aligator
0.19.0
A versatile and efficient C++ library for real-time constrained trajectory optimization.
Toggle main menu visibility
Loading...
Searching...
No Matches
blk-matrix.hpp
Go to the documentation of this file.
1
3
#include "
fwd.hpp
"
4
#include "
aligator/core/blk-matrix.hpp
"
5
6
namespace
aligator
{
7
namespace
python
{
8
namespace
bp = boost::python;
9
10
template
<
typename
T>
struct
PrintableVisitor
;
11
12
template
<
typename
BlockMatrixType>
struct
BlkMatrixPythonVisitor
;
13
14
template
<
typename
MatrixType,
int
N,
int
M>
15
struct
BlkMatrixPythonVisitor
<
BlkMatrix
<MatrixType, N, M>>
16
: bp::def_visitor<BlkMatrixPythonVisitor<BlkMatrix<MatrixType, N, M>>> {
17
using
BlockMatrixType
=
BlkMatrix<MatrixType, N, M>
;
18
using
RefType
= Eigen::Ref<MatrixType>;
19
static
constexpr
bool
IsVector
=
BlockMatrixType::IsVectorAtCompileTime
;
20
21
using
Self
=
BlkMatrixPythonVisitor<BlockMatrixType>
;
22
23
static
RefType
get_block
(
BlockMatrixType
&bmt,
size_t
i,
size_t
j) {
24
return
bmt(i, j);
25
}
26
27
static
RefType
get_block2
(
BlockMatrixType
&bmt,
size_t
i) {
return
bmt[i]; }
28
29
static
RefType
blockRow
(
BlockMatrixType
&mat,
size_t
i) {
30
if
(i >= mat.
rowDims
().size()) {
31
PyErr_SetString(PyExc_IndexError,
"Index out of range."
);
32
bp::throw_error_already_set();
33
}
34
return
mat.
blockRow
(i);
35
}
36
37
static
RefType
blockCol
(
BlockMatrixType
&mat,
size_t
i) {
38
if
(i >= mat.
rowDims
().size()) {
39
PyErr_SetString(PyExc_IndexError,
"Index out of range."
);
40
bp::throw_error_already_set();
41
}
42
return
mat.
blockCol
(i);
43
}
44
45
template
<
class
... Args>
void
visit
(bp::class_<Args...> &obj)
const
{
46
obj.add_property(
47
"matrix"
, +[](
BlockMatrixType
&m) ->
RefType
{
return
m.
matrix
(); })
48
.add_property(
"rows"
, &
BlockMatrixType::rows
)
49
.add_property(
"cols"
, &
BlockMatrixType::cols
)
50
.add_property(
"rowDims"
,
51
bp::make_function(&
BlockMatrixType::rowDims
,
52
bp::return_internal_reference<>()))
53
.add_property(
"colDims"
,
54
bp::make_function(&
BlockMatrixType::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."
)
58
.def(
"setZero"
, &
BlockMatrixType::setZero
, (
"self"
_a),
59
"Set all coefficients to zero."
)
60
.def(
"__call__"
,
get_block
, (
"self"
_a,
"i"
,
"j"
))
61
.def(
PrintableVisitor<BlockMatrixType>
{});
62
if
constexpr
(
BlockMatrixType::IsVectorAtCompileTime
) {
63
obj.def(
"__call__"
,
get_block2
, (
"self"
_a,
"i"
));
64
}
65
}
66
67
static
void
expose
(
const
char
*name) {
68
bp::class_<BlockMatrixType>(name,
""
, bp::no_init).def(
Self
());
69
}
70
};
71
72
}
// namespace python
73
}
// namespace aligator
fwd.hpp
aligator::BlkMatrix
Block matrix class, with a fixed or dynamic-size number of row and column blocks.
Definition
blk-matrix.hpp:19
aligator::BlkMatrix< MatrixType, N, M >::cols
Index cols() const
Definition
blk-matrix.hpp:196
aligator::BlkMatrix< MatrixType, N, M >::colDims
const ColDimsType & colDims() const
Definition
blk-matrix.hpp:192
aligator::BlkMatrix< MatrixType, N, M >::IsVectorAtCompileTime
static constexpr bool IsVectorAtCompileTime
Definition
blk-matrix.hpp:28
aligator::BlkMatrix< MatrixType, N, M >::rows
Index rows() const
Definition
blk-matrix.hpp:195
aligator::BlkMatrix::blockRow
auto blockRow(size_t i)
Definition
blk-matrix.hpp:121
aligator::BlkMatrix::matrix
MatrixType & matrix()
Definition
blk-matrix.hpp:173
aligator::BlkMatrix::rowDims
const RowDimsType & rowDims() const
Definition
blk-matrix.hpp:190
aligator::BlkMatrix::blockCol
auto blockCol(size_t j) const
Definition
blk-matrix.hpp:129
aligator::BlkMatrix< MatrixType, N, M >::setZero
void setZero()
Definition
blk-matrix.hpp:160
blk-matrix.hpp
aligator::python
The Python bindings.
Definition
blk-matrix.hpp:7
aligator
Main package namespace.
Definition
action-model-wrap.hpp:14
aligator::python::BlkMatrixPythonVisitor< BlkMatrix< MatrixType, N, M > >::expose
static void expose(const char *name)
Definition
blk-matrix.hpp:67
aligator::python::BlkMatrixPythonVisitor< BlkMatrix< MatrixType, N, M > >::visit
void visit(bp::class_< Args... > &obj) const
Definition
blk-matrix.hpp:45
aligator::python::BlkMatrixPythonVisitor< BlkMatrix< MatrixType, N, M > >::blockRow
static RefType blockRow(BlockMatrixType &mat, size_t i)
Definition
blk-matrix.hpp:29
aligator::python::BlkMatrixPythonVisitor< BlkMatrix< MatrixType, N, M > >::RefType
Eigen::Ref< MatrixType > RefType
Definition
blk-matrix.hpp:18
aligator::python::BlkMatrixPythonVisitor< BlkMatrix< MatrixType, N, M > >::Self
BlkMatrixPythonVisitor< BlockMatrixType > Self
Definition
blk-matrix.hpp:21
aligator::python::BlkMatrixPythonVisitor< BlkMatrix< MatrixType, N, M > >::BlockMatrixType
BlkMatrix< MatrixType, N, M > BlockMatrixType
Definition
blk-matrix.hpp:17
aligator::python::BlkMatrixPythonVisitor< BlkMatrix< MatrixType, N, M > >::IsVector
static constexpr bool IsVector
Definition
blk-matrix.hpp:19
aligator::python::BlkMatrixPythonVisitor< BlkMatrix< MatrixType, N, M > >::get_block2
static RefType get_block2(BlockMatrixType &bmt, size_t i)
Definition
blk-matrix.hpp:27
aligator::python::BlkMatrixPythonVisitor< BlkMatrix< MatrixType, N, M > >::get_block
static RefType get_block(BlockMatrixType &bmt, size_t i, size_t j)
Definition
blk-matrix.hpp:23
aligator::python::BlkMatrixPythonVisitor< BlkMatrix< MatrixType, N, M > >::blockCol
static RefType blockCol(BlockMatrixType &mat, size_t i)
Definition
blk-matrix.hpp:37
aligator::python::BlkMatrixPythonVisitor
Definition
blk-matrix.hpp:12
aligator::python::PrintableVisitor
Definition
visitors.hpp:49
bindings
python
include
aligator
python
blk-matrix.hpp
Generated by
1.17.0