sas
Modularised monitoring, logging, and control of robots.
Loading...
Searching...
No Matches
sas_core.cpp File Reference

Implementation of core functions. More...

#include <sas_core/sas_core.hpp>
#include <mutex>

Functions

VectorXd sas::concatenate (const VectorXd &a, const VectorXd &b)
 Concatenate two vectors by appending b after a.
VectorXd sas::concatenate (const std::vector< VectorXd > &as)
 Concatenate a list of vectors into a single vector.
MatrixXd sas::vstack (const MatrixXd &A, const MatrixXd &B)
 Stack two matrices vertically (A above B).
MatrixXd sas::block_diag (const std::vector< MatrixXd > &As)
 Create a block-diagonal matrix from a list of matrices.
std::vector< VectorXd > sas::split (const VectorXd &a, const std::vector< int > &ns)
 Split a vector into pieces with sizes specified by ns.

Detailed Description

Implementation of core functions.

Function Documentation

◆ block_diag()

MatrixXd sas::block_diag ( const std::vector< MatrixXd > & As)

Create a block-diagonal matrix from a list of matrices.

block_diag creates a block diagonal matrix using an input of std::vector<MatrixXd>. e.g. if As= [A, B, C], then block_diag(As) = |A 0 0| |0 B 0| |0 0 C|

Parameters
AsVector of matrices to place on the block diagonal.
Returns
Block-diagonal matrix containing the input matrices along its diagonal.
Parameters
Asthe std::vector<MatrixXd> contaning the matrix to form the block diagonal matrix.
Returns
the block diagonal matrix.

◆ concatenate() [1/2]

VectorXd sas::concatenate ( const std::vector< VectorXd > & as)

Concatenate a list of vectors into a single vector.

concatenate a std::vector of VectorXd.

Parameters
asVector of vectors to concatenate in order.
Returns
Concatenated vector containing the elements of each input vector in order.
Parameters
aan std::vector of VectorXd.
Returns
the result of the concatenated vectors.

◆ concatenate() [2/2]

VectorXd sas::concatenate ( const VectorXd & a,
const VectorXd & b )

Concatenate two vectors by appending b after a.

concatenate two VectorXd.

Parameters
aFirst vector.
bSecond vector.
Returns
Concatenated vector containing all elements of a followed by b.
Parameters
aa VectorXd.
ba VectorXd.
Returns
the result of the concatenated vectors.

◆ split()

std::vector< VectorXd > sas::split ( const VectorXd & a,
const std::vector< int > & ns )

Split a vector into pieces with sizes specified by ns.

split splits the input VectorXd as into a set of subvectors defined by ns.

Parameters
aVector to split.
nsSizes of each piece; their sum must equal a.size().
Returns
Vector containing the split VectorXd pieces.
Parameters
asthe VectorXd to be split.
nsthe sizes of the subvectors.
Returns
an std::vector<VectorXd> of the splitted vectors.

◆ vstack()

MatrixXd sas::vstack ( const MatrixXd & A,
const MatrixXd & B )

Stack two matrices vertically (A above B).

vstack vertically (row-wise) stack two MatrixXd.

Parameters
ATop matrix.
BBottom matrix.
Returns
Matrix formed by stacking A on top of B. Columns must match.
Exceptions
std::range_errorif A and B have different numbers of columns.
Parameters
Athe first MatrixXd.
Bthe second MatrixXd.
Returns
the vstacked MatrixXd.
Exceptions
astd::range_error if A and B don't have the same number of columns.
Note
returns an empty matrix if both arguments are empty or return the other argument of only one of the arguments is empty.