WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
sleipnir::VariableBlock< Mat > Class Template Reference

A submatrix of autodiff variables with reference semantics. More...

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

Classes

class  const_iterator
 
class  iterator
 

Public Member Functions

 VariableBlock (const VariableBlock< Mat > &values)=default
 
VariableBlock< Mat > & operator= (const VariableBlock< Mat > &values)
 Assigns a VariableBlock to the block.
 
 VariableBlock (VariableBlock< Mat > &&)=default
 
VariableBlock< Mat > & operator= (VariableBlock< Mat > &&values)
 Assigns a VariableBlock to the block.
 
 VariableBlock (Mat &mat)
 Constructs a Variable block pointing to all of the given matrix.
 
 VariableBlock (Mat &mat, int rowOffset, int colOffset, int blockRows, int blockCols)
 Constructs a Variable block pointing to a subset of the given matrix.
 
 VariableBlock (Mat &mat, Slice rowSlice, int rowSliceLength, Slice colSlice, int colSliceLength)
 Constructs a Variable block pointing to a subset of the given matrix.
 
VariableBlock< Mat > & operator= (double value)
 Assigns a double to the block.
 
void SetValue (double value)
 Assigns a double to the block.
 
template<typename Derived >
VariableBlock< Mat > & operator= (const Eigen::MatrixBase< Derived > &values)
 Assigns an Eigen matrix to the block.
 
template<typename Derived >
requires std::same_as<typename Derived::Scalar, double>
void SetValue (const Eigen::MatrixBase< Derived > &values)
 Sets block's internal values.
 
VariableBlock< Mat > & operator= (const Mat &values)
 Assigns a VariableMatrix to the block.
 
VariableBlock< Mat > & operator= (Mat &&values)
 Assigns a VariableMatrix to the block.
 
Variableoperator() (int row, int col)
 Returns a scalar subblock at the given row and column.
 
const Variableoperator() (int row, int col) const
 Returns a scalar subblock at the given row and column.
 
Variableoperator() (int row)
 Returns a scalar subblock at the given row.
 
const Variableoperator() (int row) const
 Returns a scalar subblock at the given row.
 
VariableBlock< Mat > Block (int rowOffset, int colOffset, int blockRows, int blockCols)
 Returns a block of the variable matrix.
 
const VariableBlock< const Mat > Block (int rowOffset, int colOffset, int blockRows, int blockCols) const
 Returns a block slice of the variable matrix.
 
VariableBlock< Mat > operator() (Slice rowSlice, Slice colSlice)
 Returns a slice of the variable matrix.
 
const VariableBlock< const Mat > operator() (Slice rowSlice, Slice colSlice) const
 Returns a slice of the variable matrix.
 
VariableBlock< Mat > operator() (Slice rowSlice, int rowSliceLength, Slice colSlice, int colSliceLength)
 Returns a slice of the variable matrix.
 
const VariableBlock< const Mat > operator() (Slice rowSlice, int rowSliceLength, Slice colSlice, int colSliceLength) const
 Returns a slice of the variable matrix.
 
VariableBlock< Mat > Segment (int offset, int length)
 Returns a segment of the variable vector.
 
const VariableBlock< Mat > Segment (int offset, int length) const
 Returns a segment of the variable vector.
 
VariableBlock< Mat > Row (int row)
 Returns a row slice of the variable matrix.
 
VariableBlock< const Mat > Row (int row) const
 Returns a row slice of the variable matrix.
 
VariableBlock< Mat > Col (int col)
 Returns a column slice of the variable matrix.
 
VariableBlock< const Mat > Col (int col) const
 Returns a column slice of the variable matrix.
 
VariableBlock< Mat > & operator*= (const VariableBlock< Mat > &rhs)
 Compound matrix multiplication-assignment operator.
 
VariableBlockoperator*= (double rhs)
 Compound matrix multiplication-assignment operator (only enabled when lhs is a scalar).
 
VariableBlock< Mat > & operator/= (const VariableBlock< Mat > &rhs)
 Compound matrix division-assignment operator (only enabled when rhs is a scalar).
 
VariableBlock< Mat > & operator/= (double rhs)
 Compound matrix division-assignment operator (only enabled when rhs is a scalar).
 
VariableBlock< Mat > & operator+= (const VariableBlock< Mat > &rhs)
 Compound addition-assignment operator.
 
VariableBlock< Mat > & operator-= (const VariableBlock< Mat > &rhs)
 Compound subtraction-assignment operator.
 
std::remove_cv_t< Mat > 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.
 
std::remove_cv_t< Mat > 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.
 

Detailed Description

template<typename Mat>
class sleipnir::VariableBlock< Mat >

A submatrix of autodiff variables with reference semantics.

Template Parameters
MatThe type of the matrix whose storage this class points to.

Constructor & Destructor Documentation

◆ VariableBlock() [1/5]

template<typename Mat >
sleipnir::VariableBlock< Mat >::VariableBlock ( const VariableBlock< Mat > & values)
default

◆ VariableBlock() [2/5]

template<typename Mat >
sleipnir::VariableBlock< Mat >::VariableBlock ( VariableBlock< Mat > && )
default

◆ VariableBlock() [3/5]

template<typename Mat >
sleipnir::VariableBlock< Mat >::VariableBlock ( Mat & mat)
inline

Constructs a Variable block pointing to all of the given matrix.

Parameters
matThe matrix to which to point.

◆ VariableBlock() [4/5]

template<typename Mat >
sleipnir::VariableBlock< Mat >::VariableBlock ( Mat & mat,
int rowOffset,
int colOffset,
int blockRows,
int blockCols )
inline

Constructs a Variable block pointing to a subset of the given matrix.

Parameters
matThe matrix to which to point.
rowOffsetThe block's row offset.
colOffsetThe block's column offset.
blockRowsThe number of rows in the block.
blockColsThe number of columns in the block.

◆ VariableBlock() [5/5]

template<typename Mat >
sleipnir::VariableBlock< Mat >::VariableBlock ( Mat & mat,
Slice rowSlice,
int rowSliceLength,
Slice colSlice,
int colSliceLength )
inline

Constructs a Variable block pointing to a subset of the given matrix.

Note that the slices are taken as is rather than adjusted.

Parameters
matThe matrix to which to point.
rowSliceThe block's row slice.
rowSliceLengthThe block's row length.
colSliceThe block's column slice.
colSliceLengthThe block's column length.

Member Function Documentation

◆ begin() [1/2]

template<typename Mat >
iterator sleipnir::VariableBlock< Mat >::begin ( )
inline

Returns begin iterator.

◆ begin() [2/2]

template<typename Mat >
const_iterator sleipnir::VariableBlock< Mat >::begin ( ) const
inline

Returns begin iterator.

◆ Block() [1/2]

template<typename Mat >
VariableBlock< Mat > sleipnir::VariableBlock< Mat >::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]

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

Returns a block slice 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()

template<typename Mat >
const_iterator sleipnir::VariableBlock< Mat >::cbegin ( ) const
inline

Returns begin iterator.

◆ cend()

template<typename Mat >
const_iterator sleipnir::VariableBlock< Mat >::cend ( ) const
inline

Returns end iterator.

◆ Col() [1/2]

template<typename Mat >
VariableBlock< Mat > sleipnir::VariableBlock< Mat >::Col ( int col)
inline

Returns a column slice of the variable matrix.

Parameters
colThe column to slice.

◆ Col() [2/2]

template<typename Mat >
VariableBlock< const Mat > sleipnir::VariableBlock< Mat >::Col ( int col) const
inline

Returns a column slice of the variable matrix.

Parameters
colThe column to slice.

◆ Cols()

template<typename Mat >
int sleipnir::VariableBlock< Mat >::Cols ( ) const
inline

Returns number of columns in the matrix.

◆ CwiseTransform()

template<typename Mat >
std::remove_cv_t< Mat > sleipnir::VariableBlock< Mat >::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]

template<typename Mat >
iterator sleipnir::VariableBlock< Mat >::end ( )
inline

Returns end iterator.

◆ end() [2/2]

template<typename Mat >
const_iterator sleipnir::VariableBlock< Mat >::end ( ) const
inline

Returns end iterator.

◆ operator()() [1/8]

template<typename Mat >
Variable & sleipnir::VariableBlock< Mat >::operator() ( int row)
inline

Returns a scalar subblock at the given row.

Parameters
rowThe scalar subblock's row.

◆ operator()() [2/8]

template<typename Mat >
const Variable & sleipnir::VariableBlock< Mat >::operator() ( int row) const
inline

Returns a scalar subblock at the given row.

Parameters
rowThe scalar subblock's row.

◆ operator()() [3/8]

template<typename Mat >
Variable & sleipnir::VariableBlock< Mat >::operator() ( int row,
int col )
inline

Returns a scalar subblock at the given row and column.

Parameters
rowThe scalar subblock's row.
colThe scalar subblock's column.

◆ operator()() [4/8]

template<typename Mat >
const Variable & sleipnir::VariableBlock< Mat >::operator() ( int row,
int col ) const
inline

Returns a scalar subblock at the given row and column.

Parameters
rowThe scalar subblock's row.
colThe scalar subblock's column.

◆ operator()() [5/8]

template<typename Mat >
VariableBlock< Mat > sleipnir::VariableBlock< Mat >::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]

template<typename Mat >
const VariableBlock< const Mat > sleipnir::VariableBlock< Mat >::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]

template<typename Mat >
VariableBlock< Mat > sleipnir::VariableBlock< Mat >::operator() ( Slice rowSlice,
Slice colSlice )
inline

Returns a slice of the variable matrix.

Parameters
rowSliceThe row slice.
colSliceThe column slice.

◆ operator()() [8/8]

template<typename Mat >
const VariableBlock< const Mat > sleipnir::VariableBlock< Mat >::operator() ( Slice rowSlice,
Slice colSlice ) const
inline

Returns a slice of the variable matrix.

Parameters
rowSliceThe row slice.
colSliceThe column slice.

◆ operator*=() [1/2]

template<typename Mat >
VariableBlock< Mat > & sleipnir::VariableBlock< Mat >::operator*= ( const VariableBlock< Mat > & rhs)
inline

Compound matrix multiplication-assignment operator.

Parameters
rhsVariable to multiply.

◆ operator*=() [2/2]

template<typename Mat >
VariableBlock & sleipnir::VariableBlock< Mat >::operator*= ( double rhs)
inline

Compound matrix multiplication-assignment operator (only enabled when lhs is a scalar).

Parameters
rhsVariable to multiply.

◆ operator+=()

template<typename Mat >
VariableBlock< Mat > & sleipnir::VariableBlock< Mat >::operator+= ( const VariableBlock< Mat > & rhs)
inline

Compound addition-assignment operator.

Parameters
rhsVariable to add.

◆ operator-=()

template<typename Mat >
VariableBlock< Mat > & sleipnir::VariableBlock< Mat >::operator-= ( const VariableBlock< Mat > & rhs)
inline

Compound subtraction-assignment operator.

Parameters
rhsVariable to subtract.

◆ operator/=() [1/2]

template<typename Mat >
VariableBlock< Mat > & sleipnir::VariableBlock< Mat >::operator/= ( const VariableBlock< Mat > & rhs)
inline

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

Parameters
rhsVariable to divide.

◆ operator/=() [2/2]

template<typename Mat >
VariableBlock< Mat > & sleipnir::VariableBlock< Mat >::operator/= ( double rhs)
inline

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

Parameters
rhsVariable to divide.

◆ operator=() [1/6]

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

Assigns an Eigen matrix to the block.

Parameters
valuesEigen matrix of values to assign.

◆ operator=() [2/6]

template<typename Mat >
VariableBlock< Mat > & sleipnir::VariableBlock< Mat >::operator= ( const Mat & values)
inline

Assigns a VariableMatrix to the block.

Parameters
valuesVariableMatrix of values.

◆ operator=() [3/6]

template<typename Mat >
VariableBlock< Mat > & sleipnir::VariableBlock< Mat >::operator= ( const VariableBlock< Mat > & values)
inline

Assigns a VariableBlock to the block.

Parameters
valuesVariableBlock of values.

◆ operator=() [4/6]

template<typename Mat >
VariableBlock< Mat > & sleipnir::VariableBlock< Mat >::operator= ( double value)
inline

Assigns a double to the block.

This only works for blocks with one row and one column.

◆ operator=() [5/6]

template<typename Mat >
VariableBlock< Mat > & sleipnir::VariableBlock< Mat >::operator= ( Mat && values)
inline

Assigns a VariableMatrix to the block.

Parameters
valuesVariableMatrix of values.

◆ operator=() [6/6]

template<typename Mat >
VariableBlock< Mat > & sleipnir::VariableBlock< Mat >::operator= ( VariableBlock< Mat > && values)
inline

Assigns a VariableBlock to the block.

Parameters
valuesVariableBlock of values.

◆ Row() [1/2]

template<typename Mat >
VariableBlock< Mat > sleipnir::VariableBlock< Mat >::Row ( int row)
inline

Returns a row slice of the variable matrix.

Parameters
rowThe row to slice.

◆ Row() [2/2]

template<typename Mat >
VariableBlock< const Mat > sleipnir::VariableBlock< Mat >::Row ( int row) const
inline

Returns a row slice of the variable matrix.

Parameters
rowThe row to slice.

◆ Rows()

template<typename Mat >
int sleipnir::VariableBlock< Mat >::Rows ( ) const
inline

Returns number of rows in the matrix.

◆ Segment() [1/2]

template<typename Mat >
VariableBlock< Mat > sleipnir::VariableBlock< Mat >::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]

template<typename Mat >
const VariableBlock< Mat > sleipnir::VariableBlock< Mat >::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() [1/2]

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

Sets block's internal values.

Parameters
valuesEigen matrix of values.

◆ SetValue() [2/2]

template<typename Mat >
void sleipnir::VariableBlock< Mat >::SetValue ( double value)
inline

Assigns a double to the block.

This only works for blocks with one row and one column.

Parameters
valueValue to assign.

◆ size()

template<typename Mat >
size_t sleipnir::VariableBlock< Mat >::size ( ) const
inline

Returns number of elements in matrix.

◆ T()

template<typename Mat >
std::remove_cv_t< Mat > sleipnir::VariableBlock< Mat >::T ( ) const
inline

Returns the transpose of the variable matrix.

◆ Value() [1/3]

template<typename Mat >
Eigen::MatrixXd sleipnir::VariableBlock< Mat >::Value ( )
inline

Returns the contents of the variable matrix.

◆ Value() [2/3]

template<typename Mat >
double sleipnir::VariableBlock< Mat >::Value ( int index)
inline

Returns a row of the variable column vector.

Parameters
indexThe index of the element to return.

◆ Value() [3/3]

template<typename Mat >
double sleipnir::VariableBlock< Mat >::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.

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