CEBL  2.1
Data Structures | Functions
cppR Namespace Reference

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 >
sum (const ublas::vector< T > &v)
template<typename T >
sum (const ublas::matrix< T > &m)
template<typename T >
ublas::vector< T > vsqrt (const ublas::vector< T > &v1)
template<typename T >
min (const ublas::matrix< T > &m)
template<typename T >
min (const ublas::vector< T > &v)
template<typename T >
max (const ublas::matrix< T > &m)
template<typename 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 >
mean (const ublas::vector< T > &v)
template<typename 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)

Function Documentation

template<typename T >
ublas::matrix<T> cppR::apply ( const ublas::matrix< T > &  m,
T(*)(T)  func 
)

Applies a 1 argument function to each value in a matrix.

Parameters:
m
funcfunction to apply
Returns:

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().

template<typename T , typename U >
ublas::matrix<T> cppR::apply ( const ublas::matrix< T > &  m,
T(*)(T, U)  func,
arg2 
)

Applies a 2-argument function to each value in a matrix.

Parameters:
m
funcfunction
arg2second argument to function
Returns:

Definition at line 164 of file cppR_utils.hpp.

template<typename T >
ublas::vector<T> cppR::apply ( const ublas::vector< T > &  m,
T(*)(T)  func 
)

Applies a 1 argument function to each value in a vector.

Parameters:
m
func
Returns:

Definition at line 181 of file cppR_utils.hpp.

template<typename T >
std::vector<T> cppR::asStdVector ( ublas::vector< T >  vec)

Converts a ublas vector to a std vector.

Parameters:
vec
Returns:

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().

template<typename T >
ublas::vector<T> cppR::asUblasVector ( std::vector< T >  vec)

Converts a std vector into a ublas vector.

Parameters:
vecstd vector
Returns:
ublas 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().

template<typename T >
ublas::vector<T> cppR::bind ( ublas::vector< T >  v1,
ublas::vector< T >  v2 
)

Binds two vectors together.

Parameters:
v1size N vector
v2size M vector
Returns:
vector of size N+M

Definition at line 182 of file cppR_construction.hpp.

Referenced by TimeoutThread::timeoutStart(), and RealTimeClassification::trainClassifierThreaded().

template<typename T >
ublas::matrix<T> cppR::cbind ( const ublas::matrix< T > &  m1,
const ublas::matrix< T > &  m2 
)

Attach two matrices together horizontally and return result.

Parameters:
m1size NxM matrix
m2size NxQ matrix
Returns:
size Nx(M+Q) matrix

Definition at line 237 of file cppR_manipulation.hpp.

References cppR_assert(), and submatrix().

Referenced by chebbp2(), filter(), and CEBL::WindowedSVD::use().

template<typename T >
ublas::vector<T> cppR::colMeans ( ublas::matrix< T > &  data)

Creates a vector of means for each column in a matrix.

Parameters:
data
Returns:
means

Definition at line 63 of file cppR_stats.hpp.

References mean(), and sum().

Referenced by CEBL::QDA::train(), and CEBL::LDA::train().

template<typename T >
ublas::vector<T> cppR::colSums ( ublas::matrix< T > &  data)

Creates of vector of sums for each column in a matrix.

Parameters:
data
Returns:
sums

Definition at line 108 of file cppR_stats.hpp.

References sum().

template<typename T >
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).

Parameters:
mmatrix
funcfunction to apply to each column
Returns:
vector of function applied to each column of m

Definition at line 229 of file cppR_utils.hpp.

template<typename T >
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.

Parameters:
mNxM matrix
nNxM matrix
Returns:

Definition at line 94 of file cppR_math.hpp.

Referenced by chebbp2(), CEBL::QDA::use(), and CEBL::LDA::use().

template<typename T >
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.

Parameters:
mNxM matrix
nNxM matrix
Returns:

Definition at line 66 of file cppR_math.hpp.

References cppR_assert().

Referenced by chebbp2(), convolve(), CEBL::LDA::train(), and CEBL::QDA::use().

template<typename T >
ublas::matrix<std::complex<T> > cppR::Conj ( ublas::matrix< std::complex< T > >  m)

Returns complex conjugate of complex matrix.

Parameters:
m
Returns:

Definition at line 333 of file cppR_math.hpp.

Referenced by convolve().

template<typename T >
int cppR::count ( const T &  value,
const ublas::vector< T > &  v 
)

Count occurences of specific value in a vector

Parameters:
value
v
Returns:
number of occurences

Definition at line 197 of file cppR_stats.hpp.

Referenced by createVector(), Session::exists(), EEGTrainingData::getClassVector(), ChannelsConfig::getNumEnabled(), rev(), rowMask(), and CEBL::QDA::train().

template<typename T >
std::vector<bool> cppR::createMask ( value,
ublas::vector< T >  v 
)

Creates a vector of booleans which are true when value equals that index in the matrix.

Parameters:
valuevalue to check
vvector
Returns:
boolean mask of length equal to that of v

Definition at line 196 of file cppR_manipulation.hpp.

Referenced by CEBL::QDA::train(), and CEBL::LDA::train().

template<typename T >
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.

Parameters:
vecvector to read from.
rowsnumber of rows
colsnumber of columns
byrowflag to create matrix by row instead of column
Returns:

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().

template<typename T >
ublas::matrix<T> cppR::createMatrix ( const std::vector< T > &  vec,
int  rows,
int  cols,
bool  byrow = false 
)

Std version of createMatrix1

Parameters:
vec
rows
cols
byrow
Returns:

Definition at line 133 of file cppR_construction.hpp.

References createMatrix().

template<typename T >
ublas::matrix<T> cppR::createMatrix ( value,
int  rows,
int  cols 
)

Create a matrix using a single value for every entry.

Parameters:
valuevalue to place in each entry
rowsnumber of rows to make
colsnumber of cols to make
Returns:

Definition at line 151 of file cppR_construction.hpp.

template<typename T >
ublas::vector<T> cppR::createVector ( const ublas::matrix< T > &  m)

Creates a vector by flattening a specified matrix.

Parameters:
mNxM matrix to convert to vector
Returns:
N * M length vector

Definition at line 40 of file cppR_construction.hpp.

References count().

Referenced by CEBL::QDA::train(), and CEBL::LDA::train().

template<typename T >
ublas::vector<T> cppR::createVector ( const T &  value,
int  size 
)

Create a vector of specified size by repeating value. Same as rep.

Parameters:
valuevalue to repeat
sizesize of resulting vecto
Returns:

Definition at line 61 of file cppR_construction.hpp.

template<typename T >
double cppR::det ( const boost::numeric::ublas::matrix_expression< T > &  m)

Compute determinant of matrix. Uses lu factorization method.

Parameters:
m
Returns:
determinant of matrix

Definition at line 241 of file cppR_math.hpp.

Referenced by CEBL::QDA::train().

template<typename T >
ublas::vector<T> cppR::diag ( const ublas::matrix< T > &  m)

Get the diagonal of a matrix and return it as a vector.

Parameters:
mmatrix to get diagonal from
Returns:
vector of diagonal entries

Definition at line 245 of file cppR_construction.hpp.

Referenced by CEBL::MNF::make(), and solve().

template<typename T >
ublas::matrix<T> cppR::diag ( const ublas::vector< T > &  v)

Create a matrix with diagonal entries taken from specified vector.

Parameters:
vvector to use as diagonal
Returns:
diagonal matrix

Definition at line 264 of file cppR_construction.hpp.

References createMatrix(), and rep().

template<typename T >
ublas::matrix<T> cppR::diag ( const T &  value,
int  size 
)

Creates a square matrix of size 'size' with diagonal entries equal to 'value'.

Parameters:
valuevalue to use as diagonal entry
sizesize of matrix
Returns:
diagonal matrix with value on the diagonal

Definition at line 287 of file cppR_construction.hpp.

References createMatrix(), and rep().

template<typename T >
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.

Parameters:
m1real symmetric matrix
Returns:
eigen struct containing vectors and values

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.

Parameters:
m
inversedo inverse fft instead
Returns:
complex matrix

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 
)

Performs fourier transform of a real matrix. This function simply turns the real matrix into a complex one and then uses fft1.

Parameters:
msee fft1
inversesee fft1
Returns:

Definition at line 430 of file cppR_math.hpp.

References fft().

template<typename T >
double cppR::frobeniusNorm ( ublas::matrix< T >  m)

frobeniusNorm of a matrix.

Computed as: $\displaystyle\sqrt{\sum_{i=0}^n \sum_{j=0}^m M_{i,j}^2} $

Parameters:
mmatrix M of size nXm
Returns:

Definition at line 162 of file cppR_stats.hpp.

References square(), and sum().

template<typename T >
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

Parameters:
data_orig
n_lags
Returns:
lagged matrix

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().

template<typename T >
T cppR::max ( const ublas::matrix< T > &  m)

Max value in a matrix.

Parameters:
m
Returns:

Definition at line 314 of file cppR_stats.hpp.

Referenced by chebbp2(), CEBL::SimpleMax::decideClasses(), CEBL::MSPRT::decideClasses(), RealTimeClassification::timeoutFunction(), and whichMax().

template<typename T >
T cppR::max ( const ublas::vector< T > &  v)

Max value in a vector.

Parameters:
v
Returns:

Definition at line 331 of file cppR_stats.hpp.

template<typename T >
T cppR::mean ( const ublas::vector< T > &  v)

Mean of a vector.

Parameters:
v
Returns:

Definition at line 378 of file cppR_stats.hpp.

References sum().

Referenced by colMeans(), mean(), rowMeans(), and var().

template<typename T >
T cppR::mean ( const ublas::matrix< T > &  m)

Mean of a matrix.

Parameters:
m
Returns:

Definition at line 392 of file cppR_stats.hpp.

References mean(), and sum().

template<typename T >
T cppR::min ( const ublas::matrix< T > &  m)

Min value in a matrix.

Parameters:
m
Returns:

Definition at line 281 of file cppR_stats.hpp.

Referenced by chebbp2(), EEGMonitor::initPlot(), EEGMonitor::reInitPlot(), vectorRange(), and whichMin().

template<typename T >
T cppR::min ( const ublas::vector< T > &  v)

Min value in a vector.

Parameters:
v
Returns:

Definition at line 298 of file cppR_stats.hpp.

template<typename T >
int cppR::ncol ( const ublas::matrix< T > &  m)
template<typename T >
int cppR::nrow ( const ublas::matrix< T > &  m)
template<typename T >
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.

template<typename T >
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.

template<typename T >
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.

template<typename T >
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.

template<typename T >
ublas::matrix<T> cppR::operator/ ( const T &  value,
ublas::matrix< T > &  m1 
)

Definition at line 33 of file cppR_operators.hpp.

template<typename T >
ublas::vector<T> cppR::operator/ ( const T &  value,
ublas::vector< T > &  v1 
)

Definition at line 49 of file cppR_operators.hpp.

template<typename T >
void cppR::printMatrix ( const ublas::matrix< T > &  m)

Prints a matrix to standard output.

Parameters:
m

Definition at line 251 of file cppR_utils.hpp.

template<typename T >
void cppR::printMatrixDim ( const ublas::matrix< T > &  m)

Prints the dimensions of a matrix to standard output.

Parameters:
m

Definition at line 308 of file cppR_utils.hpp.

template<typename T >
void cppR::printVector ( const ublas::vector< T > &  v)

Prints a vector to standard output.

Parameters:
v

Definition at line 272 of file cppR_utils.hpp.

template<typename T >
void cppR::printVector ( const std::vector< T > &  v)

Prints a std vector to standard output.

Parameters:
v

Definition at line 289 of file cppR_utils.hpp.

template<typename T >
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).

Parameters:
m
Returns:
rank of matrix

Definition at line 221 of file cppR_math.hpp.

References cppR::SvdStruct< T >::d, and svd().

template<typename T >
ublas::matrix<T> cppR::rbind ( const ublas::matrix< T > &  m1,
const ublas::matrix< T > &  m2 
)

Attach two matrices together vertically and return result.

Parameters:
m1size MxN matrix
m2size QxN matrix
Returns:
size (M+Q)xN matrix

Definition at line 267 of file cppR_manipulation.hpp.

References cppR_assert(), and submatrix().

Referenced by CEBL::WindowedSVD::use(), and CEBL::PassBand::use().

template<typename T >
ublas::matrix<T> cppR::Re ( ublas::matrix< std::complex< T > >  m)

Returns real portion of a complex matrix.

Parameters:
m
Returns:

Definition at line 316 of file cppR_math.hpp.

Referenced by chebbp2(), and convolve().

template<typename T >
ublas::matrix<T> cppR::readTable ( string  filename)

Reads a matrix table from a file written by R's write.table

Parameters:
file

Definition at line 348 of file cppR_utils.hpp.

References asUblasVector().

template<typename T >
ublas::vector<T> cppR::rep ( const ublas::vector< T > &  vec,
int  n 
)

Repeat specified vector n times into a new vector.

Parameters:
vecvector to repeat
nnumber of times to repeatn
Returns:
vector of size vec.size()*n

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().

template<typename T >
ublas::vector<T> cppR::rep ( const T &  value,
int  n 
)

Repeat a single value n times into a new vector.

Parameters:
value
n
Returns:
vector of repeated value

Definition at line 226 of file cppR_construction.hpp.

template<typename T >
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

Parameters:
m1NxM matrix to reverse
Returns:
(N*m)x1 matrix

Definition at line 297 of file cppR_manipulation.hpp.

References count().

Referenced by filter().

template<typename T >
ublas::vector<T> cppR::rev ( const ublas::vector< T > &  v)

Reverse a vector

Parameters:
v
Returns:
vector reversed

Definition at line 321 of file cppR_manipulation.hpp.

References count().

template<typename T >
ublas::vector<T> cppR::rnorm ( int  n,
double  mean,
double  sd 
)

Creates a vector of n random numbers from a normal distribution.

Parameters:
nnumber to generate
meanmean of distribution
sdstandard deviation of distribution
Returns:
vector of random numbers

Definition at line 74 of file cppR_utils.hpp.

template<typename T >
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).

Parameters:
mmatrix
funcfunction to apply to each row
Returns:
vector of function applied to each row of m

Definition at line 203 of file cppR_utils.hpp.

template<typename T >
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.

Parameters:
mmatrix
maskshould have length equal to number of rows in m
Returns:
new matrix

Definition at line 215 of file cppR_manipulation.hpp.

References count().

Referenced by DataProcess::process(), CEBL::QDA::train(), and CEBL::LDA::train().

template<typename T >
ublas::vector<T> cppR::rowMeans ( ublas::matrix< T > &  data)

Creates a vector of means for each row in a matrix.

Parameters:
data
Returns:
means

Definition at line 40 of file cppR_stats.hpp.

References mean(), and sum().

Referenced by CEBL::MNF::make().

template<typename T >
ublas::vector<T> cppR::rowSums ( ublas::matrix< T > &  data)

Creates a vector of sums for each row in a matrix.

Parameters:
data
Returns:
sums

Definition at line 87 of file cppR_stats.hpp.

References sum().

Referenced by CEBL::LDA::train(), CEBL::QDA::use(), and CEBL::LDA::use().

template<typename T >
ublas::vector<T> cppR::runif ( int  n)

Creates a vector of n random numbers from a uniform distribution.

Parameters:
n
Returns:
vector of random numbers

Definition at line 55 of file cppR_utils.hpp.

template<typename T >
ublas::vector<T> cppR::sample ( ublas::vector< T >  vec)

Randomly samples values in vector.

Parameters:
vec
Returns:
randomized vecto

Definition at line 127 of file cppR_utils.hpp.

template<typename T >
double cppR::sd ( const ublas::vector< T > &  v)

Standard deviation of matrix.

Parameters:
v
Returns:

Definition at line 440 of file cppR_stats.hpp.

References var().

Referenced by sd(), and CEBL::max_var::use().

template<typename T >
ublas::vector<double> cppR::sd ( const ublas::matrix< T > &  m)

Standard deviation of a matrix.

Parameters:
m
Returns:

Definition at line 451 of file cppR_stats.hpp.

References ncol(), and sd().

template<typename T >
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.

Parameters:
m1matrix to solve
Returns:
solved matrix

Definition at line 119 of file cppR_math.hpp.

References diag().

Referenced by chebbp2(), CEBL::MNF::make(), CEBL::QDA::train(), and CEBL::LDA::train().

template<typename T >
ublas::matrix<T> cppR::solve ( const ublas::matrix< T > &  m1,
const ublas::matrix< T > &  m2 
)

Definition at line 144 of file cppR_math.hpp.

template<typename T >
ublas::matrix<T> cppR::square ( const ublas::matrix< T > &  m)

Square each element in matrix.

Parameters:
m
Returns:

Definition at line 214 of file cppR_stats.hpp.

Referenced by frobeniusNorm().

template<typename T >
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)

Parameters:
mmatrix to select from
r1starting row inclusive
r2ending row inclusive, 0 means all rows
c1starting column inclusive
c2ending column inclusive, 0 means all columns
Returns:
matrix slice representing selected submatrix

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().

template<typename T >
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.

Parameters:
m
r1
r2
c1
c2
Returns:

Definition at line 99 of file cppR_manipulation.hpp.

References cppR_assert().

template<typename T >
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.

Parameters:
m1matrix to assign to
m1start1m1 start row
m1end1m1 end row
m1start2m1 start column
m1end2m1 end column
m2matrix to assign from
m2start1m2 start row
m2end1m2 end row
m2start2m2 start column
m2end2m2 end column

Definition at line 153 of file cppR_manipulation.hpp.

Referenced by EEGData::splitData().

template<typename T >
T cppR::sum ( const ublas::vector< T > &  v)

Sum of a vector.

Parameters:
v
Returns:

Definition at line 231 of file cppR_stats.hpp.

Referenced by colMeans(), colSums(), frobeniusNorm(), mean(), rowMeans(), rowSums(), CEBL::MSPRT::updateWithProbabilities(), and var().

template<typename T >
T cppR::sum ( const ublas::matrix< T > &  m)

Sum of a matrix.

Parameters:
m
Returns:

Definition at line 246 of file cppR_stats.hpp.

template<typename T >
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.

Parameters:
m1general rectangular matrix
Returns:

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().

template<typename T >
ublas::matrix<T> cppR::t ( const ublas::matrix< T > &  m)

Transpose matrix.

Parameters:
m
Returns:

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().

template<typename T >
ublas::vector<T> cppR::unique ( const ublas::vector< T > &  v)

Returns uniques vector of elements.

Parameters:
v
Returns:
unique elements

Definition at line 176 of file cppR_stats.hpp.

Referenced by FilterConfig::setSelectedComponentsString(), CEBL::QDA::train(), and CEBL::LDA::train().

template<typename T >
double cppR::var ( const ublas::vector< T > &  v,
double  m 
)

Variance of a vector.

Parameters:
v
m
Returns:

Definition at line 409 of file cppR_stats.hpp.

References sum().

Referenced by sd(), CEBL::max_var::use(), and var().

template<typename T >
double cppR::var ( const ublas::vector< T > &  v)

Variance of a vector.

Parameters:
v
Returns:

Definition at line 428 of file cppR_stats.hpp.

References mean(), and var().

template<typename T >
ublas::vector<T> cppR::vectorRange ( min,
max 
)

Create a vector with values min, min+1, ..., max.

Parameters:
minstarting value inclusive
maxending value inclusive
Returns:

Definition at line 312 of file cppR_construction.hpp.

References cppR_assert(), and min().

template<typename T >
ublas::vector<T> cppR::vsqrt ( const ublas::vector< T > &  v1)

Square root of vector.

Parameters:
v1
Returns:

Definition at line 263 of file cppR_stats.hpp.

template<typename T >
int cppR::whichMax ( const ublas::vector< T > &  v)

Tells which index is the max in a vector.

Parameters:
v
Returns:

Definition at line 347 of file cppR_stats.hpp.

References max().

Referenced by RealTimeClassification::timeoutFunction(), CEBL::QDA::use(), and CEBL::LDA::use().

template<typename T >
int cppR::whichMin ( const ublas::vector< T > &  v)

Tells which index is the min in a vector.

Parameters:
v
Returns:

Definition at line 363 of file cppR_stats.hpp.

References min().

template<typename T >
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.

Parameters:
m
file

Definition at line 322 of file cppR_utils.hpp.

Referenced by filter(), and CEBL::RController::writeMatrixToTempFile().