#include <sparse_obj.hpp>
|
template<typename T > |
static void | call (py::module &mod) |
|
Definition at line 56 of file sparse_obj.hpp.
◆ call()
template<typename T >
static void CarmaSparseObjInterfacer::call |
( |
py::module & |
mod | ) |
|
|
static |
Definition at line 57 of file sparse_obj.hpp.
58 auto name = appendName<T>(
"sparse_obj_");
61 py::class_<Class>(mod,
name.data(), py::buffer_protocol())
62 .def(
"get_csr",[](Class &frame){
63 py::object CSR = py::module::import(
"scipy.sparse").attr(
"csr_matrix");
64 int dim1 =
frame.get_dims(1);
65 int dim2 =
frame.get_dims(2);
66 int nnz =
frame.nz_elem;
68 std::vector<int> rowind = std::vector<int>(dim1 + 1);
69 std::vector<int> colind = std::vector<int>(nnz);
70 std::vector<T>
data = std::vector<T>(nnz);
72 frame.sparse_to_host(rowind.data(), colind.data(),
data.data());
73 py::tuple csrMat = py::make_tuple(py::array(
data.size(),
data.data()), py::array(colind.size(),colind.data()),py::array(rowind.size(), rowind.data()));
74 py::tuple shape = py::make_tuple(dim1,dim2);
77 return CSR(csrMat,py::arg(
"shape")=shape);
The documentation for this struct was generated from the following file: