COMPASS  5.0.0
End-to-end AO simulation tool using GPU acceleration
CarmaSparseObjInterfacer Struct Reference

#include <sparse_obj.hpp>

Collaboration diagram for CarmaSparseObjInterfacer:

Static Public Member Functions

template<typename T >
static void call (py::module &mod)
 

Detailed Description

Definition at line 56 of file sparse_obj.hpp.

Member Function Documentation

◆ call()

template<typename T >
static void CarmaSparseObjInterfacer::call ( py::module &  mod)
static

Definition at line 57 of file sparse_obj.hpp.

57  {
58  auto name = appendName<T>("sparse_obj_");
59  using Class = CarmaSparseObj<T>;
60 
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;
67 
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);
71 
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);
75 
76 
77  return CSR(csrMat,py::arg("shape")=shape);
78  });
79 }

The documentation for this struct was generated from the following file:
correlation_bokeh.data
data
Definition: correlation_bokeh.py:280
CarmaSparseObj
this class provides wrappers to the generic carma sparse object
Definition: carma_sparse_host_obj.h:48
test_rtcFHF.frame
frame
Definition: test_rtcFHF.py:36
layers_test.name
string name
Definition: layers_test.py:21