Skip to content

raisim::BlockRef ​

class · #include <raisim/math/Blocks.hpp>

Inherits: raisim::MatExpr< BlockRef< T, n, m > >

cpp
template <class T, size_t n, size_t m>
class BlockRef

Fixed-size n x m block view of a matrix, returned by Mat::segment(), Mat::head(), Mat::tail(), Mat::block() and the corner accessors. Reads and writes go to the referenced matrix; for a const matrix the accessors return by value. No bounds checking is done.

Public types ​

SelfType ​

cpp
typedef BlockRef<T, n, m> SelfType

This type.

MutableRef ​

cpp
using MutableRef = std::conditional_t<std::is_const<T>::value, double, double &>

double& for a mutable referenced matrix, double for a const one.

Constructors & destructor ​

BlockRef ​

cpp
BlockRef(T &array, size_t r_s, size_t c_s)

Parameters

ParameterDescription
array (in)referenced matrix
r_s (in)row of the block's top-left element
c_s (in)column of the block's top-left element

Public member functions ​

operator() ​

cpp
double operator()(size_t i) const

Parameters

ParameterDescription
i (in)column-major linear index into the block

Returns element i of the block in column-major linear order.

cpp
MutableRef operator()(size_t i)

Parameters

ParameterDescription
i (in)column-major linear index into the block

Returns element i of the block in column-major linear order.

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

Parameters

ParameterDescription
i (in)row index
j (in)column index

Returns element (i, j) of the block.

cpp
MutableRef operator()(size_t i, size_t j)

Parameters

ParameterDescription
i (in)row index
j (in)column index

Returns element (i, j) of the block.

operator[] ​

cpp
double operator[](size_t i) const

Parameters

ParameterDescription
i (in)column-major linear index into the block

Returns element i of the block in column-major linear order.

cpp
MutableRef operator[](size_t i)

Parameters

ParameterDescription
i (in)column-major linear index into the block

Returns element i of the block in column-major linear order.

Static member functions ​

size static ​

cpp
static constexpr size_t size()

Returns number of elements, n * m.

rows static ​

cpp
static constexpr size_t rows()

Returns number of rows, n.

cols static ​

cpp
static constexpr size_t cols()

Returns number of columns, m.

Public attributes ​

ref ​

cpp
T &ref

Referenced matrix.

rowStart ​

cpp
size_t rowStart

Row of the block's top-left element in the referenced matrix.

colStart ​

cpp
size_t colStart

Column of the block's top-left element in the referenced matrix.

RaiSim — physics for robotics and AI.