Skip to content

raisim::DynamicArray ​

class · #include <raisim/math.hpp>

Derived by: raisim::MatDyn, raisim::VecDyn

Owning heap buffer of doubles; the common base of VecDyn and MatDyn.

On Linux and macOS the buffer is 32-byte aligned. Copy construction and copy assignment of this base class deliberately do not copy the data (the copy constructor leaves the new object empty, copy assignment is a no-op); VecDyn and MatDyn implement their own deep copies. Moving transfers ownership of the buffer.

Constructors & destructor ​

DynamicArray ​

cpp
DynamicArray() = default
cpp
DynamicArray(const DynamicArray &)

Does not copy the data: the new array is empty. Derived classes implement the deep copy.

cpp
DynamicArray(DynamicArray &&other) noexcept

Takes ownership of other's buffer and leaves other empty.

Parameters

ParameterDescription
other (in, out)array to move from

~DynamicArray ​

cpp
~DynamicArray()

Public member functions ​

operator= ​

cpp
DynamicArray &operator=(const DynamicArray &)

No-op: the data is not copied. Derived classes implement the deep copy.

Returns *this

cpp
DynamicArray &operator=(DynamicArray &&other) noexcept

Releases this buffer, then takes ownership of other's buffer and leaves other empty.

Parameters

ParameterDescription
other (in, out)array to move from

Returns *this

cpp
ElementRef<DynamicArray> operator=(double a)

Starts an Eigen-style comma initializer, e.g. array = 1., 2., 3.;, which writes consecutive elements. The buffer must already hold enough elements; no bounds check is done.

Parameters

ParameterDescription
a (in)value of the first element

Returns proxy that receives the following elements

ptr ​

cpp
double *ptr()

Returns pointer to the first element.

cpp
const double *ptr() const

Returns pointer to the first element.

data ​

cpp
double *data()

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

cpp
const double *data() const

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

operator[] ​

cpp
double operator[](size_t i) const

Parameters

ParameterDescription
i (in)element index

Returns element i (no bounds check).

cpp
double &operator[](size_t i)

Parameters

ParameterDescription
i (in)element index

Returns reference to element i (no bounds check).

Public attributes ​

v ​

cpp
double *v

Raw data pointer (nullptr until allocated).

RaiSim — physics for robotics and AI.