MCPcopy Create free account
hub / github.com/NVIDIA/cuda-quantum / cmat_to_numpy

Function cmat_to_numpy

python/runtime/cudaq/operators/py_helpers.cpp:49–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49nanobind::object cmat_to_numpy(complex_matrix &cmat) {
50 auto rows = cmat.rows();
51 auto cols = cmat.cols();
52 auto *data = cmat.get_data(complex_matrix::order::row_major);
53
54 // Use .cast() to force immediate creation of the numpy array.
55 // Since no owner is specified, rv_policy::automatic will copy the data,
56 // making this safe even when cmat is a temporary (e.g. in get_unitary).
57 return nanobind::ndarray<nanobind::numpy, std::complex<double>,
58 nanobind::shape<-1, -1>>(data, {rows, cols},
59 nanobind::handle())
60 .cast();
61};
62
63} // namespace cudaq::detail

Callers 7

bindBosonOperatorFunction · 0.85
bindSpinOperatorFunction · 0.85
bindMatrixOperatorFunction · 0.85
bindFermionOperatorFunction · 0.85
bindOperatorHandlersFunction · 0.85
bindComplexMatrixFunction · 0.85
get_unitary_implFunction · 0.85

Calls 3

rowsMethod · 0.80
colsMethod · 0.80
get_dataMethod · 0.80

Tested by

no test coverage detected