MCPcopy Create free account
hub / github.com/pybind/pybind11 / cast

Function cast

include/pybind11/eigen/matrix.h:700–714  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

698 }
699
700 static handle cast(const Type &src, return_value_policy /* policy */, handle /* parent */) {
701 const_cast<Type &>(src).makeCompressed();
702
703 object matrix_type
704 = module_::import("scipy.sparse").attr(rowMajor ? "csr_matrix" : "csc_matrix");
705
706 array data(src.nonZeros(), src.valuePtr());
707 array outerIndices((rowMajor ? src.rows() : src.cols()) + 1, src.outerIndexPtr());
708 array innerIndices(src.nonZeros(), src.innerIndexPtr());
709
710 return matrix_type(pybind11::make_tuple(
711 std::move(data), std::move(innerIndices), std::move(outerIndices)),
712 pybind11::make_tuple(src.rows(), src.cols()))
713 .release();
714 }
715
716 PYBIND11_TYPE_CASTER(Type,
717 const_name<(Type::IsRowMajor) != 0>("scipy.sparse.csr_matrix[",

Callers 6

castMethod · 0.70
castMethod · 0.70
castMethod · 0.50
cast_non_owningMethod · 0.50
castMethod · 0.50
cast_holderMethod · 0.50

Calls 7

importFunction · 0.85
make_tupleFunction · 0.85
moveFunction · 0.85
attrMethod · 0.80
releaseMethod · 0.80
rowsMethod · 0.45
colsMethod · 0.45

Tested by

no test coverage detected