5 #ifndef __eigenpy_scipy_type_hpp__
6 #define __eigenpy_scipy_type_hpp__
18 static void sharedMemory(
const bool value);
20 static bool sharedMemory();
22 static bp::object getScipyType();
24 static const PyTypeObject* getScipyCSRMatrixType();
25 static const PyTypeObject* getScipyCSCMatrixType();
27 template <
typename SparseMatrix>
29 const Eigen::SparseMatrixBase<SparseMatrix>* ptr =
nullptr) {
31 return SparseMatrix::IsRowMajor ? getInstance().csr_matrix_obj
32 : getInstance().csc_matrix_obj;
35 template <
typename SparseMatrix>
37 const Eigen::SparseMatrixBase<SparseMatrix>* ptr =
nullptr) {
39 return SparseMatrix::IsRowMajor ? getInstance().csr_matrix_type
40 : getInstance().csc_matrix_type;
44 const PyTypeObject* type = Py_TYPE(obj.ptr());
46 assert(type == getInstance().csr_matrix_type ||
47 type == getInstance().csc_matrix_type);
49 bp::object dtype = obj.attr(
"dtype");
51 const PyArray_Descr* npy_type =
52 reinterpret_cast<PyArray_Descr*
>(dtype.ptr());
53 return npy_type->type_num;
69 #endif // ifndef __eigenpy_scipy_type_hpp__