5 #ifndef __eigenpy_numpy_allocator_hpp__ 6 #define __eigenpy_numpy_allocator_hpp__ 17 template<
typename MatType>
20 template<
typename SimilarMatrixType>
21 static PyArrayObject *
allocate(
const Eigen::MatrixBase<SimilarMatrixType> &
mat,
22 npy_intp nd, npy_intp * shape)
24 typedef typename SimilarMatrixType::Scalar Scalar;
26 const int code = Register::getTypeCode<Scalar>();
36 template<
typename MatType>
39 template<
typename SimilarMatrixType>
40 static PyArrayObject *
allocate(Eigen::PlainObjectBase<SimilarMatrixType> &
mat,
41 npy_intp nd, npy_intp * shape)
43 typedef typename SimilarMatrixType::Scalar Scalar;
44 enum { NPY_ARRAY_MEMORY_CONTIGUOUS = SimilarMatrixType::IsRowMajor ? NPY_ARRAY_CARRAY : NPY_ARRAY_FARRAY };
48 const int Scalar_type_code = Register::getTypeCode<Scalar>();
54 NPY_ARRAY_MEMORY_CONTIGUOUS | NPY_ARRAY_ALIGNED);
65 #if EIGEN_VERSION_AT_LEAST(3,2,0) 67 template<
typename MatType,
int Options,
typename Str
ide>
70 typedef Eigen::Ref<MatType,Options,Stride> RefType;
73 npy_intp nd, npy_intp * shape)
75 typedef typename RefType::Scalar Scalar;
76 enum { NPY_ARRAY_MEMORY_CONTIGUOUS = RefType::IsRowMajor ? NPY_ARRAY_CARRAY : NPY_ARRAY_FARRAY };
80 const int Scalar_type_code = Register::getTypeCode<Scalar>();
86 NPY_ARRAY_MEMORY_CONTIGUOUS | NPY_ARRAY_ALIGNED);
99 template<
typename MatType>
102 template<
typename SimilarMatrixType>
103 static PyArrayObject *
allocate(
const Eigen::PlainObjectBase<SimilarMatrixType> &
mat,
104 npy_intp nd, npy_intp * shape)
106 typedef typename SimilarMatrixType::Scalar Scalar;
107 enum { NPY_ARRAY_MEMORY_CONTIGUOUS_RO = SimilarMatrixType::IsRowMajor ? NPY_ARRAY_CARRAY_RO : NPY_ARRAY_FARRAY_RO };
111 const int Scalar_type_code = Register::getTypeCode<Scalar>();
113 static_cast<int>(nd),
116 const_cast<Scalar *>(mat.data()),
117 NPY_ARRAY_MEMORY_CONTIGUOUS_RO | NPY_ARRAY_ALIGNED);
128 #if EIGEN_VERSION_AT_LEAST(3,2,0) 130 template<
typename MatType,
int Options,
typename Str
ide>
131 struct NumpyAllocator<const Eigen::Ref<const MatType,Options,Stride> >
133 typedef const Eigen::Ref<const MatType,Options,Stride> RefType;
135 template<
typename SimilarMatrixType>
137 npy_intp nd, npy_intp * shape)
139 typedef typename SimilarMatrixType::Scalar Scalar;
140 enum { NPY_ARRAY_MEMORY_CONTIGUOUS_RO = SimilarMatrixType::IsRowMajor ? NPY_ARRAY_CARRAY_RO : NPY_ARRAY_FARRAY_RO };
144 const int Scalar_type_code = Register::getTypeCode<Scalar>();
146 static_cast<int>(nd),
149 const_cast<Scalar *>(mat.data()),
150 NPY_ARRAY_MEMORY_CONTIGUOUS_RO | NPY_ARRAY_ALIGNED);
164 #endif // ifndef __eigenpy_numpy_allocator_hpp__ static bool sharedMemory()
static PyArrayObject * allocate(Eigen::PlainObjectBase< SimilarMatrixType > &mat, npy_intp nd, npy_intp *shape)
#define call_PyArray_New(py_type_ptr, nd, shape, np_type, data_ptr, options)
#define call_PyArray_SimpleNew
static void copy(const Eigen::MatrixBase< MatrixDerived > &mat_, PyArrayObject *pyArray)
Copy mat into the Python array using Eigen::Map.
static PyArrayObject * allocate(const Eigen::PlainObjectBase< SimilarMatrixType > &mat, npy_intp nd, npy_intp *shape)
static PyArrayObject * allocate(const Eigen::MatrixBase< SimilarMatrixType > &mat, npy_intp nd, npy_intp *shape)