Vespucci  1.0.0
Vespucci::Math Namespace Reference

A namespace for math functions relating to linear least squares regression. More...

Namespaces

 Baseline
 
 Clustering
 
 DimensionReduction
 A namespace for math functions relating to dimension reduction.
 
 LinLeastSq
 
 NonLinLeastSq
 
 Normalization
 A namespace for math functions relating to normalization.
 
 PeakFinding
 A namespace for math functions relating to peak detection and counting.
 
 Quantification
 A namespace for math functions relating to peak quantification.
 
 Smoothing
 
 Stats
 
 Transform
 

Classes

class  DistanceMetricWrapper
 
class  KMeansWrapper
 The KMeansWrapper class mlpack relies heavily on template metaprogramming. This means that you only need to compile what you actually use. But Vespucci must be precompiled with all possible options availible at runtime. Here, we instantiate supported combinations of template parameters for the kmeans class in mlpack. More...
 

Functions

VESPUCCI_EXPORT arma::uword LocalMaximum (const arma::vec &X, double &value)
 Vespucci::Math::LocalMaximum. More...
 
VESPUCCI_EXPORT arma::uword LocalMaximum (const arma::vec &dX, const arma::vec &d2X, double &value)
 
VESPUCCI_EXPORT arma::uword LocalMaximum (const arma::vec &X, const arma::vec &dX, const arma::vec &d2X, double &value)
 Vespucci::Math::LocalMaximum. More...
 
VESPUCCI_EXPORT arma::uword LocalMinimum (const arma::mat &X, double &value)
 Vespucci::Math::LocalMinimum. More...
 
VESPUCCI_EXPORT arma::uword LocalMinimum (const arma::vec &dX, const arma::vec &d2X, double &value)
 
VESPUCCI_EXPORT arma::uword LocalMinimum (const arma::vec &X, const arma::vec &dX, const arma::mat &d2X, double &value)
 Vespucci::Math::LocalMinimum. More...
 
VESPUCCI_EXPORT arma::sp_mat LocalMaxima (const arma::mat &X)
 Vespucci::Math::LocalMaxima. More...
 
VESPUCCI_EXPORT arma::sp_mat LocalMaxima (const arma::mat &X, const arma::mat &dX, const arma::mat &d2X)
 Vespucci::Math::LocalMaxima. More...
 
VESPUCCI_EXPORT arma::sp_mat LocalMinima (const arma::mat &X)
 Vespucci::Math::LocalMinima. More...
 
VESPUCCI_EXPORT arma::sp_mat LocalMinima (const arma::mat &X, const arma::mat &dX, const arma::mat &d2X)
 Vespucci::Math::LocalMinima. More...
 
VESPUCCI_EXPORT arma::sp_mat LocalMinimaWindow (const arma::mat &X, const int window_size)
 Vespucci::Math::LocalMinimaWindow. More...
 
VESPUCCI_EXPORT arma::sp_mat LocalMaximaWindow (const arma::mat &X, const int window_size)
 Vespucci::Math::LocalMaximaWindow "Cleans" local maximum by window search to remove extraneous values. More...
 
VESPUCCI_EXPORT arma::sp_mat LocalMinimaCWT (arma::mat coefs, arma::uvec scales, arma::uword min_window_size, double amplitude_threshold)
 
VESPUCCI_EXPORT arma::sp_mat LocalMaximaCWT (arma::mat coefs, arma::uvec scales, arma::uword min_window_size)
 
VESPUCCI_EXPORT double quantile (arma::vec &data, double probs)
 
VESPUCCI_EXPORT arma::vec ExtendToNextPow (arma::vec X, arma::uword n)
 
VESPUCCI_EXPORT arma::uword NextPow (arma::uword number, arma::uword power)
 
VESPUCCI_EXPORT arma::mat spdiags (arma::mat B, arma::ivec d, arma::uword m, arma::uword n)
 spdiags analgous to the Octave/arma::matLAB function A = spdiags(B, d, m, n). More...
 
VESPUCCI_EXPORT arma::mat orth (arma::mat X)
 orth Returns an orthonormal basis of the range space of A More...
 
VESPUCCI_EXPORT arma::uword min (arma::uword a, arma::uword b)
 Vespucci::Math::min. More...
 
VESPUCCI_EXPORT arma::uword max (arma::uword a, arma::uword b)
 Vespucci::Math::max. More...
 
VESPUCCI_EXPORT void position (arma::uword index, arma::uword n_rows, arma::uword n_cols, arma::uword &i, arma::uword &j)
 Vespucci::Math::position Find row and column numbers for index. More...
 
VESPUCCI_EXPORT arma::umat to_row_column (arma::uvec indices, arma::uword n_rows, arma::uword n_cols)
 
VESPUCCI_EXPORT double RecalculateAverage (double new_value, double old_average, double old_count)
 Vespucci::Math::RecalculateAverage Recalculate the average value when a new value is added to a list for which only the previous means, stddevs and counts are known. More...
 
VESPUCCI_EXPORT double RecalculateStdDev (double new_value, double old_mean, double old_stddev, double old_count)
 Vespucci::Math::RecalculateStdDev Recalculate a standard deviation when a new value is added to a list for which only the previous means, stddevs and counts are known. More...
 
VESPUCCI_EXPORT arma::umat GetClosestValues (arma::vec query, arma::vec target, const arma::uword k=5)
 Vespucci::Math::GetClosestValues. More...
 
VESPUCCI_EXPORT double CalcPoly (const double x, const arma::vec &coefs)
 Vespucci::Math::CalcPoly Calculate the value of a polynomial at particular point. More...
 
VESPUCCI_EXPORT arma::vec RepresentativeSpectrum (const arma::mat &spectra, arma::uword &index, std::string metric_name="euclidean", std::string center="centroid")
 Vespucci::Math::RepresentativeSpectrum. More...
 
VESPUCCI_EXPORT arma::vec WavelengthToFrequency (const arma::vec &x, double freq_factor, double wl_factor)
 Vespucci::Math::WavelengthToFrequency. More...
 
VESPUCCI_EXPORT arma::vec FrequencyToWavelength (const arma::vec &x, double wl_factor, double freq_factor)
 Vespucci::Math::FrequencyToWavelength. More...
 
VESPUCCI_EXPORT arma::vec FrequencyToEnergy (const arma::vec &x, double energy_factor, double freq_factor)
 Vespucci::Math::FrequencyToEnergy. More...
 
VESPUCCI_EXPORT arma::vec EnergyToFrequency (const arma::vec &x, double freq_factor, double energy_factor)
 Vespucci::Math::EnergyToFrequency. More...
 
VESPUCCI_EXPORT arma::vec WavenumberToFrequency (const arma::vec &x, double freq_factor, double wn_factor)
 Vespucci::Math::WavenumberToFrequency. More...
 
VESPUCCI_EXPORT arma::vec FrequencyToWavenumber (const arma::vec &x, double wn_factor, double freq_factor)
 Vespucci::Math::FrequencyToWavenumber. More...
 
VESPUCCI_EXPORT arma::vec WavenumberToWavelength (const arma::vec &x, double wn_factor, double wl_factor)
 Vespucci::Math::WavenumberToWavelength. More...
 
VESPUCCI_EXPORT arma::vec WavelengthToWavenumber (const arma::vec &x, double wl_factor, double wn_factor)
 Vespucci::Math::WavelengthToWavenumber. More...
 
VESPUCCI_EXPORT arma::vec WavelengthToEnergy (const arma::vec &x, double energy_factor, double wl_factor)
 Vespucci::Math::WavelengthToEnergy. More...
 
VESPUCCI_EXPORT arma::vec EnergyToWavelength (const arma::vec &x, double wl_factor, double energy_factor)
 Vespucci::Math::EnergyToWavelength. More...
 
VESPUCCI_EXPORT arma::vec EnergyToWavenumber (const arma::vec &x, double wn_factor, double energy_factor)
 Vespucci::Math::EnergyToWavenumber. More...
 
VESPUCCI_EXPORT arma::vec WavenumberToEnergy (const arma::vec &x, double energy_factor, double wn_factor)
 Vespucci::Math::WavenumberToEnergy. More...
 
VESPUCCI_EXPORT bool AreEqual (const arma::vec &a, const arma::vec &b)
 AreEqual. More...
 
VESPUCCI_EXPORT bool IsMonotonic (const arma::vec &x)
 IsMonotonic. More...
 
VESPUCCI_EXPORT bool IsIncreasing (const arma::vec &x)
 IsIncreasing. More...
 
VESPUCCI_EXPORT arma::cx_vec cx_zeros (arma::uword n)
 Vespucci::Math::cx_zeros. More...
 
VESPUCCI_EXPORT arma::cx_mat cx_zeros (arma::uword m, arma::uword n)
 Vespucci::Math::cx_zeros. More...
 
VESPUCCI_EXPORT arma::uword ClosestIndex (double value, const arma::vec &vector)
 Vespucci::Math::ClosestIndex. More...
 
VESPUCCI_EXPORT arma::uvec Intersection (arma::uvec &x, arma::uvec &y)
 Vespucci::Math::Intersection. More...
 
VESPUCCI_EXPORT double CalculateRSquared (const arma::vec &data, const arma::vec &fit, arma::vec &residuals)
 Vespucci::Math::CalculateRSquared. More...
 
VESPUCCI_EXPORT arma::mat SafeRows (const arma::mat &x, arma::uword a, arma::uword b)
 Vespucci::Math::SafeRows. More...
 
template<typename T >
conv_fft (const T &A, const T &B, std::string type)
 
template<typename T >
rotate (const T &X, arma::uword shift_by, bool slide_back=true)
 
template<typename T >
diff (const T &X, arma::uword deriv_order=1)
 Vespucci::Math::diff. More...
 

Detailed Description

A namespace for math functions relating to linear least squares regression.

A namespace for math functions.

:::LinLeastSq

Function Documentation

bool Vespucci::Math::AreEqual ( const arma::vec &  a,
const arma::vec &  b 
)

AreEqual.

Parameters
a
b
Returns
Whether or not all elements in the two vectors are equal

Definition at line 858 of file accessory.cpp.

double Vespucci::Math::CalcPoly ( const double  x,
const arma::vec &  coefs 
)

Vespucci::Math::CalcPoly Calculate the value of a polynomial at particular point.

Parameters
xThe value at which to evaluate a polynomial.
coefsThe coefficients of the polynomial ordered from constant to highest order
Returns
The value of the polynomial at x

Definition at line 599 of file accessory.cpp.

double Vespucci::Math::CalculateRSquared ( const arma::vec &  data,
const arma::vec &  fit,
arma::vec &  residuals 
)

Vespucci::Math::CalculateRSquared.

Parameters
data
fit
residuals
Returns
calcuate residuals and R-squared from fit fit to data data.

Definition at line 1008 of file accessory.cpp.

arma::uword Vespucci::Math::ClosestIndex ( double  value,
const arma::vec &  vector 
)

Vespucci::Math::ClosestIndex.

Parameters
value
vector
Returns
Find the index of value in vector closest to the specified value

Definition at line 932 of file accessory.cpp.

template<typename T >
T Vespucci::Math::conv_fft ( const T &  A,
const T &  B,
std::string  type 
)

Definition at line 102 of file accessory_impl.h.

arma::cx_vec Vespucci::Math::cx_zeros ( arma::uword  n)

Vespucci::Math::cx_zeros.

Parameters
n
Returns

Definition at line 921 of file accessory.cpp.

arma::cx_mat Vespucci::Math::cx_zeros ( arma::uword  m,
arma::uword  n 
)

Vespucci::Math::cx_zeros.

Parameters
m
n
Returns
]

Definition at line 911 of file accessory.cpp.

template<typename T >
T Vespucci::Math::diff ( const T &  X,
arma::uword  deriv_order = 1 
)

Vespucci::Math::diff.

Parameters
XA vector represetning a signal or a arma::matrix where each column is a signal
deriv_orderThe derivative order to calculate
Returns
The deriv_order-th derivative of X, a vector with deriv_order fewer elements than X.

Perform arithmetic differentiation of a vector or arma::matrix (if X is a arma::matrix, the differentiation is performed to all the columns).

Definition at line 47 of file accessory_impl.h.

arma::vec Vespucci::Math::EnergyToFrequency ( const arma::vec &  x,
double  freq_factor,
double  energy_factor 
)

Vespucci::Math::EnergyToFrequency.

Parameters
x
freq_factor
energy_factor
Returns

Definition at line 657 of file accessory.cpp.

arma::vec Vespucci::Math::EnergyToWavelength ( const arma::vec &  x,
double  wl_factor,
double  energy_factor 
)

Vespucci::Math::EnergyToWavelength.

Parameters
x
wl_factor
energy_factor
Returns

Definition at line 746 of file accessory.cpp.

arma::vec Vespucci::Math::EnergyToWavenumber ( const arma::vec &  x,
double  wn_factor,
double  energy_factor 
)

Vespucci::Math::EnergyToWavenumber.

Parameters
x
wn_factor
energy_factor
Returns

Definition at line 760 of file accessory.cpp.

arma::vec Vespucci::Math::ExtendToNextPow ( arma::vec  X,
arma::uword  n 
)

Definition at line 259 of file accessory.cpp.

arma::vec Vespucci::Math::FrequencyToEnergy ( const arma::vec &  x,
double  energy_factor,
double  freq_factor 
)

Vespucci::Math::FrequencyToEnergy.

Parameters
x
energy_factor
freq_factor
Returns

Definition at line 643 of file accessory.cpp.

arma::vec Vespucci::Math::FrequencyToWavelength ( const arma::vec &  x,
double  wl_factor,
double  freq_factor 
)

Vespucci::Math::FrequencyToWavelength.

Parameters
x
wl_factor
freq_factor
Returns

Definition at line 629 of file accessory.cpp.

arma::vec Vespucci::Math::FrequencyToWavenumber ( const arma::vec &  x,
double  wn_factor,
double  freq_factor 
)

Vespucci::Math::FrequencyToWavenumber.

Parameters
x
wn_factor
freq_factor
Returns

Definition at line 686 of file accessory.cpp.

arma::umat Vespucci::Math::GetClosestValues ( arma::vec  query,
arma::vec  target,
const arma::uword  k = 5 
)

Vespucci::Math::GetClosestValues.

Parameters
query
target
k
Returns
The indices of the k values in target closest to each value in query k should be odd in case query and target contain equal values

Definition at line 576 of file accessory.cpp.

arma::uvec Vespucci::Math::Intersection ( arma::uvec &  x,
arma::uvec &  y 
)

Vespucci::Math::Intersection.

Parameters
x
y
Returns
Find the intersection between two sets of indices (the values in common between the two).

Definition at line 990 of file accessory.cpp.

bool Vespucci::Math::IsIncreasing ( const arma::vec &  x)

IsIncreasing.

Parameters
x
Returns

Definition at line 894 of file accessory.cpp.

bool Vespucci::Math::IsMonotonic ( const arma::vec &  x)

IsMonotonic.

Parameters
x
Returns

Definition at line 877 of file accessory.cpp.

arma::sp_mat Vespucci::Math::LocalMaxima ( const arma::mat &  X)

Vespucci::Math::LocalMaxima.

Parameters
XA matrix with signals as columns
Returns
A sparse matrix containing the value of each local maximum at the appropriate position. Find the local maxima of a matrix of signals using the first and second derivative tests. Works best with smooth signals (like CWT coeffs)

Definition at line 294 of file accessory.cpp.

arma::sp_mat Vespucci::Math::LocalMaxima ( const arma::mat &  X,
const arma::mat &  dX,
const arma::mat &  d2X 
)

Vespucci::Math::LocalMaxima.

Parameters
XA matrix of signals
dXA matrix of first derivatives of signals (numerical, S-G, wavelet, etc)
d2XA matrix of second derivatives of signals (numerical, S-G, wavelet, etc).
Returns

Definition at line 317 of file accessory.cpp.

arma::sp_mat Vespucci::Math::LocalMaximaCWT ( arma::mat  coefs,
arma::uvec  scales,
arma::uword  min_window_size 
)

Definition at line 780 of file accessory.cpp.

arma::sp_mat Vespucci::Math::LocalMaximaWindow ( const arma::mat &  X,
const int  window_size 
)

Vespucci::Math::LocalMaximaWindow "Cleans" local maximum by window search to remove extraneous values.

Parameters
X
window_size
Returns

Definition at line 830 of file accessory.cpp.

arma::uword Vespucci::Math::LocalMaximum ( const arma::vec &  X,
double &  value 
)

Vespucci::Math::LocalMaximum.

Parameters
X
value
Returns

Definition at line 30 of file accessory.cpp.

VESPUCCI_EXPORT arma::uword Vespucci::Math::LocalMaximum ( const arma::vec &  dX,
const arma::vec &  d2X,
double &  value 
)
arma::uword Vespucci::Math::LocalMaximum ( const arma::vec &  X,
const arma::vec &  dX,
const arma::vec &  d2X,
double &  value 
)

Vespucci::Math::LocalMaximum.

Parameters
X
dX
d2X
value
Returns

Definition at line 54 of file accessory.cpp.

arma::sp_mat Vespucci::Math::LocalMinima ( const arma::mat &  X)

Vespucci::Math::LocalMinima.

Parameters
X
Returns

Definition at line 378 of file accessory.cpp.

arma::sp_mat Vespucci::Math::LocalMinima ( const arma::mat &  X,
const arma::mat &  dX,
const arma::mat &  d2X 
)

Vespucci::Math::LocalMinima.

Parameters
X
dX
d2X
Returns

Definition at line 401 of file accessory.cpp.

VESPUCCI_EXPORT arma::sp_mat Vespucci::Math::LocalMinimaCWT ( arma::mat  coefs,
arma::uvec  scales,
arma::uword  min_window_size,
double  amplitude_threshold 
)
arma::sp_mat Vespucci::Math::LocalMinimaWindow ( const arma::mat &  X,
const int  window_size 
)

Vespucci::Math::LocalMinimaWindow.

Parameters
X
window_size
Returns

Definition at line 801 of file accessory.cpp.

arma::uword Vespucci::Math::LocalMinimum ( const arma::mat &  X,
double &  value 
)

Vespucci::Math::LocalMinimum.

Parameters
X
value
Returns

Definition at line 77 of file accessory.cpp.

VESPUCCI_EXPORT arma::uword Vespucci::Math::LocalMinimum ( const arma::vec &  dX,
const arma::vec &  d2X,
double &  value 
)
arma::uword Vespucci::Math::LocalMinimum ( const arma::vec &  X,
const arma::vec &  dX,
const arma::mat &  d2X,
double &  value 
)

Vespucci::Math::LocalMinimum.

Parameters
X
dX
d2X
value
Returns

Definition at line 103 of file accessory.cpp.

arma::uword Vespucci::Math::max ( arma::uword  a,
arma::uword  b 
)

Vespucci::Math::max.

Parameters
a
b
Returns
std::max stopped working with arma::uwords for some reason, so I made a max function It might be a better idea to just cast uwords to int and use std::max

Definition at line 237 of file accessory.cpp.

arma::uword Vespucci::Math::min ( arma::uword  a,
arma::uword  b 
)

Vespucci::Math::min.

Parameters
a
b
Returns
std::min stopped working with arma::uwords for some reason, so I made a min function It might be a better idea to just cast uwords to int and use std::min

Definition at line 249 of file accessory.cpp.

arma::uword Vespucci::Math::NextPow ( arma::uword  number,
arma::uword  power 
)

Definition at line 281 of file accessory.cpp.

arma::mat Vespucci::Math::orth ( arma::mat  X)

orth Returns an orthonormal basis of the range space of A

Parameters
Xarma::matrix
Returns
a arma::matrix whose columns form an orthonormal basis for X This function was written before MLPACK was used. The MLPACK method mlpack::math::Orthogonalize does the same thing

Definition at line 208 of file accessory.cpp.

void Vespucci::Math::position ( arma::uword  index,
arma::uword  n_rows,
arma::uword  n_cols,
arma::uword &  i,
arma::uword &  j 
)

Vespucci::Math::position Find row and column numbers for index.

Parameters
index
n_rowsNumber of rows
n_colsNumber of columns
iRow number
jColumn number

Definition at line 469 of file accessory.cpp.

double Vespucci::Math::quantile ( arma::vec &  data,
double  probs 
)

Definition at line 503 of file accessory.cpp.

double Vespucci::Math::RecalculateAverage ( double  new_value,
double  old_average,
double  old_count 
)

Vespucci::Math::RecalculateAverage Recalculate the average value when a new value is added to a list for which only the previous means, stddevs and counts are known.

Parameters
new_value
old_average
old_count
Returns

Definition at line 535 of file accessory.cpp.

double Vespucci::Math::RecalculateStdDev ( double  new_value,
double  old_mean,
double  old_stddev,
double  old_count 
)

Vespucci::Math::RecalculateStdDev Recalculate a standard deviation when a new value is added to a list for which only the previous means, stddevs and counts are known.

Parameters
new_value
old_mean
old_stddev
old_count
Returns

Definition at line 552 of file accessory.cpp.

arma::vec Vespucci::Math::RepresentativeSpectrum ( const arma::mat &  spectra,
arma::uword &  index,
std::string  metric_name = "euclidean",
std::string  center_type = "centroid" 
)

Vespucci::Math::RepresentativeSpectrum.

Parameters
spectra
metricDistance metric
center
Returns

Definition at line 953 of file accessory.cpp.

template<typename T >
T Vespucci::Math::rotate ( const T &  X,
arma::uword  shift_by,
bool  slide_back = true 
)

Definition at line 65 of file accessory_impl.h.

arma::mat Vespucci::Math::SafeRows ( const arma::mat &  x,
arma::uword  a,
arma::uword  b 
)

Vespucci::Math::SafeRows.

Parameters
x
a
b
Returns
An alternative to arma::mat::rows that allows a and b to be equal, a to be larger than b, and the range to be greater than the end of the vector (all things that are allowed in R). This makes translating from R easier.

Definition at line 1030 of file accessory.cpp.

arma::mat Vespucci::Math::spdiags ( arma::mat  B,
arma::ivec  d,
arma::uword  m,
arma::uword  n 
)

spdiags analgous to the Octave/arma::matLAB function A = spdiags(B, d, m, n).

Parameters
Ba arma::matrix containing the new diagonal vectors as columns
da vector containing the row numbers to set. The first column vector of B corresponds to the first entry in d.
mthe number of rows of the output arma::matrix
nthe number of columns of the output arma::matrix
Returns
a m by n sparase arma::matrix with the columns of B as diagonals A translation of the Octave/arma::matLAB function A = spdiags(B, d, m, n). For subdiagonals (entries of d < 0) vectors are truncated at the end when they are longer than the target diagonal. For superdiagonals, vectors are truncated at the beginning when they are longer than the target diagonal.

Definition at line 137 of file accessory.cpp.

arma::umat Vespucci::Math::to_row_column ( arma::uvec  indices,
arma::uword  n_rows,
arma::uword  n_cols 
)

Definition at line 488 of file accessory.cpp.

arma::vec Vespucci::Math::WavelengthToEnergy ( const arma::vec &  x,
double  energy_factor,
double  wl_factor 
)

Vespucci::Math::WavelengthToEnergy.

Parameters
x
energy_factor
wl_factor
Returns

Definition at line 731 of file accessory.cpp.

arma::vec Vespucci::Math::WavelengthToFrequency ( const arma::vec &  x,
double  freq_factor,
double  wl_factor 
)

Vespucci::Math::WavelengthToFrequency.

Parameters
x
freq_factor
wl_factor
Returns

Definition at line 614 of file accessory.cpp.

arma::vec Vespucci::Math::WavelengthToWavenumber ( const arma::vec &  x,
double  wl_factor,
double  wn_factor 
)

Vespucci::Math::WavelengthToWavenumber.

Parameters
x
wl_factor
wn_factor
Returns

Definition at line 716 of file accessory.cpp.

arma::vec Vespucci::Math::WavenumberToEnergy ( const arma::vec &  x,
double  energy_factor,
double  wn_factor 
)

Vespucci::Math::WavenumberToEnergy.

Parameters
x
energy_factor
wn_factor
Returns

Definition at line 773 of file accessory.cpp.

arma::vec Vespucci::Math::WavenumberToFrequency ( const arma::vec &  x,
double  freq_factor,
double  wn_factor 
)

Vespucci::Math::WavenumberToFrequency.

Parameters
x
freq_factor
wn_factor
Returns

Definition at line 671 of file accessory.cpp.

arma::vec Vespucci::Math::WavenumberToWavelength ( const arma::vec &  x,
double  wn_factor,
double  wl_factor 
)

Vespucci::Math::WavenumberToWavelength.

Parameters
x
wn_factor
wl_factor
Returns

Definition at line 701 of file accessory.cpp.