Core numerical utilities and helpers used across the project.
More...
#include <eigen3/Eigen/Dense>
Go to the source code of this file.
|
| enum class | Statistics { Mean
} |
| |
|
| template<class T > |
| constexpr T | sas::incremental_mean (const T ¤t_mean, const int ¤t_number_of_samples, const T &new_sample) |
| | incremental_mean a simple implementation of incremental mean, for the many cases in which keeping a vector of all values would be impractical.
|
| |
| 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.
|
| |
Core numerical utilities and helpers used across the project.
This header contains lightweight, frequently used numeric helpers such as incremental mean computation, vector/matrix concatenation, block-diagonal assembly and vector splitting utilities. These utilities are intended to be header-only and efficient for use in real-time control loops.
◆ 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
-
| As | Vector of matrices to place on the block diagonal. |
- Returns
- Block-diagonal matrix containing the input matrices along its diagonal.
- Parameters
-
| As | the 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
-
| as | Vector of vectors to concatenate in order. |
- Returns
- Concatenated vector containing the elements of each input vector in order.
- Parameters
-
| a | an 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
-
| a | First vector. |
| b | Second vector. |
- Returns
- Concatenated vector containing all elements of a followed by b.
- Parameters
-
| a | a VectorXd. |
| b | a VectorXd. |
- Returns
- the result of the concatenated vectors.
◆ incremental_mean()
template<class T >
| constexpr T sas::incremental_mean |
( |
const T & |
current_mean, |
|
|
const int & |
current_number_of_samples, |
|
|
const T & |
new_sample |
|
) |
| |
|
constexpr |
incremental_mean a simple implementation of incremental mean, for the many cases in which keeping a vector of all values would be impractical.
- Parameters
-
| current_mean | the current value of the mean. |
| current_number_of_samples | the current number of samples, not considering the new_sample. |
| new_sample | the new sample that will change the mean. |
- Returns
- the incremental mean, considering the new_sample.
◆ 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
-
| a | Vector to split. |
| ns | Sizes of each piece; their sum must equal a.size(). |
- Returns
- Vector containing the split VectorXd pieces.
- Parameters
-
| as | the VectorXd to be split. |
| ns | the 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
-
| A | Top matrix. |
| B | Bottom matrix. |
- Returns
- Matrix formed by stacking A on top of B. Columns must match.
- Parameters
-
| A | the first MatrixXd. |
| B | the second MatrixXd. |
- Returns
- the vstacked MatrixXd.
- Exceptions
-
| a | std::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.