8namespace bp = boost::python;
14template <
typename MatrixType,
int N,
int M>
16 : bp::def_visitor<BlkMatrixPythonVisitor<BlkMatrix<MatrixType, N, M>>> {
30 if (i >= mat.
rowDims().size()) {
31 PyErr_SetString(PyExc_IndexError,
"Index out of range.");
32 bp::throw_error_already_set();
38 if (i >= mat.
rowDims().size()) {
39 PyErr_SetString(PyExc_IndexError,
"Index out of range.");
40 bp::throw_error_already_set();
45 template <
class... Args>
void visit(bp::class_<Args...> &obj)
const {
50 .add_property(
"rowDims",
52 bp::return_internal_reference<>()))
53 .add_property(
"colDims",
55 bp::return_internal_reference<>()))
56 .def(
"blockRow",
blockRow,
"Get a block row by index.")
57 .def(
"blockCol",
blockCol,
"Get a block row by index.")
59 "Set all coefficients to zero.")
60 .def(
"__call__",
get_block, (
"self"_a,
"i",
"j"))
63 obj.def(
"__call__",
get_block2, (
"self"_a,
"i"));
67 static void expose(
const char *name) {
68 bp::class_<BlockMatrixType>(name,
"", bp::no_init).def(
Self());
Block matrix class, with a fixed or dynamic-size number of row and column blocks.
const ColDimsType & colDims() const
static constexpr bool IsVectorAtCompileTime
const RowDimsType & rowDims() const
auto blockCol(size_t j) const
static void expose(const char *name)
void visit(bp::class_< Args... > &obj) const
static RefType blockRow(BlockMatrixType &mat, size_t i)
Eigen::Ref< MatrixType > RefType
BlkMatrixPythonVisitor< BlockMatrixType > Self
BlkMatrix< MatrixType, N, M > BlockMatrixType
static constexpr bool IsVector
static RefType get_block2(BlockMatrixType &bmt, size_t i)
static RefType get_block(BlockMatrixType &bmt, size_t i, size_t j)
static RefType blockCol(BlockMatrixType &mat, size_t i)