MLpp
ml::LinearAlgebra Namespace Reference

Linear algebra helper functions. More...

Functions

double xAx_symmetric (const Eigen::MatrixXd &A, Eigen::Ref< const Eigen::VectorXd > x)
 Calculates x^T A x for a symmetric matrix A. More...
 
void xxT (const Eigen::VectorXd &x, Eigen::MatrixXd &dest)
 Calculates x * x^T and places it in dest. More...
 
void add_a_xxT (const Eigen::VectorXd &x, Eigen::MatrixXd &dest, double a)
 Adds a * x * x^T to A. More...
 

Detailed Description

Linear algebra helper functions.

Function Documentation

◆ xAx_symmetric()

double ml::LinearAlgebra::xAx_symmetric ( const Eigen::MatrixXd &  A,
Eigen::Ref< const Eigen::VectorXd >  x 
)

Calculates x^T A x for a symmetric matrix A.

Parameters
ASymmetric square matrix.
xVector.
Returns
Value of \( \vec{x}^T A \vec{x} \).
Exceptions
std::invalid_argumentIf A is not square or x.size() != A.rows().

◆ xxT()

void ml::LinearAlgebra::xxT ( const Eigen::VectorXd &  x,
Eigen::MatrixXd &  dest 
)

Calculates x * x^T and places it in dest.

Parameters
[in]xVector of length N.
[out]destOutput matrix, resized if necessary. Assumed to be non-aliasing with x.

◆ add_a_xxT()

void ml::LinearAlgebra::add_a_xxT ( const Eigen::VectorXd &  x,
Eigen::MatrixXd &  dest,
double  a 
)

Adds a * x * x^T to A.

Parameters
[in]xVector of length N.
[out]AExisting N x N matrix.
Exceptions
std::invalid_argumentIf A is not square or x.size() != A.rows().