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

#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)
 
 VariableBlock (VariableBlock< Mat > &&)=default
 
VariableBlock< Mat > & operator= (VariableBlock< Mat > &&values)
 
 VariableBlock (Mat &mat)
 
 VariableBlock (Mat &mat, int rowOffset, int colOffset, int blockRows, int blockCols)
 
 VariableBlock (Mat &mat, Slice rowSlice, int rowSliceLength, Slice colSlice, int colSliceLength)
 
VariableBlock< Mat > & operator= (double value)
 
void SetValue (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 SetValue (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< MatBlock (int rowOffset, int colOffset, int blockRows, int blockCols)
 
const VariableBlock< const MatBlock (int rowOffset, int colOffset, int blockRows, int blockCols) const
 
VariableBlock< Matoperator() (Slice rowSlice, Slice colSlice)
 
const VariableBlock< const Matoperator() (Slice rowSlice, Slice colSlice) const
 
VariableBlock< Matoperator() (Slice rowSlice, int rowSliceLength, Slice colSlice, int colSliceLength)
 
const VariableBlock< const Matoperator() (Slice rowSlice, int rowSliceLength, Slice colSlice, int colSliceLength) const
 
VariableBlock< MatSegment (int offset, int length)
 
const VariableBlock< MatSegment (int offset, int length) const
 
VariableBlock< MatRow (int row)
 
VariableBlock< const MatRow (int row) const
 
VariableBlock< MatCol (int col)
 
VariableBlock< const MatCol (int col) const
 
VariableBlock< Mat > & operator*= (const VariableBlock< Mat > &rhs)
 
VariableBlockoperator*= (double rhs)
 
VariableBlock< Mat > & operator/= (const VariableBlock< Mat > &rhs)
 
VariableBlock< Mat > & operator/= (double rhs)
 
VariableBlock< Mat > & operator+= (const VariableBlock< Mat > &rhs)
 
VariableBlock< Mat > & operator-= (const VariableBlock< Mat > &rhs)
 
std::remove_cv_t< MatT () const
 
int Rows () const
 
int Cols () const
 
double Value (int row, int col)
 
double Value (int index)
 
Eigen::MatrixXd Value ()
 
std::remove_cv_t< MatCwiseTransform (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
 

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]

Compound matrix multiplication-assignment operator.

Parameters
rhsVariable to multiply.

◆ operator*=() [2/2]

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

Parameters
rhsVariable to multiply.

◆ operator+=()

Compound addition-assignment operator.

Parameters
rhsVariable to add.

◆ operator-=()

Compound subtraction-assignment operator.

Parameters
rhsVariable to subtract.

◆ operator/=() [1/2]

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

Parameters
rhsVariable to divide.

◆ operator/=() [2/2]

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]

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: