What is the simple and effective way to create c contiguous array from python object? Suppose I wish to create C++ Matrix class, that can be constructed using python object.
template<typename T>
struct Matrix
{
Matrix(PyObject* obj)
{
// extract nrows, ncols, allocate data and copy content
}
T* data;
int nrows;
int ncols;
};
And this constructor should accept python objects such as:
[[0., 1.], [1. 0.]]
((1, 2), (2, 3), (3, 4))
numpy.zeros((3, 5))