mlpack
Classes | Typedefs | Functions | Variables
mlpack::math Namespace Reference

Miscellaneous math routines. More...

Classes

class  ColumnsToBlocks
 Transform the columns of the given matrix into a block format. More...
 
class  RangeType
 Simple real-valued range. More...
 

Typedefs

typedef RangeType< double > Range
 3.0.0 TODO: break reverse-compatibility by changing RangeType to Range.
 

Functions

template<typename eT >
arma::Mat< eT > ColumnCovariance (const arma::Mat< eT > &A, const size_t norm_type=0)
 
template<typename T >
arma::Mat< std::complex< T > > ColumnCovariance (const arma::Mat< std::complex< T > > &A, const size_t norm_type=0)
 
template<typename T >
arma::Mat< std::complex< T > > ColumnCovariance (const arma::Mat< std::complex< T >> &x, const size_t normType)
 
double ClampNonNegative (const double d)
 Forces a number to be non-negative, turning negative numbers into zero. More...
 
double ClampNonPositive (const double d)
 Forces a number to be non-positive, turning positive numbers into zero. More...
 
double ClampRange (double value, const double rangeMin, const double rangeMax)
 Clamp a number between a particular range. More...
 
void VectorPower (arma::vec &vec, const double power)
 Auxiliary function to raise vector elements to a specific power. More...
 
void Center (const arma::mat &x, arma::mat &xCentered)
 Creates a centered matrix, where centering is done by subtracting the sum over the columns (a column vector) from each column of the matrix. More...
 
void WhitenUsingSVD (const arma::mat &x, arma::mat &xWhitened, arma::mat &whiteningMatrix)
 Whitens a matrix using the singular value decomposition of the covariance matrix. More...
 
void RandVector (arma::vec &v)
 Overwrites a dimension-N vector to a random vector on the unit sphere in R^N.
 
void Orthogonalize (const arma::mat &x, arma::mat &W)
 Orthogonalize x and return the result in W, using eigendecomposition. More...
 
void Orthogonalize (arma::mat &x)
 Orthogonalize x in-place. More...
 
void RemoveRows (const arma::mat &input, const std::vector< size_t > &rowsToRemove, arma::mat &output)
 Remove a certain set of rows in a matrix while copying to a second matrix. More...
 
void Svec (const arma::mat &input, arma::vec &output)
 Upper triangular representation of a symmetric matrix, scaled such that, dot(Svec(A), Svec(B)) == dot(A, B) for symmetric A, B. More...
 
void Svec (const arma::sp_mat &input, arma::sp_vec &output)
 
void Smat (const arma::vec &input, arma::mat &output)
 The inverse of Svec. More...
 
size_t SvecIndex (size_t i, size_t j, size_t n)
 Return the index such that A[i,j] == factr(i, j) * svec(A)[pos(i, j)], where factr(i, j) = sqrt(2) if i != j and 1 otherwise. More...
 
void SymKronId (const arma::mat &A, arma::mat &op)
 If A is a symmetric matrix, then SymKronId returns an operator Op such that. More...
 
template<typename T >
Sign (const T x)
 Signum function. More...
 
template<typename T >
LogAdd (T x, T y)
 Internal log-addition. More...
 
template<typename T >
T::elem_type AccuLog (const T &x)
 Log-sum a vector of log values. More...
 
template<typename T , bool InPlace = false>
void LogSumExp (const T &x, arma::Col< typename T::elem_type > &y)
 Compute the sum of exponentials of each element in each column, then compute the log of that. More...
 
template<typename T , bool InPlace = false>
void LogSumExpT (const T &x, arma::Col< typename T::elem_type > &y)
 Compute the sum of exponentials of each element in each row, then compute the log of that. More...
 
template<typename ElemType >
arma::Cube< ElemType > MakeAlias (arma::Cube< ElemType > &input, const bool strict=true)
 Make an alias of a dense cube. More...
 
template<typename ElemType >
arma::Mat< ElemType > MakeAlias (arma::Mat< ElemType > &input, const bool strict=true)
 Make an alias of a dense matrix. More...
 
template<typename ElemType >
arma::Row< ElemType > MakeAlias (arma::Row< ElemType > &input, const bool strict=true)
 Make an alias of a dense row. More...
 
template<typename ElemType >
arma::Col< ElemType > MakeAlias (arma::Col< ElemType > &input, const bool strict=true)
 Make an alias of a dense column. More...
 
template<typename ElemType >
arma::SpMat< ElemType > MakeAlias (const arma::SpMat< ElemType > &input, const bool=true)
 Make a copy of a sparse matrix (an alias is not possible). More...
 
template<typename ElemType >
arma::SpRow< ElemType > MakeAlias (const arma::SpRow< ElemType > &input, const bool=true)
 Make a copy of a sparse row (an alias is not possible). More...
 
template<typename ElemType >
arma::SpCol< ElemType > MakeAlias (const arma::SpCol< ElemType > &input, const bool=true)
 Make a copy of a sparse column (an alias is not possible). More...
 
template<typename ElemType >
void ClearAlias (arma::Mat< ElemType > &mat)
 Clear an alias so that no data is overwritten. More...
 
template<typename ElemType >
void ClearAlias (arma::SpMat< ElemType > &)
 Clear an alias for a sparse matrix. More...
 
template<typename CubeType >
CubeType MultiplyCube2Cube (const CubeType &cubeA, const CubeType &cubeB, const bool aTranspose=false, const bool bTranspose=false)
 Matrix multiplication of slices of two cubes. More...
 
template<typename MatType , typename CubeType >
CubeType MultiplyMat2Cube (const MatType &matA, const CubeType &cubeB, const bool aTranspose=false, const bool bTranspose=false)
 Matrix multiplication of a matrix and all the slices of a cube. More...
 
template<typename CubeType , typename MatType >
CubeType MultiplyCube2Mat (const CubeType &cubeA, const MatType &matB, const bool aTranspose=false, const bool bTranspose=false)
 Matrix multiplication of all slices of a cube with a matrix. More...
 
MLPACK_EXPORT std::uniform_real_distribution randUniformDist (0.0, 1.0)
 
MLPACK_EXPORT std::normal_distribution randNormalDist (0.0, 1.0)
 
void RandomSeed (const size_t seed)
 Set the random seed used by the random functions (Random() and RandInt()). More...
 
void FixedRandomSeed ()
 Set the random seed to a fixed number. More...
 
void CustomRandomSeed (const size_t seed)
 
double Random ()
 Generates a uniform random number between 0 and 1.
 
double Random (const double lo, const double hi)
 Generates a uniform random number in the specified range.
 
double RandBernoulli (const double input)
 Generates a 0/1 specified by the input.
 
int RandInt (const int hiExclusive)
 Generates a uniform random integer.
 
int RandInt (const int lo, const int hiExclusive)
 Generates a uniform random integer.
 
double RandNormal ()
 Generates a normally distributed random number with mean 0 and variance 1.
 
double RandNormal (const double mean, const double variance)
 Generates a normally distributed random number with specified mean and variance. More...
 
void ObtainDistinctSamples (const size_t loInclusive, const size_t hiExclusive, const size_t maxNumSamples, arma::uvec &distinctSamples)
 Obtains no more than maxNumSamples distinct samples. More...
 
void RandomBasis (mat &basis, const size_t d)
 
void RandomBasis (arma::mat &basis, const size_t d)
 Create a random d-dimensional orthogonal basis, storing it in the given matrix. More...
 
template<typename T >
RangeType< T > operator* (const T d, const RangeType< T > &r)
 
template<typename MatType , typename LabelsType >
void ShuffleData (const MatType &inputPoints, const LabelsType &inputLabels, MatType &outputPoints, LabelsType &outputLabels, const std::enable_if_t<!arma::is_SpMat< MatType >::value > *=0, const std::enable_if_t<!arma::is_Cube< MatType >::value > *=0)
 Shuffle a dataset and associated labels (or responses). More...
 
template<typename MatType , typename LabelsType >
void ShuffleData (const MatType &inputPoints, const LabelsType &inputLabels, MatType &outputPoints, LabelsType &outputLabels, const std::enable_if_t< arma::is_SpMat< MatType >::value > *=0, const std::enable_if_t<!arma::is_Cube< MatType >::value > *=0)
 Shuffle a sparse dataset and associated labels (or responses). More...
 
template<typename MatType , typename LabelsType >
void ShuffleData (const MatType &inputPoints, const LabelsType &inputLabels, MatType &outputPoints, LabelsType &outputLabels, const std::enable_if_t<!arma::is_SpMat< MatType >::value > *=0, const std::enable_if_t< arma::is_Cube< MatType >::value > *=0, const std::enable_if_t< arma::is_Cube< LabelsType >::value > *=0)
 Shuffle a cube-shaped dataset and associated labels (or responses) which are also cube-shaped. More...
 
template<typename MatType , typename LabelsType , typename WeightsType >
void ShuffleData (const MatType &inputPoints, const LabelsType &inputLabels, const WeightsType &inputWeights, MatType &outputPoints, LabelsType &outputLabels, WeightsType &outputWeights, const std::enable_if_t<!arma::is_SpMat< MatType >::value > *=0, const std::enable_if_t<!arma::is_Cube< MatType >::value > *=0)
 Shuffle a dataset and associated labels (or responses) and weights. More...
 
template<typename MatType , typename LabelsType , typename WeightsType >
void ShuffleData (const MatType &inputPoints, const LabelsType &inputLabels, const WeightsType &inputWeights, MatType &outputPoints, LabelsType &outputLabels, WeightsType &outputWeights, const std::enable_if_t< arma::is_SpMat< MatType >::value > *=0, const std::enable_if_t<!arma::is_Cube< MatType >::value > *=0)
 Shuffle a sparse dataset and associated labels (or responses) and weights. More...
 

Variables

MLPACK_EXPORT std::mt19937 randGen
 MLPACK_EXPORT is required for global variables; it exports the symbols correctly on Windows.
 
MLPACK_EXPORT std::uniform_real_distribution randUniformDist
 
MLPACK_EXPORT std::normal_distribution randNormalDist
 

Detailed Description

Miscellaneous math routines.

Function Documentation

◆ AccuLog()

template<typename T >
T::elem_type mlpack::math::AccuLog ( const T &  x)

Log-sum a vector of log values.

Sum a vector of log values.

(T should be an Armadillo type.)

Parameters
xvector of log values
Returns
log(e^x0 + e^x1 + ...)
Parameters
xvector of log values
Returns
log(e^x0 + e^x1 + ...)

◆ Center()

void mlpack::math::Center ( const arma::mat &  x,
arma::mat &  xCentered 
)

Creates a centered matrix, where centering is done by subtracting the sum over the columns (a column vector) from each column of the matrix.

Parameters
xInput matrix
xCenteredMatrix to write centered output into

◆ ClampNonNegative()

double mlpack::math::ClampNonNegative ( const double  d)
inline

Forces a number to be non-negative, turning negative numbers into zero.

Avoids branching costs (this is a measurable improvement).

Parameters
dDouble to clamp.
Returns
0 if d < 0, d otherwise.

◆ ClampNonPositive()

double mlpack::math::ClampNonPositive ( const double  d)
inline

Forces a number to be non-positive, turning positive numbers into zero.

Avoids branching costs (this is a measurable improvement).

Parameters
dDouble to clamp.
Returns
0 if d > 0, d otherwise.

◆ ClampRange()

double mlpack::math::ClampRange ( double  value,
const double  rangeMin,
const double  rangeMax 
)
inline

Clamp a number between a particular range.

Parameters
valueThe number to clamp.
rangeMinThe first of the range.
rangeMaxThe last of the range.
Returns
max(rangeMin, min(rangeMax, d)).

◆ ClearAlias() [1/2]

template<typename ElemType >
void mlpack::math::ClearAlias ( arma::Mat< ElemType > &  mat)

Clear an alias so that no data is overwritten.

This resets the matrix if it is an alias (and does nothing otherwise).

◆ ClearAlias() [2/2]

template<typename ElemType >
void mlpack::math::ClearAlias ( arma::SpMat< ElemType > &  )

Clear an alias for a sparse matrix.

This does nothing because no sparse matrices can have aliases.

◆ FixedRandomSeed()

void mlpack::math::FixedRandomSeed ( )
inline

Set the random seed to a fixed number.

This function is used in binding tests to set a fixed random seed before calling mlpack(). In this way we can test whether a certain parameter makes a difference to execution of CLI binding. Refer to pull request #1306 for discussion on this function.

◆ LogAdd()

template<typename T >
T mlpack::math::LogAdd ( x,
y 
)

Internal log-addition.

Parameters
xlog value
ylog value
Returns
log(e^x + e^y)

\[ e^z = e^x + e^y e^z = e^x(1 + e^{y-x}) = e^y(1 + e^{x-y}) z = x + \log(1 + e^{y-x}) = y + \log(1 + e^{x-y}) \]

So when \( y > x \), \( z = y + \log(1 + e^{x-y}) \); when \( x > y \), \( z = x + \log(1 + e^{y-x}) \).

Parameters
xlog value
ylog value
Returns
log(e^x + e^y)

◆ LogSumExp()

template<typename T , bool InPlace = false>
void mlpack::math::LogSumExp ( const T &  x,
arma::Col< typename T::elem_type > &  y 
)

Compute the sum of exponentials of each element in each column, then compute the log of that.

If InPlace is true, then the values of y will also be added to the sum.

That is, if InPlace is false, then this method will set y such that:

`y_i = log(sum(exp(x.col(i))))`

and if InPlace is true, then y will be set such that:

`y_i = log(sum(exp(x.col(i))) + exp(y_i))`.

If InPlace is true, then the values of y will also be added to the sum.

◆ LogSumExpT()

template<typename T , bool InPlace = false>
void mlpack::math::LogSumExpT ( const T &  x,
arma::Col< typename T::elem_type > &  y 
)

Compute the sum of exponentials of each element in each row, then compute the log of that.

If InPlace is true, then the values of y will also be added to the sum.

That is, if InPlace is false, then this method will set y such that:

`y_i = log(sum(exp(x.row(i))))`

and if InPlace is true, then y will be set such that:

`y_i = log(sum(exp(x.row(i))) + exp(y_i))`.

If InPlace is true, then the values of y will also be added to the sum.

◆ MakeAlias() [1/7]

template<typename ElemType >
arma::Cube<ElemType> mlpack::math::MakeAlias ( arma::Cube< ElemType > &  input,
const bool  strict = true 
)

Make an alias of a dense cube.

If strict is true, then the alias cannot be resized or pointed at new memory.

◆ MakeAlias() [2/7]

template<typename ElemType >
arma::Mat<ElemType> mlpack::math::MakeAlias ( arma::Mat< ElemType > &  input,
const bool  strict = true 
)

Make an alias of a dense matrix.

If strict is true, then the alias cannot be resized or pointed at new memory.

◆ MakeAlias() [3/7]

template<typename ElemType >
arma::Row<ElemType> mlpack::math::MakeAlias ( arma::Row< ElemType > &  input,
const bool  strict = true 
)

Make an alias of a dense row.

If strict is true, then the alias cannot be resized or pointed at new memory.

◆ MakeAlias() [4/7]

template<typename ElemType >
arma::Col<ElemType> mlpack::math::MakeAlias ( arma::Col< ElemType > &  input,
const bool  strict = true 
)

Make an alias of a dense column.

If strict is true, then the alias cannot be resized or pointed at new memory.

◆ MakeAlias() [5/7]

template<typename ElemType >
arma::SpMat<ElemType> mlpack::math::MakeAlias ( const arma::SpMat< ElemType > &  input,
const bool  = true 
)

Make a copy of a sparse matrix (an alias is not possible).

The strict parameter is ignored.

◆ MakeAlias() [6/7]

template<typename ElemType >
arma::SpRow<ElemType> mlpack::math::MakeAlias ( const arma::SpRow< ElemType > &  input,
const bool  = true 
)

Make a copy of a sparse row (an alias is not possible).

The strict parameter is ignored.

◆ MakeAlias() [7/7]

template<typename ElemType >
arma::SpCol<ElemType> mlpack::math::MakeAlias ( const arma::SpCol< ElemType > &  input,
const bool  = true 
)

Make a copy of a sparse column (an alias is not possible).

The strict parameter is ignored.

◆ MultiplyCube2Cube()

template<typename CubeType >
CubeType mlpack::math::MultiplyCube2Cube ( const CubeType &  cubeA,
const CubeType &  cubeB,
const bool  aTranspose = false,
const bool  bTranspose = false 
)

Matrix multiplication of slices of two cubes.

This function expects both cubes to have the same number of slices. For example, a valid operation would be: cube A of shape (m, p, s) multiplied by cube B of shape (p, n, s) resulting in a cube of shape (m, n, s).

Parameters
cubeAFirst cube.
cubeBSecond cube.
aTransposeWhether slices of first cube have to be transposed.
bTransposeWhether slices of second cube have to be transposed.

◆ MultiplyCube2Mat()

template<typename CubeType , typename MatType >
CubeType mlpack::math::MultiplyCube2Mat ( const CubeType &  cubeA,
const MatType &  matB,
const bool  aTranspose = false,
const bool  bTranspose = false 
)

Matrix multiplication of all slices of a cube with a matrix.

This function is used when the first object is a cube and the second object is a matrix. For example, a valid operation would be: cube A of shape (m, p, s) multiplied by a matrix of shape (p, n) resulting in a cube of shape (m, n, s).

Parameters
cubeAThe cube as the first operand.
matBThe matrix as the second operand.
aTransposeWhether slices of cube have to be transposed.
bTransposeWhether matrix has to be transposed.

◆ MultiplyMat2Cube()

template<typename MatType , typename CubeType >
CubeType mlpack::math::MultiplyMat2Cube ( const MatType &  matA,
const CubeType &  cubeB,
const bool  aTranspose = false,
const bool  bTranspose = false 
)

Matrix multiplication of a matrix and all the slices of a cube.

This function is used when the first object is a matrix and the second object is a cube. For example, a valid operation would be: matrix A of shape (m, p) multiplied by cube B of shape (p, n, s) resulting in a cube of shape (m, n, s).

Parameters
matAThe matrix as the first operand.
cubeBThe cube as the second operand.
aTransposeWhether matrix has to be transposed.
bTransposeWhether slices of cube have to be transposed.

◆ ObtainDistinctSamples()

void mlpack::math::ObtainDistinctSamples ( const size_t  loInclusive,
const size_t  hiExclusive,
const size_t  maxNumSamples,
arma::uvec &  distinctSamples 
)
inline

Obtains no more than maxNumSamples distinct samples.

Each sample belongs to [loInclusive, hiExclusive).

Parameters
loInclusiveThe lower bound (inclusive).
hiExclusiveThe high bound (exclusive).
maxNumSamplesThe maximum number of samples to obtain.
distinctSamplesThe samples that will be obtained.

◆ Orthogonalize() [1/2]

void mlpack::math::Orthogonalize ( const arma::mat &  x,
arma::mat &  W 
)

Orthogonalize x and return the result in W, using eigendecomposition.

We will be using the formula \( W = x (x^T x)^{-0.5} \).

◆ Orthogonalize() [2/2]

void mlpack::math::Orthogonalize ( arma::mat &  x)

Orthogonalize x in-place.

This could be sped up by a custom implementation.

◆ RandNormal()

double mlpack::math::RandNormal ( const double  mean,
const double  variance 
)
inline

Generates a normally distributed random number with specified mean and variance.

Parameters
meanMean of distribution.
varianceVariance of distribution.

◆ RandomBasis()

void mlpack::math::RandomBasis ( arma::mat &  basis,
const size_t  d 
)

Create a random d-dimensional orthogonal basis, storing it in the given matrix.

Parameters
basisMatrix to store basis in.
dDesired number of dimensions in the basis.

◆ RandomSeed()

void mlpack::math::RandomSeed ( const size_t  seed)
inline

Set the random seed used by the random functions (Random() and RandInt()).

The seed is casted to a 32-bit integer before being given to the random number generator, but a size_t is taken as a parameter for API consistency.

Parameters
seedSeed for the random number generator.

◆ RemoveRows()

void mlpack::math::RemoveRows ( const arma::mat &  input,
const std::vector< size_t > &  rowsToRemove,
arma::mat &  output 
)

Remove a certain set of rows in a matrix while copying to a second matrix.

Parameters
inputInput matrix to copy.
rowsToRemoveVector containing indices of rows to be removed.
outputMatrix to copy non-removed rows into.

◆ ShuffleData() [1/5]

template<typename MatType , typename LabelsType >
void mlpack::math::ShuffleData ( const MatType &  inputPoints,
const LabelsType &  inputLabels,
MatType &  outputPoints,
LabelsType &  outputLabels,
const std::enable_if_t<!arma::is_SpMat< MatType >::value > *  = 0,
const std::enable_if_t<!arma::is_Cube< MatType >::value > *  = 0 
)

Shuffle a dataset and associated labels (or responses).

It is expected that inputPoints and inputLabels have the same number of columns (so, be sure that inputLabels, if it is a vector, is a row vector).

Shuffled data will be output into outputPoints and outputLabels.

◆ ShuffleData() [2/5]

template<typename MatType , typename LabelsType >
void mlpack::math::ShuffleData ( const MatType &  inputPoints,
const LabelsType &  inputLabels,
MatType &  outputPoints,
LabelsType &  outputLabels,
const std::enable_if_t< arma::is_SpMat< MatType >::value > *  = 0,
const std::enable_if_t<!arma::is_Cube< MatType >::value > *  = 0 
)

Shuffle a sparse dataset and associated labels (or responses).

It is expected that inputPoints and inputLabels have the same number of columns (so, be sure that inputLabels, if it is a vector, is a row vector).

Shuffled data will be output into outputPoints and outputLabels.

◆ ShuffleData() [3/5]

template<typename MatType , typename LabelsType >
void mlpack::math::ShuffleData ( const MatType &  inputPoints,
const LabelsType &  inputLabels,
MatType &  outputPoints,
LabelsType &  outputLabels,
const std::enable_if_t<!arma::is_SpMat< MatType >::value > *  = 0,
const std::enable_if_t< arma::is_Cube< MatType >::value > *  = 0,
const std::enable_if_t< arma::is_Cube< LabelsType >::value > *  = 0 
)

Shuffle a cube-shaped dataset and associated labels (or responses) which are also cube-shaped.

It is expected that inputPoints and inputLabels have the same number of columns.

Shuffled data will be output into outputPoints and outputLabels.

◆ ShuffleData() [4/5]

template<typename MatType , typename LabelsType , typename WeightsType >
void mlpack::math::ShuffleData ( const MatType &  inputPoints,
const LabelsType &  inputLabels,
const WeightsType &  inputWeights,
MatType &  outputPoints,
LabelsType &  outputLabels,
WeightsType &  outputWeights,
const std::enable_if_t<!arma::is_SpMat< MatType >::value > *  = 0,
const std::enable_if_t<!arma::is_Cube< MatType >::value > *  = 0 
)

Shuffle a dataset and associated labels (or responses) and weights.

It is expected that inputPoints and inputLabels and inputWeights have the same number of columns (so, be sure that inputLabels, if it is a vector, is a row vector).

Shuffled data will be output into outputPoints and outputLabels and outputWeights.

◆ ShuffleData() [5/5]

template<typename MatType , typename LabelsType , typename WeightsType >
void mlpack::math::ShuffleData ( const MatType &  inputPoints,
const LabelsType &  inputLabels,
const WeightsType &  inputWeights,
MatType &  outputPoints,
LabelsType &  outputLabels,
WeightsType &  outputWeights,
const std::enable_if_t< arma::is_SpMat< MatType >::value > *  = 0,
const std::enable_if_t<!arma::is_Cube< MatType >::value > *  = 0 
)

Shuffle a sparse dataset and associated labels (or responses) and weights.

It is expected that inputPoints and inputLabels and inputWeights have the same number of columns (so, be sure that inputLabels, if it is a vector, is a row vector).

Shuffled data will be output into outputPoints and outputLabels and outputWeights.

◆ Sign()

template<typename T >
T mlpack::math::Sign ( const T  x)

Signum function.

Return 1 if x>0; return 0 if x=0; return -1 if x<0. Return type are the same as input type.

Parameters
xNumber of any type.

◆ Smat()

void mlpack::math::Smat ( const arma::vec &  input,
arma::mat &  output 
)

The inverse of Svec.

That is, Smat(Svec(A)) == A.

Parameters
input
outputA symmetric matrix

◆ Svec()

void mlpack::math::Svec ( const arma::mat &  input,
arma::vec &  output 
)

Upper triangular representation of a symmetric matrix, scaled such that, dot(Svec(A), Svec(B)) == dot(A, B) for symmetric A, B.

Specifically,

Svec(K) = [ K_11, sqrt(2) K_12, ..., sqrt(2) K_1n, K_22, ..., sqrt(2) K_2n, ..., K_nn ]^T

Parameters
inputA symmetric matrix
output

◆ SvecIndex()

size_t mlpack::math::SvecIndex ( size_t  i,
size_t  j,
size_t  n 
)
inline

Return the index such that A[i,j] == factr(i, j) * svec(A)[pos(i, j)], where factr(i, j) = sqrt(2) if i != j and 1 otherwise.

Parameters
i
j
n

◆ SymKronId()

void mlpack::math::SymKronId ( const arma::mat &  A,
arma::mat &  op 
)

If A is a symmetric matrix, then SymKronId returns an operator Op such that.

Op * svec(X) == svec(0.5 * (AX + XA))

for every symmetric matrix X

Parameters
A
op

◆ VectorPower()

void mlpack::math::VectorPower ( arma::vec &  vec,
const double  power 
)

Auxiliary function to raise vector elements to a specific power.

The sign is ignored in the power operation and then re-added. Useful for eigenvalues.

◆ WhitenUsingSVD()

void mlpack::math::WhitenUsingSVD ( const arma::mat &  x,
arma::mat &  xWhitened,
arma::mat &  whiteningMatrix 
)

Whitens a matrix using the singular value decomposition of the covariance matrix.

Whitening means the covariance matrix of the result is the identity matrix.