Sleipnir C++ API
Loading...
Searching...
No Matches
slp::VariableBlock< Mat > Class Template Reference

#include <sleipnir/autodiff/variable_block.hpp>

Public Member Functions

 VariableBlock (const VariableBlock< Mat > &)=default
 
VariableBlock< Mat > & operator= (const VariableBlock< Mat > &values)
 
 VariableBlock (VariableBlock< Mat > &&)=default
 
VariableBlock< Mat > & operator= (VariableBlock< Mat > &&values)
 
 VariableBlock (Mat &mat)
 
 VariableBlock (Mat &mat, int row_offset, int col_offset, int block_rows, int block_cols)
 
 VariableBlock (Mat &mat, Slice row_slice, int row_slice_length, Slice col_slice, int col_slice_length)
 
VariableBlock< Mat > & operator= (ScalarLike auto value)
 
void set_value (double value)
 
template<typename Derived >
VariableBlock< Mat > & operator= (const Eigen::MatrixBase< Derived > &values)
 
template<typename Derived >
requires std::same_as<typename Derived::Scalar, double>
void set_value (const Eigen::MatrixBase< Derived > &values)
 
VariableBlock< Mat > & operator= (const Mat &values)
 
VariableBlock< Mat > & operator= (Mat &&values)
 
Variableoperator() (int row, int col)
 
const Variableoperator() (int row, int col) const
 
Variableoperator[] (int row)
 
const Variableoperator[] (int row) const
 
VariableBlock< Mat > block (int row_offset, int col_offset, int block_rows, int block_cols)
 
const VariableBlock< const Mat > block (int row_offset, int col_offset, int block_rows, int block_cols) const
 
VariableBlock< Mat > operator() (Slice row_slice, Slice col_slice)
 
const VariableBlock< const Mat > operator() (Slice row_slice, Slice col_slice) const
 
VariableBlock< Mat > operator() (Slice row_slice, int row_slice_length, Slice col_slice, int col_slice_length)
 
const VariableBlock< const Mat > operator() (Slice row_slice, int row_slice_length, Slice col_slice, int col_slice_length) const
 
VariableBlock< Mat > segment (int offset, int length)
 
const VariableBlock< Mat > segment (int offset, int length) const
 
VariableBlock< Mat > row (int row)
 
VariableBlock< const Mat > row (int row) const
 
VariableBlock< Mat > col (int col)
 
VariableBlock< const Mat > col (int col) const
 
VariableBlock< Mat > & operator*= (const MatrixLike auto &rhs)
 
VariableBlock< Mat > & operator*= (const ScalarLike auto &rhs)
 
VariableBlock< Mat > & operator/= (const MatrixLike auto &rhs)
 
VariableBlock< Mat > & operator/= (const ScalarLike auto &rhs)
 
VariableBlock< Mat > & operator+= (const MatrixLike auto &rhs)
 
VariableBlock< Mat > & operator+= (const ScalarLike auto &rhs)
 
VariableBlock< Mat > & operator-= (const MatrixLike auto &rhs)
 
VariableBlock< Mat > & operator-= (const ScalarLike auto &rhs)
 
 operator Variable () const
 
std::remove_cv_t< Mat > T () const
 
int rows () const
 
int cols () const
 
double value (int row, int col)
 
double value (int index)
 
Eigen::MatrixXd value ()
 
std::remove_cv_t< Mat > cwise_transform (function_ref< Variable(const Variable &x)> unary_op) 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
 

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: