Miscellaneous math routines. More...
Classes | |
class | Range |
Simple real-valued range. More... | |
Functions | |
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. | |
double | ClampNonNegative (const double d) |
Forces a number to be non-negative, turning negative numbers into zero. | |
double | ClampNonPositive (const double d) |
Forces a number to be non-positive, turning positive numbers into zero. | |
double | ClampRange (double value, const double rangeMin, const double rangeMax) |
Clamp a number between a particular range. | |
void | Orthogonalize (arma::mat &x) |
Orthogonalize x in-place. | |
void | Orthogonalize (const arma::mat &x, arma::mat &W) |
Orthogonalize x and return the result in W, using eigendecomposition. | |
int | RandInt (const int lo, const int hiExclusive) |
Generates a uniform random integer. | |
int | RandInt (const int hiExclusive) |
Generates a uniform random integer. | |
double | RandNormal (const double mean, const double variance) |
Generates a normally distributed random number with specified mean and variance. | |
double | RandNormal () |
Generates a normally distributed random number with mean 0 and variance 1. | |
double | Random (const double lo, const double hi) |
Generates a uniform random number in the specified range. | |
double | Random () |
Generates a uniform random number between 0 and 1. | |
void | RandomSeed (const size_t seed) |
Set the random seed used by the random functions (Random() and RandInt()). | |
void | RandVector (arma::vec &v) |
Overwrites a dimension-N vector to a random vector on the unit sphere in R^N. | |
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. | |
void | VectorPower (arma::vec &vec, double power) |
Auxiliary function to raise vector elements to a specific power. | |
void | WhitenUsingEig (const arma::mat &x, arma::mat &xWhitened, arma::mat &whiteningMatrix) |
Whitens a matrix using the eigendecomposition of the covariance matrix. | |
void | WhitenUsingSVD (const arma::mat &x, arma::mat &xWhitened, arma::mat &whiteningMatrix) |
Whitens a matrix using the singular value decomposition of the covariance matrix. | |
Variables | |
boost::mt19937 | randGen |
boost::normal_distribution | randNormalDist |
boost::uniform_01 < boost::mt19937, double > | randUniformDist |
Miscellaneous math routines.
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.
x | Input matrix | |
xCentered | Matrix to write centered output into |
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).
d | Double to clamp. |
Definition at line 38 of file clamp.hpp.
Referenced by ClampRange().
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).
d | Double to clamp. | |
0 | if d > 0, d otherwise. |
Definition at line 50 of file clamp.hpp.
Referenced by ClampRange().
double mlpack::math::ClampRange | ( | double | value, | |
const double | rangeMin, | |||
const double | rangeMax | |||
) | [inline] |
Clamp a number between a particular range.
value | The number to clamp. | |
rangeMin | The first of the range. | |
rangeMax | The last of the range. |
Definition at line 63 of file clamp.hpp.
References ClampNonNegative(), and ClampNonPositive().
void mlpack::math::Orthogonalize | ( | arma::mat & | x | ) |
Orthogonalize x in-place.
This could be sped up by a custom implementation.
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 .
int mlpack::math::RandInt | ( | const int | lo, | |
const int | hiExclusive | |||
) | [inline] |
Generates a uniform random integer.
Definition at line 117 of file random.hpp.
References randGen, and randUniformDist.
int mlpack::math::RandInt | ( | const int | hiExclusive | ) | [inline] |
Generates a uniform random integer.
Definition at line 103 of file random.hpp.
References randGen, and randUniformDist.
Referenced by mlpack::sparse_coding::DataDependentRandomInitializer::Initialize(), and mlpack::nmf::RandomAcolInitialization< p >::Initialize().
double mlpack::math::RandNormal | ( | const double | mean, | |
const double | variance | |||
) | [inline] |
Generates a normally distributed random number with specified mean and variance.
mean | Mean of distribution. | |
variance | Variance of distribution. |
Definition at line 146 of file random.hpp.
References randGen, and randNormalDist.
double mlpack::math::RandNormal | ( | ) | [inline] |
Generates a normally distributed random number with mean 0 and variance 1.
Definition at line 134 of file random.hpp.
References randGen, and randNormalDist.
double mlpack::math::Random | ( | const double | lo, | |
const double | hi | |||
) | [inline] |
Generates a uniform random number in the specified range.
Definition at line 89 of file random.hpp.
References randGen, and randUniformDist.
double mlpack::math::Random | ( | ) | [inline] |
Generates a uniform random number between 0 and 1.
Definition at line 75 of file random.hpp.
References randGen, and randUniformDist.
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.
seed | Seed for the random number generator. |
Definition at line 66 of file random.hpp.
References randGen.
void mlpack::math::RandVector | ( | arma::vec & | v | ) |
Overwrites a dimension-N vector to a random vector on the unit sphere in R^N.
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.
input | Input matrix to copy. | |
rowsToRemove | Vector containing indices of rows to be removed. | |
output | Matrix to copy non-removed rows into. |
void mlpack::math::VectorPower | ( | arma::vec & | vec, | |
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.
void mlpack::math::WhitenUsingEig | ( | const arma::mat & | x, | |
arma::mat & | xWhitened, | |||
arma::mat & | whiteningMatrix | |||
) |
Whitens a matrix using the eigendecomposition of the covariance matrix.
Whitening means the covariance matrix of the result is the identity matrix.
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.
boost::mt19937 mlpack::math::randGen |
Referenced by RandInt(), RandNormal(), Random(), and RandomSeed().
boost::normal_distribution mlpack::math::randNormalDist |
Referenced by RandNormal().
boost::uniform_01<boost::mt19937, double> mlpack::math::randUniformDist |