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

Implementation of core functions. More...

#include <marinholab/sas/core/sas_core.hpp>
#include <mutex>

Functions

Eigen::VectorXd marinholab::sas::core::concatenate (const Eigen::VectorXd &a, const Eigen::VectorXd &b)
 Concatenate two vectors by appending b after a.
Eigen::VectorXd marinholab::sas::core::concatenate (const std::vector< Eigen::VectorXd > &as)
 Concatenate a list of vectors into a single vector.
Eigen::MatrixXd marinholab::sas::core::vstack (const Eigen::MatrixXd &A, const Eigen::MatrixXd &B)
 Stack two matrices vertically (A above B).
Eigen::MatrixXd marinholab::sas::core::block_diag (const std::vector< Eigen::MatrixXd > &As)
 Create a block-diagonal matrix from a list of matrices.
std::vector< Eigen::VectorXd > marinholab::sas::core::split (const Eigen::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()

Eigen::MatrixXd marinholab::sas::core::block_diag ( const std::vector< Eigen::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<Eigen::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<Eigen::MatrixXd> contaning the matrix to form the block diagonal matrix.
Returns
the block diagonal matrix.

◆ concatenate() [1/2]

Eigen::VectorXd marinholab::sas::core::concatenate ( const Eigen::VectorXd & a,
const Eigen::VectorXd & b )

Concatenate two vectors by appending b after a.

concatenate two Eigen::VectorXd.

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

◆ concatenate() [2/2]

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

Concatenate a list of vectors into a single vector.

concatenate a std::vector of Eigen::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 Eigen::VectorXd.
Returns
the result of the concatenated vectors.

◆ split()

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

Split a vector into pieces with sizes specified by ns.

split splits the input Eigen::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 Eigen::VectorXd pieces.
Parameters
asthe Eigen::VectorXd to be split.
nsthe sizes of the subvectors.
Returns
an std::vector<Eigen::VectorXd> of the splitted vectors.

◆ vstack()

Eigen::MatrixXd marinholab::sas::core::vstack ( const Eigen::MatrixXd & A,
const Eigen::MatrixXd & B )

Stack two matrices vertically (A above B).

vstack vertically (row-wise) stack two Eigen::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 Eigen::MatrixXd.
Bthe second Eigen::MatrixXd.
Returns
the vstacked Eigen::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.