0

Pythonオブジェクトからc連続配列を作成する簡単で効果的な方法は何ですか? Python オブジェクトを使用して構築できる C++ Matrix クラスを作成したいとします。

template<typename T>
struct Matrix
{
    Matrix(PyObject* obj)
    {
        // extract nrows, ncols, allocate data and copy content
    }

    T*  data;
    int nrows;
    int ncols;
};

そして、このコンストラクターは、次のような python オブジェクトを受け入れる必要があります。

[[0., 1.], [1. 0.]]
((1, 2), (2, 3), (3, 4))
numpy.zeros((3, 5))
4

0 に答える 0