CEBL
2.1
|
Data Structures | |
struct | EigStruct |
struct | SvdStruct |
Functions | |
template<typename T > | |
ublas::vector< T > | createVector (const ublas::matrix< T > &m) |
template<typename T > | |
ublas::vector< T > | createVector (const T &value, int size) |
template<typename T > | |
ublas::matrix< T > | createMatrix (const ublas::vector< T > &vec, int rows, int cols, bool byrow=false) |
template<typename T > | |
ublas::matrix< T > | createMatrix (const std::vector< T > &vec, int rows, int cols, bool byrow=false) |
template<typename T > | |
ublas::matrix< T > | createMatrix (T value, int rows, int cols) |
template<typename T > | |
ublas::vector< T > | bind (ublas::vector< T > v1, ublas::vector< T > v2) |
template<typename T > | |
ublas::vector< T > | rep (const ublas::vector< T > &vec, int n) |
template<typename T > | |
ublas::vector< T > | rep (const T &value, int n) |
template<typename T > | |
ublas::vector< T > | diag (const ublas::matrix< T > &m) |
template<typename T > | |
ublas::matrix< T > | diag (const ublas::vector< T > &v) |
template<typename T > | |
ublas::matrix< T > | diag (const T &value, int size) |
template<typename T > | |
ublas::vector< T > | vectorRange (T min, T max) |
template<typename T > | |
ublas::matrix_slice < ublas::matrix< T > > | submatrix (ublas::matrix< T > &m, int r1, int r2, int c1, int c2) |
template<typename T > | |
const ublas::matrix_slice < ublas::matrix< T > > | submatrix (const ublas::matrix< T > &m, int r1, int r2, int c1, int c2) |
template<typename T > | |
void | submatrixAssign (ublas::matrix< T > &m1, int m1start1, int m1end1, int m1start2, int m1end2, const ublas::matrix< T > &m2, int m2start1, int m2end1, int m2start2, int m2end2) |
template<typename T > | |
std::vector< bool > | createMask (T value, ublas::vector< T > v) |
template<typename T > | |
ublas::matrix< T > | rowMask (const ublas::matrix< T > &m, std::vector< bool > mask) |
template<typename T > | |
ublas::matrix< T > | cbind (const ublas::matrix< T > &m1, const ublas::matrix< T > &m2) |
template<typename T > | |
ublas::matrix< T > | rbind (const ublas::matrix< T > &m1, const ublas::matrix< T > &m2) |
template<typename T > | |
ublas::matrix< T > | rev (const ublas::matrix< T > &m1) |
template<typename T > | |
ublas::vector< T > | rev (const ublas::vector< T > &v) |
template<typename T > | |
ublas::matrix< T > | compProd (const ublas::matrix< T > &m, const ublas::matrix< T > &n) |
template<typename T > | |
ublas::matrix< T > | compDiv (const ublas::matrix< T > &m, const ublas::matrix< T > &n) |
template<typename T > | |
ublas::matrix< T > | solve (const ublas::matrix< T > &m1) |
template<typename T > | |
ublas::matrix< T > | solve (const ublas::matrix< T > &m1, const ublas::matrix< T > &m2) |
template<typename T > | |
EigStruct< T > | eigen (const ublas::matrix< T > &m1) |
template<typename T > | |
SvdStruct< T > | svd (const ublas::matrix< T > &m1) |
template<typename T > | |
int | rank (const ublas::matrix< T > &m) |
template<typename T > | |
double | det (const boost::numeric::ublas::matrix_expression< T > &m) |
template<typename T > | |
ublas::matrix< T > | Lag (const ublas::matrix< T > &data_orig, int n_lags) |
template<typename T > | |
ublas::matrix< T > | Re (ublas::matrix< std::complex< T > > m) |
template<typename T > | |
ublas::matrix< std::complex< T > > | Conj (ublas::matrix< std::complex< T > > m) |
ublas::matrix< std::complex < double > > | fft (const ublas::matrix< complex< double > > &m, bool inverse=false) |
ublas::matrix< std::complex < double > > | fft (const ublas::matrix< double > &m, bool inverse=false) |
template<typename T > | |
ublas::matrix< T > | operator+= (const ublas::matrix< T > &m, const T v) |
Scalar addition for a ublas matrix. | |
template<typename T > | |
ublas::matrix< T > | operator+ (const ublas::matrix< T > &m, const T v) |
Scalar addition for a ublas matrix. | |
template<typename T > | |
ublas::matrix< T > | operator-= (const ublas::matrix< T > &m, const T v) |
Scalar subtraction for a ublas matrix. | |
template<typename T > | |
ublas::matrix< T > | operator- (const ublas::matrix< T > &m, const T v) |
Scalar subtraction for ublas matrix. | |
template<typename T > | |
ublas::matrix< T > | operator/ (const T &value, ublas::matrix< T > &m1) |
template<typename T > | |
ublas::vector< T > | operator/ (const T &value, ublas::vector< T > &v1) |
template<typename T > | |
ublas::vector< T > | rowMeans (ublas::matrix< T > &data) |
template<typename T > | |
ublas::vector< T > | colMeans (ublas::matrix< T > &data) |
template<typename T > | |
ublas::vector< T > | rowSums (ublas::matrix< T > &data) |
template<typename T > | |
ublas::vector< T > | colSums (ublas::matrix< T > &data) |
template<typename T > | |
ublas::matrix< T > | t (const ublas::matrix< T > &m) |
template<typename T > | |
int | ncol (const ublas::matrix< T > &m) |
template<typename T > | |
int | nrow (const ublas::matrix< T > &m) |
template<typename T > | |
double | frobeniusNorm (ublas::matrix< T > m) |
template<typename T > | |
ublas::vector< T > | unique (const ublas::vector< T > &v) |
template<typename T > | |
int | count (const T &value, const ublas::vector< T > &v) |
template<typename T > | |
ublas::matrix< T > | square (const ublas::matrix< T > &m) |
template<typename T > | |
T | sum (const ublas::vector< T > &v) |
template<typename T > | |
T | sum (const ublas::matrix< T > &m) |
template<typename T > | |
ublas::vector< T > | vsqrt (const ublas::vector< T > &v1) |
template<typename T > | |
T | min (const ublas::matrix< T > &m) |
template<typename T > | |
T | min (const ublas::vector< T > &v) |
template<typename T > | |
T | max (const ublas::matrix< T > &m) |
template<typename T > | |
T | max (const ublas::vector< T > &v) |
template<typename T > | |
int | whichMax (const ublas::vector< T > &v) |
template<typename T > | |
int | whichMin (const ublas::vector< T > &v) |
template<typename T > | |
T | mean (const ublas::vector< T > &v) |
template<typename T > | |
T | mean (const ublas::matrix< T > &m) |
template<typename T > | |
double | var (const ublas::vector< T > &v, double m) |
template<typename T > | |
double | var (const ublas::vector< T > &v) |
template<typename T > | |
double | sd (const ublas::vector< T > &v) |
template<typename T > | |
ublas::vector< double > | sd (const ublas::matrix< T > &m) |
template<typename T > | |
ublas::vector< T > | runif (int n) |
template<typename T > | |
ublas::vector< T > | rnorm (int n, double mean, double sd) |
template<typename T > | |
std::vector< T > | asStdVector (ublas::vector< T > vec) |
template<typename T > | |
ublas::vector< T > | asUblasVector (std::vector< T > vec) |
template<typename T > | |
ublas::vector< T > | sample (ublas::vector< T > vec) |
template<typename T > | |
ublas::matrix< T > | apply (const ublas::matrix< T > &m, T(*func)(T)) |
template<typename T , typename U > | |
ublas::matrix< T > | apply (const ublas::matrix< T > &m, T(*func)(T, U), U arg2) |
template<typename T > | |
ublas::vector< T > | apply (const ublas::vector< T > &m, T(*func)(T)) |
template<typename T > | |
ublas::vector< T > | rowApply (const ublas::matrix< T > &m, T(*func)(const ublas::vector< T > &)) |
template<typename T > | |
ublas::vector< T > | columnApply (const ublas::matrix< T > &m, T(*func)(const ublas::vector< T > &)) |
template<typename T > | |
void | printMatrix (const ublas::matrix< T > &m) |
template<typename T > | |
void | printVector (const ublas::vector< T > &v) |
template<typename T > | |
void | printVector (const std::vector< T > &v) |
template<typename T > | |
void | printMatrixDim (const ublas::matrix< T > &m) |
template<typename T > | |
void | writeTable (const ublas::matrix< T > &m, string filename) |
template<typename T > | |
ublas::matrix< T > | readTable (string filename) |
ublas::matrix<T> cppR::apply | ( | const ublas::matrix< T > & | m, |
T(*)(T) | func | ||
) |
Applies a 1 argument function to each value in a matrix.
m | |
func | function to apply |
Definition at line 146 of file cppR_utils.hpp.
Referenced by chebbp2(), CEBL::MSPRT::decideClasses(), CEBL::MSPRT::updateWithProbabilities(), CEBL::QDA::use(), and CEBL::LDA::use().
ublas::matrix<T> cppR::apply | ( | const ublas::matrix< T > & | m, |
T(*)(T, U) | func, | ||
U | arg2 | ||
) |
Applies a 2-argument function to each value in a matrix.
m | |
func | function |
arg2 | second argument to function |
Definition at line 164 of file cppR_utils.hpp.
ublas::vector<T> cppR::apply | ( | const ublas::vector< T > & | m, |
T(*)(T) | func | ||
) |
Applies a 1 argument function to each value in a vector.
m | |
func |
Definition at line 181 of file cppR_utils.hpp.
std::vector<T> cppR::asStdVector | ( | ublas::vector< T > | vec | ) |
Converts a ublas vector to a std vector.
vec |
Definition at line 94 of file cppR_utils.hpp.
Referenced by CEBL::SimpleMax::decideClasses(), CEBL::MSPRT::decideClasses(), CEBL::SimpleMax::init(), boost::serialization::save(), CEBL::QDA::use(), and CEBL::LDA::use().
ublas::vector<T> cppR::asUblasVector | ( | std::vector< T > | vec | ) |
Converts a std vector into a ublas vector.
vec | std vector |
Definition at line 110 of file cppR_utils.hpp.
Referenced by CEBL::SimpleMax::decideClasses(), boost::serialization::load(), readTable(), RealTimeClassification::timeoutFunction(), and CEBL::MSPRT::updateWithProbabilities().
ublas::vector<T> cppR::bind | ( | ublas::vector< T > | v1, |
ublas::vector< T > | v2 | ||
) |
Binds two vectors together.
v1 | size N vector |
v2 | size M vector |
Definition at line 182 of file cppR_construction.hpp.
Referenced by TimeoutThread::timeoutStart(), and RealTimeClassification::trainClassifierThreaded().
ublas::matrix<T> cppR::cbind | ( | const ublas::matrix< T > & | m1, |
const ublas::matrix< T > & | m2 | ||
) |
Attach two matrices together horizontally and return result.
m1 | size NxM matrix |
m2 | size NxQ matrix |
Definition at line 237 of file cppR_manipulation.hpp.
References cppR_assert(), and submatrix().
Referenced by chebbp2(), filter(), and CEBL::WindowedSVD::use().
ublas::vector<T> cppR::colMeans | ( | ublas::matrix< T > & | data | ) |
Creates a vector of means for each column in a matrix.
data |
Definition at line 63 of file cppR_stats.hpp.
Referenced by CEBL::QDA::train(), and CEBL::LDA::train().
ublas::vector<T> cppR::colSums | ( | ublas::matrix< T > & | data | ) |
Creates of vector of sums for each column in a matrix.
data |
Definition at line 108 of file cppR_stats.hpp.
References sum().
ublas::vector<T> cppR::columnApply | ( | const ublas::matrix< T > & | m, |
T(*)(const ublas::vector< T > &) | func | ||
) |
Apply function to each column of a matrix and return a vector of the result for each row.
Similar to the R function call: apply(matrix, 2, func).
m | matrix |
func | function to apply to each column |
Definition at line 229 of file cppR_utils.hpp.
ublas::matrix<T> cppR::compDiv | ( | const ublas::matrix< T > & | m, |
const ublas::matrix< T > & | n | ||
) |
Compute component-wise quotient of two matrices. Matrices must be of the same size.
m | NxM matrix |
n | NxM matrix |
Definition at line 94 of file cppR_math.hpp.
Referenced by chebbp2(), CEBL::QDA::use(), and CEBL::LDA::use().
ublas::matrix<T> cppR::compProd | ( | const ublas::matrix< T > & | m, |
const ublas::matrix< T > & | n | ||
) |
Compute component-wise product of two matrices. Matrices must be of the same size.
m | NxM matrix |
n | NxM matrix |
Definition at line 66 of file cppR_math.hpp.
References cppR_assert().
Referenced by chebbp2(), convolve(), CEBL::LDA::train(), and CEBL::QDA::use().
ublas::matrix<std::complex<T> > cppR::Conj | ( | ublas::matrix< std::complex< T > > | m | ) |
Returns complex conjugate of complex matrix.
m |
Definition at line 333 of file cppR_math.hpp.
Referenced by convolve().
int cppR::count | ( | const T & | value, |
const ublas::vector< T > & | v | ||
) |
Count occurences of specific value in a vector
value | |
v |
Definition at line 197 of file cppR_stats.hpp.
Referenced by createVector(), Session::exists(), EEGTrainingData::getClassVector(), ChannelsConfig::getNumEnabled(), rev(), rowMask(), and CEBL::QDA::train().
std::vector<bool> cppR::createMask | ( | T | value, |
ublas::vector< T > | v | ||
) |
Creates a vector of booleans which are true when value equals that index in the matrix.
value | value to check |
v | vector |
Definition at line 196 of file cppR_manipulation.hpp.
Referenced by CEBL::QDA::train(), and CEBL::LDA::train().
ublas::matrix<T> cppR::createMatrix | ( | const ublas::vector< T > & | vec, |
int | rows, | ||
int | cols, | ||
bool | byrow = false |
||
) |
Create a matrix from a vector. Reshapes vector based on specified number of rows and columns. Creates matrix by column from vector unless byrow is set. If rows * cols is greater than the size of vec, the entries in vec will be reused.
vec | vector to read from. |
rows | number of rows |
cols | number of columns |
byrow | flag to create matrix by row instead of column |
Definition at line 91 of file cppR_construction.hpp.
Referenced by CEBL::MNF::apply(), chebbp2(), createMatrix(), diag(), filter(), Lag(), main(), CEBL::MNF::make(), CEBL::QDA::train(), CEBL::LDA::train(), CEBL::QDA::use(), CEBL::WindowedSVD::use(), CEBL::LDA::use(), and CEBL::PassBand::use().
ublas::matrix<T> cppR::createMatrix | ( | const std::vector< T > & | vec, |
int | rows, | ||
int | cols, | ||
bool | byrow = false |
||
) |
Std version of createMatrix1
vec | |
rows | |
cols | |
byrow |
Definition at line 133 of file cppR_construction.hpp.
References createMatrix().
ublas::matrix<T> cppR::createMatrix | ( | T | value, |
int | rows, | ||
int | cols | ||
) |
Create a matrix using a single value for every entry.
value | value to place in each entry |
rows | number of rows to make |
cols | number of cols to make |
Definition at line 151 of file cppR_construction.hpp.
ublas::vector<T> cppR::createVector | ( | const ublas::matrix< T > & | m | ) |
Creates a vector by flattening a specified matrix.
m | NxM matrix to convert to vector |
Definition at line 40 of file cppR_construction.hpp.
References count().
Referenced by CEBL::QDA::train(), and CEBL::LDA::train().
ublas::vector<T> cppR::createVector | ( | const T & | value, |
int | size | ||
) |
Create a vector of specified size by repeating value. Same as rep.
value | value to repeat |
size | size of resulting vecto |
Definition at line 61 of file cppR_construction.hpp.
double cppR::det | ( | const boost::numeric::ublas::matrix_expression< T > & | m | ) |
Compute determinant of matrix. Uses lu factorization method.
m |
Definition at line 241 of file cppR_math.hpp.
Referenced by CEBL::QDA::train().
ublas::vector<T> cppR::diag | ( | const ublas::matrix< T > & | m | ) |
Get the diagonal of a matrix and return it as a vector.
m | matrix to get diagonal from |
Definition at line 245 of file cppR_construction.hpp.
Referenced by CEBL::MNF::make(), and solve().
ublas::matrix<T> cppR::diag | ( | const ublas::vector< T > & | v | ) |
Create a matrix with diagonal entries taken from specified vector.
v | vector to use as diagonal |
Definition at line 264 of file cppR_construction.hpp.
References createMatrix(), and rep().
ublas::matrix<T> cppR::diag | ( | const T & | value, |
int | size | ||
) |
Creates a square matrix of size 'size' with diagonal entries equal to 'value'.
value | value to use as diagonal entry |
size | size of matrix |
Definition at line 287 of file cppR_construction.hpp.
References createMatrix(), and rep().
EigStruct<T> cppR::eigen | ( | const ublas::matrix< T > & | m1 | ) |
Computes eigen values and eigen vectors from specified matrix. cppR::eigen uses the lapack syev routine.
m1 | real symmetric matrix |
Definition at line 168 of file cppR_math.hpp.
References cppR::EigStruct< T >::values, and cppR::EigStruct< T >::vectors.
ublas::matrix<std::complex<double> > cppR::fft | ( | const ublas::matrix< complex< double > > & | m, |
bool | inverse = false |
||
) |
Computes the fourier transform of given matrix. Result is a complex matrix.
Note: this function is not included unless the FFTW3 header file has already been included. This is to allow compilation of cppR without necessarily linking to the FFTW3 library.
m | |
inverse | do inverse fft instead |
Definition at line 363 of file cppR_math.hpp.
Referenced by chebbp2(), convolve(), and fft().
ublas::matrix<std::complex<double> > cppR::fft | ( | const ublas::matrix< double > & | m, |
bool | inverse = false |
||
) |
double cppR::frobeniusNorm | ( | ublas::matrix< T > | m | ) |
frobeniusNorm of a matrix.
Computed as:
m | matrix M of size nXm |
Definition at line 162 of file cppR_stats.hpp.
ublas::matrix<T> cppR::Lag | ( | const ublas::matrix< T > & | data_orig, |
int | n_lags | ||
) |
Perform time embedded lagging on matrix. Note: matrix should be of the form: nFeatures X nSamples
data_orig | |
n_lags |
Definition at line 271 of file cppR_math.hpp.
References createMatrix(), ncol(), nrow(), and submatrix().
Referenced by FilterConfig::apply(), FilterConfig::getComponents(), ObjectCreate(), FilterConfig::train(), CEBL::WindowedSVD::use(), CEBL::Lag::use(), and CEBL::IncrementalSVD::use().
T cppR::max | ( | const ublas::matrix< T > & | m | ) |
Max value in a matrix.
m |
Definition at line 314 of file cppR_stats.hpp.
Referenced by chebbp2(), CEBL::SimpleMax::decideClasses(), CEBL::MSPRT::decideClasses(), RealTimeClassification::timeoutFunction(), and whichMax().
T cppR::max | ( | const ublas::vector< T > & | v | ) |
T cppR::mean | ( | const ublas::vector< T > & | v | ) |
Mean of a vector.
v |
Definition at line 378 of file cppR_stats.hpp.
References sum().
Referenced by colMeans(), mean(), rowMeans(), and var().
T cppR::mean | ( | const ublas::matrix< T > & | m | ) |
T cppR::min | ( | const ublas::matrix< T > & | m | ) |
Min value in a matrix.
m |
Definition at line 281 of file cppR_stats.hpp.
Referenced by chebbp2(), EEGMonitor::initPlot(), EEGMonitor::reInitPlot(), vectorRange(), and whichMin().
T cppR::min | ( | const ublas::vector< T > & | v | ) |
int cppR::ncol | ( | const ublas::matrix< T > & | m | ) |
Number of columns in a matrix.
m |
Definition at line 139 of file cppR_stats.hpp.
Referenced by CEBL::MNF::apply(), filter(), Lag(), CEBL::MNF::make(), sd(), CEBL::QDA::train(), CEBL::LDA::train(), CEBL::QDA::use(), CEBL::WindowedSVD::use(), CEBL::Lag::use(), and CEBL::IncrementalSVD::use().
int cppR::nrow | ( | const ublas::matrix< T > & | m | ) |
Number of rows in a matrix
m |
Definition at line 148 of file cppR_stats.hpp.
Referenced by Lag(), CEBL::MNF::make(), CEBL::QDA::train(), CEBL::LDA::train(), CEBL::QDA::use(), CEBL::WindowedSVD::use(), CEBL::Lag::use(), CEBL::LDA::use(), CEBL::IncrementalSVD::use(), and CEBL::PassBand::use().
ublas::matrix<T> cppR::operator+ | ( | const ublas::matrix< T > & | m, |
const T | v | ||
) |
Scalar addition for a ublas matrix.
Definition at line 467 of file cppR_math.hpp.
ublas::matrix<T> cppR::operator+= | ( | const ublas::matrix< T > & | m, |
const T | v | ||
) |
Scalar addition for a ublas matrix.
Definition at line 455 of file cppR_math.hpp.
ublas::matrix<T> cppR::operator- | ( | const ublas::matrix< T > & | m, |
const T | v | ||
) |
Scalar subtraction for ublas matrix.
Definition at line 491 of file cppR_math.hpp.
ublas::matrix<T> cppR::operator-= | ( | const ublas::matrix< T > & | m, |
const T | v | ||
) |
Scalar subtraction for a ublas matrix.
Definition at line 479 of file cppR_math.hpp.
ublas::matrix<T> cppR::operator/ | ( | const T & | value, |
ublas::matrix< T > & | m1 | ||
) |
Definition at line 33 of file cppR_operators.hpp.
ublas::vector<T> cppR::operator/ | ( | const T & | value, |
ublas::vector< T > & | v1 | ||
) |
Definition at line 49 of file cppR_operators.hpp.
void cppR::printMatrix | ( | const ublas::matrix< T > & | m | ) |
void cppR::printMatrixDim | ( | const ublas::matrix< T > & | m | ) |
Prints the dimensions of a matrix to standard output.
m |
Definition at line 308 of file cppR_utils.hpp.
void cppR::printVector | ( | const ublas::vector< T > & | v | ) |
void cppR::printVector | ( | const std::vector< T > & | v | ) |
Prints a std vector to standard output.
v |
Definition at line 289 of file cppR_utils.hpp.
int cppR::rank | ( | const ublas::matrix< T > & | m | ) |
Returns rank of matrix by counting the number of singular values greater than 1e-9 (due to machine precision).
m |
Definition at line 221 of file cppR_math.hpp.
References cppR::SvdStruct< T >::d, and svd().
ublas::matrix<T> cppR::rbind | ( | const ublas::matrix< T > & | m1, |
const ublas::matrix< T > & | m2 | ||
) |
Attach two matrices together vertically and return result.
m1 | size MxN matrix |
m2 | size QxN matrix |
Definition at line 267 of file cppR_manipulation.hpp.
References cppR_assert(), and submatrix().
Referenced by CEBL::WindowedSVD::use(), and CEBL::PassBand::use().
ublas::matrix<T> cppR::Re | ( | ublas::matrix< std::complex< T > > | m | ) |
Returns real portion of a complex matrix.
m |
Definition at line 316 of file cppR_math.hpp.
Referenced by chebbp2(), and convolve().
ublas::matrix<T> cppR::readTable | ( | string | filename | ) |
Reads a matrix table from a file written by R's write.table
file |
Definition at line 348 of file cppR_utils.hpp.
References asUblasVector().
ublas::vector<T> cppR::rep | ( | const ublas::vector< T > & | vec, |
int | n | ||
) |
Repeat specified vector n times into a new vector.
vec | vector to repeat |
n | number of times to repeatn |
Definition at line 203 of file cppR_construction.hpp.
Referenced by CEBL::MNF::apply(), CEBL::SimpleMax::decideClasses(), diag(), CEBL::SimpleMax::init(), CEBL::MSPRT::init(), DeviceConfig::isReady(), CEBL::MNF::make(), CEBL::QDA::train(), and CEBL::MSPRT::updateWithProbabilities().
ublas::vector<T> cppR::rep | ( | const T & | value, |
int | n | ||
) |
Repeat a single value n times into a new vector.
value | |
n |
Definition at line 226 of file cppR_construction.hpp.
ublas::matrix<T> cppR::rev | ( | const ublas::matrix< T > & | m1 | ) |
Reverse elements in matrix. If matrix has more than 1 column, all columns will be put into a single column matrix
m1 | NxM matrix to reverse |
Definition at line 297 of file cppR_manipulation.hpp.
References count().
Referenced by filter().
ublas::vector<T> cppR::rev | ( | const ublas::vector< T > & | v | ) |
Reverse a vector
v |
Definition at line 321 of file cppR_manipulation.hpp.
References count().
ublas::vector<T> cppR::rnorm | ( | int | n, |
double | mean, | ||
double | sd | ||
) |
Creates a vector of n random numbers from a normal distribution.
n | number to generate |
mean | mean of distribution |
sd | standard deviation of distribution |
Definition at line 74 of file cppR_utils.hpp.
ublas::vector<T> cppR::rowApply | ( | const ublas::matrix< T > & | m, |
T(*)(const ublas::vector< T > &) | func | ||
) |
Apply function to each row of a matrix and return a vector of the result for each row.
Similar to the R function call: apply(matrix, 1, func).
m | matrix |
func | function to apply to each row |
Definition at line 203 of file cppR_utils.hpp.
ublas::matrix<T> cppR::rowMask | ( | const ublas::matrix< T > & | m, |
std::vector< bool > | mask | ||
) |
Select rows of matrix based on a vector mask. This will return a new matrix which is constructed from the original matrix using only the rows specified in the mask.
m | matrix |
mask | should have length equal to number of rows in m |
Definition at line 215 of file cppR_manipulation.hpp.
References count().
Referenced by DataProcess::process(), CEBL::QDA::train(), and CEBL::LDA::train().
ublas::vector<T> cppR::rowMeans | ( | ublas::matrix< T > & | data | ) |
Creates a vector of means for each row in a matrix.
data |
Definition at line 40 of file cppR_stats.hpp.
Referenced by CEBL::MNF::make().
ublas::vector<T> cppR::rowSums | ( | ublas::matrix< T > & | data | ) |
Creates a vector of sums for each row in a matrix.
data |
Definition at line 87 of file cppR_stats.hpp.
References sum().
Referenced by CEBL::LDA::train(), CEBL::QDA::use(), and CEBL::LDA::use().
ublas::vector<T> cppR::runif | ( | int | n | ) |
Creates a vector of n random numbers from a uniform distribution.
n |
Definition at line 55 of file cppR_utils.hpp.
ublas::vector<T> cppR::sample | ( | ublas::vector< T > | vec | ) |
Randomly samples values in vector.
vec |
Definition at line 127 of file cppR_utils.hpp.
double cppR::sd | ( | const ublas::vector< T > & | v | ) |
Standard deviation of matrix.
v |
Definition at line 440 of file cppR_stats.hpp.
References var().
Referenced by sd(), and CEBL::max_var::use().
ublas::vector<double> cppR::sd | ( | const ublas::matrix< T > & | m | ) |
Standard deviation of a matrix.
m |
Definition at line 451 of file cppR_stats.hpp.
ublas::matrix<T> cppR::solve | ( | const ublas::matrix< T > & | m1 | ) |
Computues solution to set of real linear equations in matrix form. Uses a diagonal matrix of 1's as right-hand side so the solution will will be the inverse of the specified matrix. cppR::solve uses lapack routine gesv to perform the inverse.
m1 | matrix to solve |
Definition at line 119 of file cppR_math.hpp.
References diag().
Referenced by chebbp2(), CEBL::MNF::make(), CEBL::QDA::train(), and CEBL::LDA::train().
ublas::matrix<T> cppR::solve | ( | const ublas::matrix< T > & | m1, |
const ublas::matrix< T > & | m2 | ||
) |
Definition at line 144 of file cppR_math.hpp.
ublas::matrix<T> cppR::square | ( | const ublas::matrix< T > & | m | ) |
Square each element in matrix.
m |
Definition at line 214 of file cppR_stats.hpp.
Referenced by frobeniusNorm().
ublas::matrix_slice<ublas::matrix<T> > cppR::submatrix | ( | ublas::matrix< T > & | m, |
int | r1, | ||
int | r2, | ||
int | c1, | ||
int | c2 | ||
) |
Select a submatrix from a matrix. The matrix slice returned by this function can be assigned which will modify the selected submatrix of the original matrix. Note: use the ublas functions row(M,n) and col(M,n) if you only want single columns or rows. Submatrix will not work for a single row or column.
You can think of this function as the R brackets: m[r1:r2,c1:c2] would be submatrix(m, r1, r2, c1, c2)
m | matrix to select from |
r1 | starting row inclusive |
r2 | ending row inclusive, 0 means all rows |
c1 | starting column inclusive |
c2 | ending column inclusive, 0 means all columns |
Definition at line 54 of file cppR_manipulation.hpp.
References cppR_assert().
Referenced by FilterConfig::apply(), cbind(), chebbp2(), filter(), Lag(), DataProcess::process(), rbind(), EEGDataStream::read(), CEBL::WindowedSVD::use(), CEBL::Lag::use(), and CEBL::IncrementalSVD::use().
const ublas::matrix_slice<ublas::matrix<T> > cppR::submatrix | ( | const ublas::matrix< T > & | m, |
int | r1, | ||
int | r2, | ||
int | c1, | ||
int | c2 | ||
) |
Identical to submatrix except the return value cannot be assigned. Use this to make a new matrix from a submatrix if the original is const.
m | |
r1 | |
r2 | |
c1 | |
c2 |
Definition at line 99 of file cppR_manipulation.hpp.
References cppR_assert().
void cppR::submatrixAssign | ( | ublas::matrix< T > & | m1, |
int | m1start1, | ||
int | m1end1, | ||
int | m1start2, | ||
int | m1end2, | ||
const ublas::matrix< T > & | m2, | ||
int | m2start1, | ||
int | m2end1, | ||
int | m2start2, | ||
int | m2end2 | ||
) |
Assign submatrix of one matrix to submatrix of another.
Deprecated: Use submatrix instead.
m1 | matrix to assign to |
m1start1 | m1 start row |
m1end1 | m1 end row |
m1start2 | m1 start column |
m1end2 | m1 end column |
m2 | matrix to assign from |
m2start1 | m2 start row |
m2end1 | m2 end row |
m2start2 | m2 start column |
m2end2 | m2 end column |
Definition at line 153 of file cppR_manipulation.hpp.
Referenced by EEGData::splitData().
T cppR::sum | ( | const ublas::vector< T > & | v | ) |
Sum of a vector.
v |
Definition at line 231 of file cppR_stats.hpp.
Referenced by colMeans(), colSums(), frobeniusNorm(), mean(), rowMeans(), rowSums(), CEBL::MSPRT::updateWithProbabilities(), and var().
T cppR::sum | ( | const ublas::matrix< T > & | m | ) |
SvdStruct<T> cppR::svd | ( | const ublas::matrix< T > & | m1 | ) |
Performs the singular value decomposition on specified matrix Returns a structure containing the singular values, and matrices of both left and right singular vectors. cppR::svd uses the lapack gesdd routine.
m1 | general rectangular matrix |
Definition at line 194 of file cppR_math.hpp.
References cppR::SvdStruct< T >::d, cppR::SvdStruct< T >::u, and cppR::SvdStruct< T >::v.
Referenced by rank(), and CEBL::WindowedSVD::use().
ublas::matrix<T> cppR::t | ( | const ublas::matrix< T > & | m | ) |
Transpose matrix.
m |
Definition at line 130 of file cppR_stats.hpp.
Referenced by chebbp2(), localMax(), CEBL::QDA::train(), CEBL::LDA::train(), CEBL::QDA::use(), CEBL::WindowedSVD::use(), CEBL::LDA::use(), and CEBL::max_var::use().
ublas::vector<T> cppR::unique | ( | const ublas::vector< T > & | v | ) |
Returns uniques vector of elements.
v |
Definition at line 176 of file cppR_stats.hpp.
Referenced by FilterConfig::setSelectedComponentsString(), CEBL::QDA::train(), and CEBL::LDA::train().
double cppR::var | ( | const ublas::vector< T > & | v, |
double | m | ||
) |
Variance of a vector.
v | |
m |
Definition at line 409 of file cppR_stats.hpp.
References sum().
Referenced by sd(), CEBL::max_var::use(), and var().
double cppR::var | ( | const ublas::vector< T > & | v | ) |
ublas::vector<T> cppR::vectorRange | ( | T | min, |
T | max | ||
) |
Create a vector with values min, min+1, ..., max.
min | starting value inclusive |
max | ending value inclusive |
Definition at line 312 of file cppR_construction.hpp.
References cppR_assert(), and min().
ublas::vector<T> cppR::vsqrt | ( | const ublas::vector< T > & | v1 | ) |
int cppR::whichMax | ( | const ublas::vector< T > & | v | ) |
Tells which index is the max in a vector.
v |
Definition at line 347 of file cppR_stats.hpp.
References max().
Referenced by RealTimeClassification::timeoutFunction(), CEBL::QDA::use(), and CEBL::LDA::use().
int cppR::whichMin | ( | const ublas::vector< T > & | v | ) |
Tells which index is the min in a vector.
v |
Definition at line 363 of file cppR_stats.hpp.
References min().
void cppR::writeTable | ( | const ublas::matrix< T > & | m, |
string | filename | ||
) |
Writes a matrix as an R-readable table to a file. Load this in R with the read.table function.
m | |
file |
Definition at line 322 of file cppR_utils.hpp.
Referenced by filter(), and CEBL::RController::writeMatrixToTempFile().