6namespace bp = boost::python;
10template <
typename MatrixType,
int N,
int M>
12 : bp::def_visitor<BlkMatrixPythonVisitor<BlkMatrix<MatrixType, N, M>>> {
23 if (i >= mat.
rowDims().size()) {
24 PyErr_SetString(PyExc_IndexError,
"Index out of range.");
25 bp::throw_error_already_set();
30 template <
class... Args>
void visit(bp::class_<Args...> &obj)
const {
35 .add_property(
"rowDims",
37 bp::return_internal_reference<>()))
38 .add_property(
"colDims",
40 bp::return_internal_reference<>()))
41 .def(
"blockRow",
blockRow,
"Get a block row by index.")
42 .def(
"__call__",
get_block, (
"self"_a,
"i",
"j"));
45 static void expose(
const char *name) {
46 bp::class_<BlockMatrixType>(name,
"", bp::no_init).def(
Self());
Block matrix class, with a fixed-size number of row and column blocks.
const row_dim_t & rowDims() const
const col_dim_t & colDims() 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 RefType get_block(BlockMatrixType &bmt, size_t i, size_t j)