WPILibC++ 2027.0.0-alpha-2
Loading...
Searching...
No Matches
slp::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/variable_block.hpp>

Classes

class  const_iterator
 
class  iterator
 

Public Member Functions

 VariableBlock (const VariableBlock< Mat > &)=default
 Copy constructor.
 
VariableBlock< Mat > & operator= (const VariableBlock< Mat > &values)
 Assigns a VariableBlock to the block.
 
 VariableBlock (VariableBlock< Mat > &&)=default
 Move constructor.
 
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 row_offset, int col_offset, int block_rows, int block_cols)
 Constructs a Variable block pointing to a subset of the given matrix.
 
 VariableBlock (Mat &mat, Slice row_slice, int row_slice_length, Slice col_slice, int col_slice_length)
 Constructs a Variable block pointing to a subset of the given matrix.
 
VariableBlock< Mat > & operator= (ScalarLike auto value)
 Assigns a double to the block.
 
void set_value (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 set_value (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 row_offset, int col_offset, int block_rows, int block_cols)
 Returns a block of the variable matrix.
 
const VariableBlock< const Mat > block (int row_offset, int col_offset, int block_rows, int block_cols) const
 Returns a block slice of the variable matrix.
 
VariableBlock< Mat > operator() (Slice row_slice, Slice col_slice)
 Returns a slice of the variable matrix.
 
const VariableBlock< const Mat > operator() (Slice row_slice, Slice col_slice) const
 Returns a slice of the variable matrix.
 
VariableBlock< Mat > operator() (Slice row_slice, int row_slice_length, Slice col_slice, int col_slice_length)
 Returns a slice of the variable matrix.
 
const VariableBlock< const Mat > operator() (Slice row_slice, int row_slice_length, Slice col_slice, int col_slice_length) 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 MatrixLike auto &rhs)
 Compound matrix multiplication-assignment operator.
 
VariableBlock< Mat > & operator*= (const ScalarLike auto &rhs)
 Compound matrix multiplication-assignment operator.
 
VariableBlock< Mat > & operator/= (const MatrixLike auto &rhs)
 Compound matrix division-assignment operator.
 
VariableBlock< Mat > & operator/= (const ScalarLike auto &rhs)
 Compound matrix division-assignment operator.
 
VariableBlock< Mat > & operator+= (const MatrixLike auto &rhs)
 Compound addition-assignment operator.
 
VariableBlock< Mat > & operator+= (const ScalarLike auto &rhs)
 Compound addition-assignment operator.
 
VariableBlock< Mat > & operator-= (const MatrixLike auto &rhs)
 Compound subtraction-assignment operator.
 
VariableBlock< Mat > & operator-= (const ScalarLike auto &rhs)
 Compound subtraction-assignment operator.
 
 operator Variable () const
 Implicit conversion operator from 1x1 VariableBlock to Variable.
 
std::remove_cv_t< Mat > T () const
 Returns the transpose of the variable matrix.
 
int rows () const
 Returns the number of rows in the matrix.
 
int cols () const
 Returns the 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 > cwise_transform (function_ref< Variable(const Variable &x)> unary_op) 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 slp::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 >
slp::VariableBlock< Mat >::VariableBlock ( const VariableBlock< Mat > & )
default

Copy constructor.

◆ VariableBlock() [2/5]

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

Move constructor.

◆ VariableBlock() [3/5]

template<typename Mat >
slp::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 >
slp::VariableBlock< Mat >::VariableBlock ( Mat & mat,
int row_offset,
int col_offset,
int block_rows,
int block_cols )
inline

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

Parameters
matThe matrix to which to point.
row_offsetThe block's row offset.
col_offsetThe block's column offset.
block_rowsThe number of rows in the block.
block_colsThe number of columns in the block.

◆ VariableBlock() [5/5]

template<typename Mat >
slp::VariableBlock< Mat >::VariableBlock ( Mat & mat,
Slice row_slice,
int row_slice_length,
Slice col_slice,
int col_slice_length )
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.
row_sliceThe block's row slice.
row_slice_lengthThe block's row length.
col_sliceThe block's column slice.
col_slice_lengthThe block's column length.

Member Function Documentation

◆ begin() [1/2]

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

Returns begin iterator.

Returns
Begin iterator.

◆ begin() [2/2]

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

Returns begin iterator.

Returns
Begin iterator.

◆ block() [1/2]

template<typename Mat >
VariableBlock< Mat > slp::VariableBlock< Mat >::block ( int row_offset,
int col_offset,
int block_rows,
int block_cols )
inline

Returns a block of the variable matrix.

Parameters
row_offsetThe row offset of the block selection.
col_offsetThe column offset of the block selection.
block_rowsThe number of rows in the block selection.
block_colsThe number of columns in the block selection.
Returns
A block of the variable matrix.

◆ block() [2/2]

template<typename Mat >
const VariableBlock< const Mat > slp::VariableBlock< Mat >::block ( int row_offset,
int col_offset,
int block_rows,
int block_cols ) const
inline

Returns a block slice of the variable matrix.

Parameters
row_offsetThe row offset of the block selection.
col_offsetThe column offset of the block selection.
block_rowsThe number of rows in the block selection.
block_colsThe number of columns in the block selection.
Returns
A block slice of the variable matrix.

◆ cbegin()

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

Returns begin iterator.

Returns
Begin iterator.

◆ cend()

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

Returns end iterator.

Returns
End iterator.

◆ col() [1/2]

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

Returns a column slice of the variable matrix.

Parameters
colThe column to slice.
Returns
A column slice of the variable matrix.

◆ col() [2/2]

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

Returns a column slice of the variable matrix.

Parameters
colThe column to slice.
Returns
A column slice of the variable matrix.

◆ cols()

template<typename Mat >
int slp::VariableBlock< Mat >::cols ( ) const
inline

Returns the number of columns in the matrix.

Returns
The number of columns in the matrix.

◆ cwise_transform()

template<typename Mat >
std::remove_cv_t< Mat > slp::VariableBlock< Mat >::cwise_transform ( function_ref< Variable(const Variable &x)> unary_op) const
inline

Transforms the matrix coefficient-wise with an unary operator.

Parameters
unary_opThe unary operator to use for the transform operation.
Returns
Result of the unary operator.

◆ end() [1/2]

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

Returns end iterator.

Returns
End iterator.

◆ end() [2/2]

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

Returns end iterator.

Returns
End iterator.

◆ operator Variable()

template<typename Mat >
slp::VariableBlock< Mat >::operator Variable ( ) const
inline

Implicit conversion operator from 1x1 VariableBlock to Variable.

◆ operator()() [1/6]

template<typename Mat >
Variable & slp::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.
Returns
A scalar subblock at the given row and column.

◆ operator()() [2/6]

template<typename Mat >
const Variable & slp::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.
Returns
A scalar subblock at the given row and column.

◆ operator()() [3/6]

template<typename Mat >
VariableBlock< Mat > slp::VariableBlock< Mat >::operator() ( Slice row_slice,
int row_slice_length,
Slice col_slice,
int col_slice_length )
inline

Returns a slice of the variable matrix.

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

Parameters
row_sliceThe row slice.
row_slice_lengthThe row slice length.
col_sliceThe column slice.
col_slice_lengthThe column slice length.
Returns
A slice of the variable matrix.

◆ operator()() [4/6]

template<typename Mat >
const VariableBlock< const Mat > slp::VariableBlock< Mat >::operator() ( Slice row_slice,
int row_slice_length,
Slice col_slice,
int col_slice_length ) const
inline

Returns a slice of the variable matrix.

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

Parameters
row_sliceThe row slice.
row_slice_lengthThe row slice length.
col_sliceThe column slice.
col_slice_lengthThe column slice length.
Returns
A slice of the variable matrix.

◆ operator()() [5/6]

template<typename Mat >
VariableBlock< Mat > slp::VariableBlock< Mat >::operator() ( Slice row_slice,
Slice col_slice )
inline

Returns a slice of the variable matrix.

Parameters
row_sliceThe row slice.
col_sliceThe column slice.
Returns
A slice of the variable matrix.

◆ operator()() [6/6]

template<typename Mat >
const VariableBlock< const Mat > slp::VariableBlock< Mat >::operator() ( Slice row_slice,
Slice col_slice ) const
inline

Returns a slice of the variable matrix.

Parameters
row_sliceThe row slice.
col_sliceThe column slice.
Returns
A slice of the variable matrix.

◆ operator*=() [1/2]

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

Compound matrix multiplication-assignment operator.

Parameters
rhsVariable to multiply.
Returns
Result of multiplication.

◆ operator*=() [2/2]

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

Compound matrix multiplication-assignment operator.

Parameters
rhsVariable to multiply.
Returns
Result of multiplication.

◆ operator+=() [1/2]

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

Compound addition-assignment operator.

Parameters
rhsVariable to add.
Returns
Result of addition.

◆ operator+=() [2/2]

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

Compound addition-assignment operator.

Parameters
rhsVariable to add.
Returns
Result of addition.

◆ operator-=() [1/2]

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

Compound subtraction-assignment operator.

Parameters
rhsVariable to subtract.
Returns
Result of subtraction.

◆ operator-=() [2/2]

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

Compound subtraction-assignment operator.

Parameters
rhsVariable to subtract.
Returns
Result of subtraction.

◆ operator/=() [1/2]

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

Compound matrix division-assignment operator.

Parameters
rhsVariable to divide.
Returns
Result of division.

◆ operator/=() [2/2]

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

Compound matrix division-assignment operator.

Parameters
rhsVariable to divide.
Returns
Result of division.

◆ operator=() [1/6]

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

Assigns an Eigen matrix to the block.

Parameters
valuesEigen matrix of values to assign.
Returns
This VariableBlock.

◆ operator=() [2/6]

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

Assigns a VariableMatrix to the block.

Parameters
valuesVariableMatrix of values.
Returns
This VariableBlock.

◆ operator=() [3/6]

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

Assigns a VariableBlock to the block.

Parameters
valuesVariableBlock of values.
Returns
This VariableBlock.

◆ operator=() [4/6]

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

Assigns a VariableMatrix to the block.

Parameters
valuesVariableMatrix of values.
Returns
This VariableBlock.

◆ operator=() [5/6]

template<typename Mat >
VariableBlock< Mat > & slp::VariableBlock< Mat >::operator= ( ScalarLike auto value)
inline

Assigns a double to the block.

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

Parameters
valueValue to assign.
Returns
This VariableBlock.

◆ operator=() [6/6]

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

Assigns a VariableBlock to the block.

Parameters
valuesVariableBlock of values.
Returns
This VariableBlock.

◆ operator[]() [1/2]

template<typename Mat >
Variable & slp::VariableBlock< Mat >::operator[] ( int row)
inline

Returns a scalar subblock at the given row.

Parameters
rowThe scalar subblock's row.
Returns
A scalar subblock at the given row.

◆ operator[]() [2/2]

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

Returns a scalar subblock at the given row.

Parameters
rowThe scalar subblock's row.
Returns
A scalar subblock at the given row.

◆ row() [1/2]

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

Returns a row slice of the variable matrix.

Parameters
rowThe row to slice.
Returns
A row slice of the variable matrix.

◆ row() [2/2]

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

Returns a row slice of the variable matrix.

Parameters
rowThe row to slice.
Returns
A row slice of the variable matrix.

◆ rows()

template<typename Mat >
int slp::VariableBlock< Mat >::rows ( ) const
inline

Returns the number of rows in the matrix.

Returns
The number of rows in the matrix.

◆ segment() [1/2]

template<typename Mat >
VariableBlock< Mat > slp::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.
Returns
A segment of the variable vector.

◆ segment() [2/2]

template<typename Mat >
const VariableBlock< Mat > slp::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.
Returns
A segment of the variable vector.

◆ set_value() [1/2]

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

Sets block's internal values.

Parameters
valuesEigen matrix of values.

◆ set_value() [2/2]

template<typename Mat >
void slp::VariableBlock< Mat >::set_value ( 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 slp::VariableBlock< Mat >::size ( ) const
inline

Returns number of elements in matrix.

Returns
Number of elements in matrix.

◆ T()

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

Returns the transpose of the variable matrix.

Returns
The transpose of the variable matrix.

◆ value() [1/3]

template<typename Mat >
Eigen::MatrixXd slp::VariableBlock< Mat >::value ( )
inline

Returns the contents of the variable matrix.

Returns
The contents of the variable matrix.

◆ value() [2/3]

template<typename Mat >
double slp::VariableBlock< Mat >::value ( int index)
inline

Returns a row of the variable column vector.

Parameters
indexThe index of the element to return.
Returns
A row of the variable column vector.

◆ value() [3/3]

template<typename Mat >
double slp::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.
Returns
An element of the variable matrix.

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