Skip to content

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 ​

cpp
SparseJacobian()

~SparseJacobian ​

cpp
~SparseJacobian()

Public member functions ​

resize ​

cpp
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

ParameterDescription
cols (in)number of stored columns

operator[] ​

cpp
double operator[](size_t i) const

Parameters

ParameterDescription
i (in)index into the column-major value block (row i % 3 of stored column i / 3)

Returns the value.

cpp
double &operator[](size_t i)

Parameters

ParameterDescription
i (in)index into the column-major value block (row i % 3 of stored column i / 3)

Returns reference to the value.

operator() ​

cpp
double operator()(size_t i, size_t j) const

Parameters

ParameterDescription
i (in)row (0 to 2)
j (in)stored column (full-Jacobian column idx[j])

Returns the value.

cpp
double &operator()(size_t i, size_t j)

Parameters

ParameterDescription
i (in)row (0 to 2)
j (in)stored column (full-Jacobian column idx[j])

Returns reference to the value.

operator*= ​

cpp
void operator*=(double val)

Multiplies all stored values by val.

Parameters

ParameterDescription
val (in)scale factor

ptr ​

cpp
double *ptr()

Returns pointer to the first stored value.

cpp
const double *ptr() const

Returns pointer to the first stored value.

data ​

cpp
double *data()

Returns pointer to the first stored value (Eigen-compatible name).

cpp
const double *data() const

Returns pointer to the first stored value (Eigen-compatible name).

e ​

cpp
Eigen::Map<Eigen::Matrix<double, -1, -1>> e()

Returns Eigen map of the 3 x size value block.

cpp
const Eigen::Map<const Eigen::Matrix<double, -1, -1>> e() const

Returns read-only Eigen map of the 3 x size value block.

fillSub ​

cpp
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

ParameterDescription
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= ​

cpp
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

ParameterDescription
rhs (in)Jacobian to copy

Returns *this

Public attributes ​

size ​

cpp
size_t size

Number of stored (non-zero) columns.

capacity ​

cpp
size_t capacity

Number of allocated columns.

v ​

cpp
MatDyn v

Value storage, 3 x capacity and column-major; only the first size columns are meaningful.

idx ​

cpp
std::vector<size_t> idx

idx[i] is the full-Jacobian column (generalized-velocity index) of stored column i.

RaiSim — physics for robotics and AI.