raisim::SparseJacobian
class · #include <raisim/math.hpp>
Sparse Jacobian with three rows (e.g. of a point's position or of a body's angular velocity with respect to the generalized velocity) that stores only its non-zero columns.
v holds the values as a dense 3 x size block (column-major); column i of v is column idx[i] of the full 3 x dof Jacobian. All other columns of the full Jacobian are zero.
Constructors & destructor
SparseJacobian
SparseJacobian()~SparseJacobian
~SparseJacobian()Public member functions
resize
void resize(size_t cols)Sets the number of stored columns to cols. The storage is reallocated only when cols exceeds the current capacity (the old values are then lost). All stored values are set to zero; the entries of idx are not reset.
Parameters
| Parameter | Description |
|---|---|
cols (in) | number of stored columns |
operator[]
double operator[](size_t i) constParameters
| Parameter | Description |
|---|---|
i (in) | index into the column-major value block (row i % 3 of stored column i / 3) |
Returns the value.
double &operator[](size_t i)Parameters
| Parameter | Description |
|---|---|
i (in) | index into the column-major value block (row i % 3 of stored column i / 3) |
Returns reference to the value.
operator()
double operator()(size_t i, size_t j) constParameters
| Parameter | Description |
|---|---|
i (in) | row (0 to 2) |
j (in) | stored column (full-Jacobian column idx[j]) |
Returns the value.
double &operator()(size_t i, size_t j)Parameters
| Parameter | Description |
|---|---|
i (in) | row (0 to 2) |
j (in) | stored column (full-Jacobian column idx[j]) |
Returns reference to the value.
operator*=
void operator*=(double val)Multiplies all stored values by val.
Parameters
| Parameter | Description |
|---|---|
val (in) | scale factor |
ptr
double *ptr()Returns pointer to the first stored value.
const double *ptr() constReturns pointer to the first stored value.
data
double *data()Returns pointer to the first stored value (Eigen-compatible name).
const double *data() constReturns pointer to the first stored value (Eigen-compatible name).
e
Eigen::Map<Eigen::Matrix<double, -1, -1>> e()Returns Eigen map of the 3 x size value block.
const Eigen::Map<const Eigen::Matrix<double, -1, -1>> e() constReturns read-only Eigen map of the 3 x size value block.
fillSub
template <size_t j, size_t k>
void fillSub(size_t startRow, size_t startColumn, const Mat<j, k> &in)Copies in into the value block. Bounds are checked only in debug builds.
Parameters
| Parameter | Description |
|---|---|
startRow (in) | row of the block's top-left element |
startColumn (in) | stored column of the block's top-left element |
in (in) | block values |
operator=
SparseJacobian &operator=(const SparseJacobian &rhs)Deep copy of the size, values and indices. The storage only grows, to at least rhs.capacity columns: the articulated system sizes its Jacobians for every degree of freedom and fills them in place, so a copy (a checkpoint restore, for one) must keep that room. Grown storage is zeroed, as resize() leaves it.
Parameters
| Parameter | Description |
|---|---|
rhs (in) | Jacobian to copy |
Returns *this
Public attributes
size
size_t sizeNumber of stored (non-zero) columns.
capacity
size_t capacityNumber of allocated columns.
v
MatDyn vValue storage, 3 x capacity and column-major; only the first size columns are meaningful.
idx
std::vector<size_t> idxidx[i] is the full-Jacobian column (generalized-velocity index) of stored column i.