eisgenerator 2.1.x
Math

Various math functions performed on eisgenerator types. More...

Functions

void eis::mulitplyAdd (std::vector< eis::DataPoint > &data, fvalue mult, fvalue add)
std::complex< fvalue > eis::absGrad (const std::vector< eis::DataPoint > &data, size_t index)
 Calculates the element wise absolute gradient at the given point of the data given.
fvalue eis::grad (const std::vector< fvalue > &data, const std::vector< fvalue > &omega, size_t index)
 Calculates derivative at the given point of the data given.
std::complex< fvalue > eis::grad (const std::vector< eis::DataPoint > &data, size_t index)
 Calculates the gradient at the given point of the data given.
fvalue eis::mean (const std::vector< fvalue > &data)
 Calculates the mean of the given data.
std::complex< fvalue > eis::mean (const std::vector< eis::DataPoint > &data)
 Calculates the mean of the given data.
fvalue eis::median (std::vector< fvalue > data)
 Calculates the median of the given data.
std::complex< fvalue > eis::median (const std::vector< eis::DataPoint > &data)
 Calculates the median of the given data.
void eis::difference (std::vector< eis::DataPoint > &a, const std::vector< eis::DataPoint > &b)
 Calculates the difference between two spectra.
std::vector< eis::DataPoint > eis::rescale (const std::vector< eis::DataPoint > &data, size_t outputSize)
 Resamples the data to the given amount of points.
fvalue eis::pearsonCorrelation (const std::vector< eis::DataPoint > &data)
 Calculates the Pearson correlation between the imaginary and the real part of the data.
fvalue eis::nonConstantScore (const std::vector< eis::DataPoint > &data)
fvalue eis::nyquistAreaVariance (const std::vector< eis::DataPoint > &data, eis::DataPoint *centroid=nullptr)
 Calculates the variance of the distance of the data from a centroid in the nyquist plane.
fvalue eis::maximumNyquistJump (const std::vector< eis::DataPoint > &data)
 Finds the maximum distance between subsequent points in the data in the nyquist plane.
void eis::noise (std::vector< eis::DataPoint > &data, double amplitude, bool relative)
 Adds white noise to the data.
void eis::removeDuplicates (std::vector< eis::DataPoint > &data)
 Removes duplicate data points from the data.
bool eis::fvalueEq (fvalue a, fvalue b, unsigned int ulp=4)
 Checks two fvalues for equality.
std::vector< eis::DataPoint > eis::fitToFrequencies (std::vector< fvalue > omegas, const std::vector< eis::DataPoint > &data, bool linearExtrapolation=false)
 This function resamples, extrapolates and interpolates to fit the data given to the frequencies also given.
fvalue eis::eisDistance (const std::vector< eis::DataPoint > &a, const std::vector< eis::DataPoint > &b)
 Returns the mean l2 element wise distance of the given spectra.
fvalue eis::eisNyquistDistance (const std::vector< eis::DataPoint > &a, const std::vector< eis::DataPoint > &b)
 Returns the mean distance of the points in a to the linearly interpolated nyquist curve of b.

Detailed Description

Various math functions performed on eisgenerator types.

Function Documentation

◆ absGrad()

std::complex< fvalue > eis::absGrad ( const std::vector< eis::DataPoint > & data,
size_t index )

Calculates the element wise absolute gradient at the given point of the data given.

Parameters
dataThe data to calculate the gradient on.
indexThe position in the data to calculate the gradient at.
Returns
The element wise absolute gradient abs(re(grad(a)))+abs(im(grad(a)))i.

References absGrad().

Referenced by absGrad().

◆ difference()

void eis::difference ( std::vector< eis::DataPoint > & a,
const std::vector< eis::DataPoint > & b )

Calculates the difference between two spectra.

this function calculates an element wise a = a-b and ingores omega

Parameters
aThe first operand, where b is subtracted
bThe second operand that is subtracted from the first, must be the same size as a

References difference().

Referenced by difference().

◆ eisDistance()

fvalue eis::eisDistance ( const std::vector< eis::DataPoint > & a,
const std::vector< eis::DataPoint > & b )

Returns the mean l2 element wise distance of the given spectra.

This function will be moved to the math API in the future.

Parameters
aThe first set of points.
bThe second set of points, must contain the same number of elements as a
Returns
The mean l2 distance.

References eisDistance().

Referenced by eisDistance().

◆ eisNyquistDistance()

fvalue eis::eisNyquistDistance ( const std::vector< eis::DataPoint > & a,
const std::vector< eis::DataPoint > & b )

Returns the mean distance of the points in a to the linearly interpolated nyquist curve of b.

This function will be moved to the math API in the future.

This implementation is quite slow.

Parameters
aThe first set of points.
bThe second set of points.
Returns
The mean nyquist distance.

References eisNyquistDistance().

Referenced by eisNyquistDistance().

◆ fitToFrequencies()

std::vector< eis::DataPoint > eis::fitToFrequencies ( std::vector< fvalue > omegas,
const std::vector< eis::DataPoint > & data,
bool linearExtrapolation = false )

This function resamples, extrapolates and interpolates to fit the data given to the frequencies also given.

Data is resampled to the target size, interpolation for data points is performed using linear interpolation, extrapolation is performed using linear or base 10 logarithmic extrapolation.

Parameters
omegasThe frequencies to resample the data to.
dataThe data to resample.
linearExtrapolationtrue if linear extrapolation is to be performed, otherwise base 10 logarithmic extrapolation is used.
Returns
The resampled data.

References fitToFrequencies().

Referenced by fitToFrequencies().

◆ fvalueEq()

bool eis::fvalueEq ( fvalue a,
fvalue b,
unsigned int ulp = 4 )

Checks two fvalues for equality.

Equality is considered given when the values are within ulp epsilons at the magnitude of the sum of operands.

Parameters
athe first value to compare
bthe second value to compare
Returns
true if equal, false if unequal

References fvalueEq().

Referenced by fvalueEq().

◆ grad() [1/2]

std::complex< fvalue > eis::grad ( const std::vector< eis::DataPoint > & data,
size_t index )

Calculates the gradient at the given point of the data given.

Parameters
dataThe data to calculate the gradient on.
indexThe position in the data to calculate the gradient at.
Returns
The gradient.

References grad().

◆ grad() [2/2]

fvalue eis::grad ( const std::vector< fvalue > & data,
const std::vector< fvalue > & omega,
size_t index )

Calculates derivative at the given point of the data given.

Parameters
dataThe data to calculate the gradient on.
indexThe position in the data to calculate the gradient at.
Returns
The derivative.

References grad().

Referenced by grad(), and grad().

◆ maximumNyquistJump()

fvalue eis::maximumNyquistJump ( const std::vector< eis::DataPoint > & data)

Finds the maximum distance between subsequent points in the data in the nyquist plane.

Parameters
dataThe data to use.
Returns
The largest distance.

References maximumNyquistJump().

Referenced by maximumNyquistJump().

◆ mean() [1/2]

std::complex< fvalue > eis::mean ( const std::vector< eis::DataPoint > & data)

Calculates the mean of the given data.

Parameters
dataThe data to calculate the mean of.
Returns
The mean

References mean().

◆ mean() [2/2]

fvalue eis::mean ( const std::vector< fvalue > & data)

Calculates the mean of the given data.

Parameters
dataThe data to calculate the mean of.
Returns
The mean

References mean().

Referenced by mean(), and mean().

◆ median() [1/2]

std::complex< fvalue > eis::median ( const std::vector< eis::DataPoint > & data)

Calculates the median of the given data.

Parameters
dataThe data to calculate the median of.
Returns
The median.

References median().

◆ median() [2/2]

fvalue eis::median ( std::vector< fvalue > data)

Calculates the median of the given data.

Parameters
dataThe data to calculate the median of.
Returns
The median.

References median().

Referenced by median(), and median().

◆ noise()

void eis::noise ( std::vector< eis::DataPoint > & data,
double amplitude,
bool relative )

Adds white noise to the data.

Parameters
dataThe data to add noise to.
amplitudeThe amplitude of the noise.
relativeIf true, the amplitude will be taken as relative to the magnitude of the data, otherwise it will be taken as an absolute value.

References noise().

Referenced by noise().

◆ nyquistAreaVariance()

fvalue eis::nyquistAreaVariance ( const std::vector< eis::DataPoint > & data,
eis::DataPoint * centroid = nullptr )

Calculates the variance of the distance of the data from a centroid in the nyquist plane.

Parameters
dataThe data to calculate on.
centroidThe centroid to use, if nullptr is passed here, the mean of the data will be used as the centroid.
Returns
The variance.

References nyquistAreaVariance().

Referenced by nyquistAreaVariance().

◆ pearsonCorrelation()

fvalue eis::pearsonCorrelation ( const std::vector< eis::DataPoint > & data)

Calculates the Pearson correlation between the imaginary and the real part of the data.

Parameters
dataData to calculate the Pearson correlation on.
Returns
the Pearson correlation coefficient.

References pearsonCorrelation().

Referenced by pearsonCorrelation().

◆ removeDuplicates()

void eis::removeDuplicates ( std::vector< eis::DataPoint > & data)

Removes duplicate data points from the data.

Duplicates are detected by checking the value of omega for sameness using fvalueEq with the default ulp.

Parameters
datathe data to remove duplicates from

References removeDuplicates().

Referenced by removeDuplicates().

◆ rescale()

std::vector< eis::DataPoint > eis::rescale ( const std::vector< eis::DataPoint > & data,
size_t outputSize )

Resamples the data to the given amount of points.

Parameters
dataData to resample.
outputSizeSize to resample to.
Returns
The resampled data.

References rescale().

Referenced by rescale().