Sleipnir C++ API
Loading...
Searching...
No Matches
sleipnir::VariableMatrix Class Reference

#include <sleipnir/autodiff/VariableMatrix.hpp>

Classes

class  const_iterator
 
struct  empty_t
 
class  iterator
 

Public Member Functions

 VariableMatrix ()=default
 
 VariableMatrix (int rows)
 
 VariableMatrix (int rows, int cols)
 
 VariableMatrix (empty_t, int rows, int cols)
 
 VariableMatrix (std::initializer_list< std::initializer_list< Variable > > list)
 
 VariableMatrix (const std::vector< std::vector< double > > &list)
 
 VariableMatrix (const std::vector< std::vector< Variable > > &list)
 
template<typename Derived >
 VariableMatrix (const Eigen::MatrixBase< Derived > &values)
 
template<typename Derived >
 VariableMatrix (const Eigen::DiagonalBase< Derived > &values)
 
template<typename Derived >
VariableMatrixoperator= (const Eigen::MatrixBase< Derived > &values)
 
template<typename Derived >
requires std::same_as<typename Derived::Scalar, double>
void SetValue (const Eigen::MatrixBase< Derived > &values)
 
 VariableMatrix (const Variable &variable)
 
 VariableMatrix (Variable &&variable)
 
 VariableMatrix (const VariableBlock< VariableMatrix > &values)
 
 VariableMatrix (const VariableBlock< const VariableMatrix > &values)
 
 VariableMatrix (std::span< const Variable > values)
 
 VariableMatrix (std::span< const Variable > values, int rows, int cols)
 
Variableoperator() (int row, int col)
 
const Variableoperator() (int row, int col) const
 
Variableoperator() (int row)
 
const Variableoperator() (int row) const
 
VariableBlock< VariableMatrixBlock (int rowOffset, int colOffset, int blockRows, int blockCols)
 
const VariableBlock< const VariableMatrixBlock (int rowOffset, int colOffset, int blockRows, int blockCols) const
 
VariableBlock< VariableMatrixoperator() (Slice rowSlice, Slice colSlice)
 
const VariableBlock< const VariableMatrixoperator() (Slice rowSlice, Slice colSlice) const
 
VariableBlock< VariableMatrixoperator() (Slice rowSlice, int rowSliceLength, Slice colSlice, int colSliceLength)
 
const VariableBlock< const VariableMatrixoperator() (Slice rowSlice, int rowSliceLength, Slice colSlice, int colSliceLength) const
 
VariableBlock< VariableMatrixSegment (int offset, int length)
 
const VariableBlock< const VariableMatrixSegment (int offset, int length) const
 
VariableBlock< VariableMatrixRow (int row)
 
const VariableBlock< const VariableMatrixRow (int row) const
 
VariableBlock< VariableMatrixCol (int col)
 
const VariableBlock< const VariableMatrixCol (int col) const
 
VariableMatrixoperator*= (const VariableMatrix &rhs)
 
VariableMatrixoperator/= (const Variable &rhs)
 
VariableMatrixoperator+= (const VariableMatrix &rhs)
 
VariableMatrixoperator-= (const VariableMatrix &rhs)
 
 operator Variable () const
 
VariableMatrix T () const
 
int Rows () const
 
int Cols () const
 
double Value (int row, int col)
 
double Value (int index)
 
Eigen::MatrixXd Value ()
 
VariableMatrix CwiseTransform (function_ref< Variable(const Variable &x)> unaryOp) const
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
size_t size () const
 

Static Public Member Functions

static VariableMatrix Zero (int rows, int cols)
 
static VariableMatrix Ones (int rows, int cols)
 

Static Public Attributes

static constexpr empty_t empty {}
 

Friends

SLEIPNIR_DLLEXPORT VariableMatrix operator* (const VariableMatrix &lhs, const VariableMatrix &rhs)
 
SLEIPNIR_DLLEXPORT VariableMatrix operator* (const VariableMatrix &lhs, const Variable &rhs)
 
SLEIPNIR_DLLEXPORT VariableMatrix operator* (const VariableMatrix &lhs, double rhs)
 
SLEIPNIR_DLLEXPORT VariableMatrix operator* (const Variable &lhs, const VariableMatrix &rhs)
 
SLEIPNIR_DLLEXPORT VariableMatrix operator* (double lhs, const VariableMatrix &rhs)
 
SLEIPNIR_DLLEXPORT VariableMatrix operator/ (const VariableMatrix &lhs, const Variable &rhs)
 
SLEIPNIR_DLLEXPORT VariableMatrix operator+ (const VariableMatrix &lhs, const VariableMatrix &rhs)
 
SLEIPNIR_DLLEXPORT VariableMatrix operator- (const VariableMatrix &lhs, const VariableMatrix &rhs)
 
SLEIPNIR_DLLEXPORT VariableMatrix operator- (const VariableMatrix &lhs)
 

Detailed Description

A matrix of autodiff variables.

Constructor & Destructor Documentation

◆ VariableMatrix() [1/15]

sleipnir::VariableMatrix::VariableMatrix ( )
default

Constructs an empty VariableMatrix.

◆ VariableMatrix() [2/15]

sleipnir::VariableMatrix::VariableMatrix ( int  rows)
inlineexplicit

Constructs a VariableMatrix column vector with the given rows.

Parameters
rowsThe number of matrix rows.

◆ VariableMatrix() [3/15]

sleipnir::VariableMatrix::VariableMatrix ( int  rows,
int  cols 
)
inline

Constructs a zero-initialized VariableMatrix with the given dimensions.

Parameters
rowsThe number of matrix rows.
colsThe number of matrix columns.

◆ VariableMatrix() [4/15]

sleipnir::VariableMatrix::VariableMatrix ( empty_t  ,
int  rows,
int  cols 
)
inline

Constructs an empty VariableMatrix with the given dimensions.

Parameters
rowsThe number of matrix rows.
colsThe number of matrix columns.

◆ VariableMatrix() [5/15]

sleipnir::VariableMatrix::VariableMatrix ( std::initializer_list< std::initializer_list< Variable > >  list)
inline

Constructs a scalar VariableMatrix from a nested list of Variables.

Parameters
listThe nested list of Variables.

◆ VariableMatrix() [6/15]

sleipnir::VariableMatrix::VariableMatrix ( const std::vector< std::vector< double > > &  list)
inline

Constructs a scalar VariableMatrix from a nested list of doubles.

This overload is for Python bindings only.

Parameters
listThe nested list of Variables.

◆ VariableMatrix() [7/15]

sleipnir::VariableMatrix::VariableMatrix ( const std::vector< std::vector< Variable > > &  list)
inline

Constructs a scalar VariableMatrix from a nested list of Variables.

This overload is for Python bindings only.

Parameters
listThe nested list of Variables.

◆ VariableMatrix() [8/15]

template<typename Derived >
sleipnir::VariableMatrix::VariableMatrix ( const Eigen::MatrixBase< Derived > &  values)
inline

Constructs a VariableMatrix from an Eigen matrix.

Parameters
valuesEigen matrix of values.

◆ VariableMatrix() [9/15]

template<typename Derived >
sleipnir::VariableMatrix::VariableMatrix ( const Eigen::DiagonalBase< Derived > &  values)
inline

Constructs a VariableMatrix from an Eigen diagonal matrix.

Parameters
valuesDiagonal matrix of values.

◆ VariableMatrix() [10/15]

sleipnir::VariableMatrix::VariableMatrix ( const Variable variable)
inline

Constructs a scalar VariableMatrix from a Variable.

Parameters
variableVariable.

◆ VariableMatrix() [11/15]

sleipnir::VariableMatrix::VariableMatrix ( Variable &&  variable)
inline

Constructs a scalar VariableMatrix from a Variable.

Parameters
variableVariable.

◆ VariableMatrix() [12/15]

sleipnir::VariableMatrix::VariableMatrix ( const VariableBlock< VariableMatrix > &  values)
inline

Constructs a VariableMatrix from a VariableBlock.

Parameters
valuesVariableBlock of values.

◆ VariableMatrix() [13/15]

sleipnir::VariableMatrix::VariableMatrix ( const VariableBlock< const VariableMatrix > &  values)
inline

Constructs a VariableMatrix from a VariableBlock.

Parameters
valuesVariableBlock of values.

◆ VariableMatrix() [14/15]

sleipnir::VariableMatrix::VariableMatrix ( std::span< const Variable values)
inlineexplicit

Constructs a column vector wrapper around a Variable array.

Parameters
valuesVariable array to wrap.

◆ VariableMatrix() [15/15]

sleipnir::VariableMatrix::VariableMatrix ( std::span< const Variable values,
int  rows,
int  cols 
)
inline

Constructs a matrix wrapper around a Variable array.

Parameters
valuesVariable array to wrap.
rowsThe number of matrix rows.
colsThe number of matrix columns.

Member Function Documentation

◆ begin() [1/2]

iterator sleipnir::VariableMatrix::begin ( )
inline

Returns begin iterator.

◆ begin() [2/2]

const_iterator sleipnir::VariableMatrix::begin ( ) const
inline

Returns begin iterator.

◆ Block() [1/2]

VariableBlock< VariableMatrix > sleipnir::VariableMatrix::Block ( int  rowOffset,
int  colOffset,
int  blockRows,
int  blockCols 
)
inline

Returns a block of the variable matrix.

Parameters
rowOffsetThe row offset of the block selection.
colOffsetThe column offset of the block selection.
blockRowsThe number of rows in the block selection.
blockColsThe number of columns in the block selection.

◆ Block() [2/2]

const VariableBlock< const VariableMatrix > sleipnir::VariableMatrix::Block ( int  rowOffset,
int  colOffset,
int  blockRows,
int  blockCols 
) const
inline

Returns a block of the variable matrix.

Parameters
rowOffsetThe row offset of the block selection.
colOffsetThe column offset of the block selection.
blockRowsThe number of rows in the block selection.
blockColsThe number of columns in the block selection.

◆ cbegin()

const_iterator sleipnir::VariableMatrix::cbegin ( ) const
inline

Returns begin iterator.

◆ cend()

const_iterator sleipnir::VariableMatrix::cend ( ) const
inline

Returns end iterator.

◆ Col() [1/2]

VariableBlock< VariableMatrix > sleipnir::VariableMatrix::Col ( int  col)
inline

Returns a column slice of the variable matrix.

Parameters
colThe column to slice.

◆ Col() [2/2]

const VariableBlock< const VariableMatrix > sleipnir::VariableMatrix::Col ( int  col) const
inline

Returns a column slice of the variable matrix.

Parameters
colThe column to slice.

◆ Cols()

int sleipnir::VariableMatrix::Cols ( ) const
inline

Returns number of columns in the matrix.

◆ CwiseTransform()

VariableMatrix sleipnir::VariableMatrix::CwiseTransform ( function_ref< Variable(const Variable &x)>  unaryOp) const
inline

Transforms the matrix coefficient-wise with an unary operator.

Parameters
unaryOpThe unary operator to use for the transform operation.

◆ end() [1/2]

iterator sleipnir::VariableMatrix::end ( )
inline

Returns end iterator.

◆ end() [2/2]

const_iterator sleipnir::VariableMatrix::end ( ) const
inline

Returns end iterator.

◆ Ones()

static VariableMatrix sleipnir::VariableMatrix::Ones ( int  rows,
int  cols 
)
inlinestatic

Returns a variable matrix filled with ones.

Parameters
rowsThe number of matrix rows.
colsThe number of matrix columns.

◆ operator Variable()

sleipnir::VariableMatrix::operator Variable ( ) const
inline

Implicit conversion operator from 1x1 VariableMatrix to Variable.

◆ operator()() [1/8]

Variable & sleipnir::VariableMatrix::operator() ( int  row)
inline

Returns a block pointing to the given row.

Parameters
rowThe block row.

◆ operator()() [2/8]

const Variable & sleipnir::VariableMatrix::operator() ( int  row) const
inline

Returns a block pointing to the given row.

Parameters
rowThe block row.

◆ operator()() [3/8]

Variable & sleipnir::VariableMatrix::operator() ( int  row,
int  col 
)
inline

Returns a block pointing to the given row and column.

Parameters
rowThe block row.
colThe block column.

◆ operator()() [4/8]

const Variable & sleipnir::VariableMatrix::operator() ( int  row,
int  col 
) const
inline

Returns a block pointing to the given row and column.

Parameters
rowThe block row.
colThe block column.

◆ operator()() [5/8]

VariableBlock< VariableMatrix > sleipnir::VariableMatrix::operator() ( Slice  rowSlice,
int  rowSliceLength,
Slice  colSlice,
int  colSliceLength 
)
inline

Returns a slice of the variable matrix.

The given slices aren't adjusted. This overload is for Python bindings only.

Parameters
rowSliceThe row slice.
rowSliceLengthThe row slice length.
colSliceThe column slice.
colSliceLengthThe column slice length.

◆ operator()() [6/8]

const VariableBlock< const VariableMatrix > sleipnir::VariableMatrix::operator() ( Slice  rowSlice,
int  rowSliceLength,
Slice  colSlice,
int  colSliceLength 
) const
inline

Returns a slice of the variable matrix.

The given slices aren't adjusted. This overload is for Python bindings only.

Parameters
rowSliceThe row slice.
rowSliceLengthThe row slice length.
colSliceThe column slice.
colSliceLengthThe column slice length.

◆ operator()() [7/8]

VariableBlock< VariableMatrix > sleipnir::VariableMatrix::operator() ( Slice  rowSlice,
Slice  colSlice 
)
inline

Returns a slice of the variable matrix.

Parameters
rowSliceThe row slice.
colSliceThe column slice.

◆ operator()() [8/8]

const VariableBlock< const VariableMatrix > sleipnir::VariableMatrix::operator() ( Slice  rowSlice,
Slice  colSlice 
) const
inline

Returns a slice of the variable matrix.

Parameters
rowSliceThe row slice.
colSliceThe column slice.

◆ operator*=()

VariableMatrix & sleipnir::VariableMatrix::operator*= ( const VariableMatrix rhs)
inline

Compound matrix multiplication-assignment operator.

Parameters
rhsVariable to multiply.

◆ operator+=()

VariableMatrix & sleipnir::VariableMatrix::operator+= ( const VariableMatrix rhs)
inline

Compound addition-assignment operator.

Parameters
rhsVariable to add.

◆ operator-=()

VariableMatrix & sleipnir::VariableMatrix::operator-= ( const VariableMatrix rhs)
inline

Compound subtraction-assignment operator.

Parameters
rhsVariable to subtract.

◆ operator/=()

VariableMatrix & sleipnir::VariableMatrix::operator/= ( const Variable rhs)
inline

Compound matrix division-assignment operator (only enabled when rhs is a scalar).

Parameters
rhsVariable to divide.

◆ operator=()

template<typename Derived >
VariableMatrix & sleipnir::VariableMatrix::operator= ( const Eigen::MatrixBase< Derived > &  values)
inline

Assigns an Eigen matrix to a VariableMatrix.

Parameters
valuesEigen matrix of values.

◆ Row() [1/2]

VariableBlock< VariableMatrix > sleipnir::VariableMatrix::Row ( int  row)
inline

Returns a row slice of the variable matrix.

Parameters
rowThe row to slice.

◆ Row() [2/2]

const VariableBlock< const VariableMatrix > sleipnir::VariableMatrix::Row ( int  row) const
inline

Returns a row slice of the variable matrix.

Parameters
rowThe row to slice.

◆ Rows()

int sleipnir::VariableMatrix::Rows ( ) const
inline

Returns number of rows in the matrix.

◆ Segment() [1/2]

VariableBlock< VariableMatrix > sleipnir::VariableMatrix::Segment ( int  offset,
int  length 
)
inline

Returns a segment of the variable vector.

Parameters
offsetThe offset of the segment.
lengthThe length of the segment.

◆ Segment() [2/2]

const VariableBlock< const VariableMatrix > sleipnir::VariableMatrix::Segment ( int  offset,
int  length 
) const
inline

Returns a segment of the variable vector.

Parameters
offsetThe offset of the segment.
lengthThe length of the segment.

◆ SetValue()

template<typename Derived >
requires std::same_as<typename Derived::Scalar, double>
void sleipnir::VariableMatrix::SetValue ( const Eigen::MatrixBase< Derived > &  values)
inline

Sets the VariableMatrix's internal values.

Parameters
valuesEigen matrix of values.

◆ size()

size_t sleipnir::VariableMatrix::size ( ) const
inline

Returns number of elements in matrix.

◆ T()

VariableMatrix sleipnir::VariableMatrix::T ( ) const
inline

Returns the transpose of the variable matrix.

◆ Value() [1/3]

Eigen::MatrixXd sleipnir::VariableMatrix::Value ( )
inline

Returns the contents of the variable matrix.

◆ Value() [2/3]

double sleipnir::VariableMatrix::Value ( int  index)
inline

Returns a row of the variable column vector.

Parameters
indexThe index of the element to return.

◆ Value() [3/3]

double sleipnir::VariableMatrix::Value ( int  row,
int  col 
)
inline

Returns an element of the variable matrix.

Parameters
rowThe row of the element to return.
colThe column of the element to return.

◆ Zero()

static VariableMatrix sleipnir::VariableMatrix::Zero ( int  rows,
int  cols 
)
inlinestatic

Returns a variable matrix filled with zeroes.

Parameters
rowsThe number of matrix rows.
colsThe number of matrix columns.

Friends And Related Symbol Documentation

◆ operator* [1/5]

Scalar-matrix multiplication operator.

Parameters
lhsOperator left-hand side.
rhsOperator right-hand side.

◆ operator* [2/5]

Matrix-scalar multiplication operator.

Parameters
lhsOperator left-hand side.
rhsOperator right-hand side.

◆ operator* [3/5]

Matrix multiplication operator.

Parameters
lhsOperator left-hand side.
rhsOperator right-hand side.

◆ operator* [4/5]

Matrix-scalar multiplication operator.

Parameters
lhsOperator left-hand side.
rhsOperator right-hand side.

◆ operator* [5/5]

Scalar-matrix multiplication operator.

Parameters
lhsOperator left-hand side.
rhsOperator right-hand side.

◆ operator+

Binary addition operator.

Parameters
lhsOperator left-hand side.
rhsOperator right-hand side.

◆ operator- [1/2]

Unary minus operator.

Parameters
lhsOperand for unary minus.

◆ operator- [2/2]

Binary subtraction operator.

Parameters
lhsOperator left-hand side.
rhsOperator right-hand side.

◆ operator/

Binary division operator (only enabled when rhs is a scalar).

Parameters
lhsOperator left-hand side.
rhsOperator right-hand side.

Member Data Documentation

◆ empty

constexpr empty_t sleipnir::VariableMatrix::empty {}
staticconstexpr

The documentation for this class was generated from the following file: