WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
sleipnir::VariableMatrix Class Reference

A matrix of autodiff variables. More...

#include </home/runner/work/allwpilib/allwpilib/wpimath/src/main/native/thirdparty/sleipnir/include/sleipnir/autodiff/VariableMatrix.hpp>

Classes

class  const_iterator
 
class  iterator
 

Public Member Functions

 VariableMatrix ()=default
 Constructs an empty VariableMatrix.
 
 VariableMatrix (int rows)
 Constructs a VariableMatrix column vector with the given rows.
 
 VariableMatrix (int rows, int cols)
 Constructs a VariableMatrix with the given dimensions.
 
 VariableMatrix (std::initializer_list< std::initializer_list< Variable > > list)
 Constructs a scalar VariableMatrix from a nested list of Variables.
 
 VariableMatrix (const std::vector< std::vector< double > > &list)
 Constructs a scalar VariableMatrix from a nested list of doubles.
 
 VariableMatrix (const std::vector< std::vector< Variable > > &list)
 Constructs a scalar VariableMatrix from a nested list of Variables.
 
template<typename Derived >
 VariableMatrix (const Eigen::MatrixBase< Derived > &values)
 Constructs a VariableMatrix from an Eigen matrix.
 
template<typename Derived >
 VariableMatrix (const Eigen::DiagonalBase< Derived > &values)
 Constructs a VariableMatrix from an Eigen diagonal matrix.
 
template<typename Derived >
VariableMatrixoperator= (const Eigen::MatrixBase< Derived > &values)
 Assigns an Eigen matrix to a VariableMatrix.
 
template<typename Derived >
requires std::same_as<typename Derived::Scalar, double>
void SetValue (const Eigen::MatrixBase< Derived > &values)
 Sets the VariableMatrix's internal values.
 
 VariableMatrix (const Variable &variable)
 Constructs a scalar VariableMatrix from a Variable.
 
 VariableMatrix (Variable &&variable)
 Constructs a scalar VariableMatrix from a Variable.
 
 VariableMatrix (const VariableBlock< VariableMatrix > &values)
 Constructs a VariableMatrix from a VariableBlock.
 
 VariableMatrix (const VariableBlock< const VariableMatrix > &values)
 Constructs a VariableMatrix from a VariableBlock.
 
 VariableMatrix (std::span< const Variable > values)
 Constructs a column vector wrapper around a Variable array.
 
 VariableMatrix (std::span< const Variable > values, int rows, int cols)
 Constructs a matrix wrapper around a Variable array.
 
Variableoperator() (int row, int col)
 Returns a block pointing to the given row and column.
 
const Variableoperator() (int row, int col) const
 Returns a block pointing to the given row and column.
 
Variableoperator() (int row)
 Returns a block pointing to the given row.
 
const Variableoperator() (int row) const
 Returns a block pointing to the given row.
 
VariableBlock< VariableMatrixBlock (int rowOffset, int colOffset, int blockRows, int blockCols)
 Returns a block of the variable matrix.
 
const VariableBlock< const VariableMatrixBlock (int rowOffset, int colOffset, int blockRows, int blockCols) const
 Returns a block of the variable matrix.
 
VariableBlock< VariableMatrixoperator() (Slice rowSlice, Slice colSlice)
 Returns a slice of the variable matrix.
 
const VariableBlock< const VariableMatrixoperator() (Slice rowSlice, Slice colSlice) const
 Returns a slice of the variable matrix.
 
VariableBlock< VariableMatrixoperator() (Slice rowSlice, int rowSliceLength, Slice colSlice, int colSliceLength)
 Returns a slice of the variable matrix.
 
const VariableBlock< const VariableMatrixoperator() (Slice rowSlice, int rowSliceLength, Slice colSlice, int colSliceLength) const
 Returns a slice of the variable matrix.
 
VariableBlock< VariableMatrixSegment (int offset, int length)
 Returns a segment of the variable vector.
 
const VariableBlock< const VariableMatrixSegment (int offset, int length) const
 Returns a segment of the variable vector.
 
VariableBlock< VariableMatrixRow (int row)
 Returns a row slice of the variable matrix.
 
const VariableBlock< const VariableMatrixRow (int row) const
 Returns a row slice of the variable matrix.
 
VariableBlock< VariableMatrixCol (int col)
 Returns a column slice of the variable matrix.
 
const VariableBlock< const VariableMatrixCol (int col) const
 Returns a column slice of the variable matrix.
 
VariableMatrixoperator*= (const VariableMatrix &rhs)
 Compound matrix multiplication-assignment operator.
 
VariableMatrixoperator/= (const Variable &rhs)
 Compound matrix division-assignment operator (only enabled when rhs is a scalar).
 
VariableMatrixoperator+= (const VariableMatrix &rhs)
 Compound addition-assignment operator.
 
VariableMatrixoperator-= (const VariableMatrix &rhs)
 Compound subtraction-assignment operator.
 
 operator Variable () const
 Implicit conversion operator from 1x1 VariableMatrix to Variable.
 
VariableMatrix T () const
 Returns the transpose of the variable matrix.
 
int Rows () const
 Returns number of rows in the matrix.
 
int Cols () const
 Returns number of columns in the matrix.
 
double Value (int row, int col)
 Returns an element of the variable matrix.
 
double Value (int index)
 Returns a row of the variable column vector.
 
Eigen::MatrixXd Value ()
 Returns the contents of the variable matrix.
 
VariableMatrix CwiseTransform (function_ref< Variable(const Variable &x)> unaryOp) const
 Transforms the matrix coefficient-wise with an unary operator.
 
iterator begin ()
 Returns begin iterator.
 
iterator end ()
 Returns end iterator.
 
const_iterator begin () const
 Returns begin iterator.
 
const_iterator end () const
 Returns end iterator.
 
const_iterator cbegin () const
 Returns begin iterator.
 
const_iterator cend () const
 Returns end iterator.
 
size_t size () const
 Returns number of elements in matrix.
 

Static Public Member Functions

static VariableMatrix Zero (int rows, int cols)
 Returns a variable matrix filled with zeroes.
 
static VariableMatrix Ones (int rows, int cols)
 Returns a variable matrix filled with ones.
 

Friends

SLEIPNIR_DLLEXPORT VariableMatrix operator* (const VariableMatrix &lhs, const VariableMatrix &rhs)
 Matrix multiplication operator.
 
SLEIPNIR_DLLEXPORT VariableMatrix operator* (const VariableMatrix &lhs, const Variable &rhs)
 Matrix-scalar multiplication operator.
 
SLEIPNIR_DLLEXPORT VariableMatrix operator* (const VariableMatrix &lhs, double rhs)
 Matrix-scalar multiplication operator.
 
SLEIPNIR_DLLEXPORT VariableMatrix operator* (const Variable &lhs, const VariableMatrix &rhs)
 Scalar-matrix multiplication operator.
 
SLEIPNIR_DLLEXPORT VariableMatrix operator* (double lhs, const VariableMatrix &rhs)
 Scalar-matrix multiplication operator.
 
SLEIPNIR_DLLEXPORT VariableMatrix operator/ (const VariableMatrix &lhs, const Variable &rhs)
 Binary division operator (only enabled when rhs is a scalar).
 
SLEIPNIR_DLLEXPORT VariableMatrix operator+ (const VariableMatrix &lhs, const VariableMatrix &rhs)
 Binary addition operator.
 
SLEIPNIR_DLLEXPORT VariableMatrix operator- (const VariableMatrix &lhs, const VariableMatrix &rhs)
 Binary subtraction operator.
 
SLEIPNIR_DLLEXPORT VariableMatrix operator- (const VariableMatrix &lhs)
 Unary minus operator.
 

Detailed Description

A matrix of autodiff variables.

Constructor & Destructor Documentation

◆ VariableMatrix() [1/14]

sleipnir::VariableMatrix::VariableMatrix ( )
default

Constructs an empty VariableMatrix.

◆ VariableMatrix() [2/14]

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

Constructs a VariableMatrix column vector with the given rows.

Parameters
rowsThe number of matrix rows.

◆ VariableMatrix() [3/14]

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

Constructs a VariableMatrix with the given dimensions.

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

◆ VariableMatrix() [4/14]

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() [5/14]

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() [6/14]

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() [7/14]

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() [8/14]

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() [9/14]

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

Constructs a scalar VariableMatrix from a Variable.

Parameters
variableVariable.

◆ VariableMatrix() [10/14]

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

Constructs a scalar VariableMatrix from a Variable.

Parameters
variableVariable.

◆ VariableMatrix() [11/14]

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

Constructs a VariableMatrix from a VariableBlock.

Parameters
valuesVariableBlock of values.

◆ VariableMatrix() [12/14]

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

Constructs a VariableMatrix from a VariableBlock.

Parameters
valuesVariableBlock of values.

◆ VariableMatrix() [13/14]

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

Constructs a column vector wrapper around a Variable array.

Parameters
valuesVariable array to wrap.

◆ VariableMatrix() [14/14]

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]

SLEIPNIR_DLLEXPORT VariableMatrix operator* ( const Variable & lhs,
const VariableMatrix & rhs )
friend

Scalar-matrix multiplication operator.

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

◆ operator* [2/5]

SLEIPNIR_DLLEXPORT VariableMatrix operator* ( const VariableMatrix & lhs,
const Variable & rhs )
friend

Matrix-scalar multiplication operator.

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

◆ operator* [3/5]

SLEIPNIR_DLLEXPORT VariableMatrix operator* ( const VariableMatrix & lhs,
const VariableMatrix & rhs )
friend

Matrix multiplication operator.

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

◆ operator* [4/5]

SLEIPNIR_DLLEXPORT VariableMatrix operator* ( const VariableMatrix & lhs,
double rhs )
friend

Matrix-scalar multiplication operator.

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

◆ operator* [5/5]

SLEIPNIR_DLLEXPORT VariableMatrix operator* ( double lhs,
const VariableMatrix & rhs )
friend

Scalar-matrix multiplication operator.

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

◆ operator+

SLEIPNIR_DLLEXPORT VariableMatrix operator+ ( const VariableMatrix & lhs,
const VariableMatrix & rhs )
friend

Binary addition operator.

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

◆ operator- [1/2]

SLEIPNIR_DLLEXPORT VariableMatrix operator- ( const VariableMatrix & lhs)
friend

Unary minus operator.

Parameters
lhsOperand for unary minus.

◆ operator- [2/2]

SLEIPNIR_DLLEXPORT VariableMatrix operator- ( const VariableMatrix & lhs,
const VariableMatrix & rhs )
friend

Binary subtraction operator.

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

◆ operator/

SLEIPNIR_DLLEXPORT VariableMatrix operator/ ( const VariableMatrix & lhs,
const Variable & rhs )
friend

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

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

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