#include <cmath>
#include "DataTypes.hxx"
#include "FastRounding.hxx"
Go to the source code of this file.
Namespaces | |
namespace | CLAM |
Defines | |
#define | CLAM_DB_SCALING 20 |
Functions | |
float | CLAM_sin (register float x) |
Efficient versions of common functions. | |
float | CLAM_cos (register float x) |
float | CLAM_atan (register float x) |
float | CLAM_atan2 (float Imag, float Real) |
float | CLAM_exp2 (register float x) |
float | CLAM_log2 (register float x) |
float | CLAM_pow (float x, float y) |
float | CLAM_sqrt (register float x) |
float | CLAM_log (register float x) |
float | CLAM_log10 (register float x) |
float | CLAM_20log10 (register float x) |
float | CLAM_exp (register float x) |
double | round (double _X) |
float | round (float _X) |
float | log2lin (float x) |
Fast "pow" for converting a logarithmic value into linear value ( assumes a log scale factor of 20 ). | |
bool | isPowerOfTwo (CLAM::TUInt32 n) |
Returns true if the given (unsigned) integer n is a power-of-two. | |
CLAM::TUInt32 | nextPowerOfTwo (CLAM::TUInt32 n) |
Returns the closest power-of-two number greater or equal to n for the given (unsigned) integer n. | |
template<class T > | |
T | CLAM::Abs (T value) |
double | CLAM::DB (double linData, int scaling=20) |
double | CLAM::Lin (double logData, int scaling=20) |
template<class T > | |
T | CLAM::CLAM_max (const T &x, const T &y) |
Definition of CLAM_min and CLAM_max. | |
template<class T > | |
T | CLAM::CLAM_min (const T &x, const T &y) |
Variables | |
const float | PI_ = 3.1415926535897932384626433832795028841972 |
const float | ONE_OVER_PI = (0.3183098861837906661338147750939f) |
const float | TWOPI = (6.2831853071795864769252867665590057683943f) |
const float | ONE_OVER_TWOPI = (0.15915494309189535682609381638f) |
const float | PI_2 = (1.5707963267948966192313216916397514420986f) |
const float | TWO_OVER_PI = (0.636619772367581332267629550188f) |
const float | LN2 = (0.6931471805599453094172321214581765680755f) |
const float | ONE_OVER_LN2 = (1.44269504088896333066907387547f) |
const float | LN10 = (2.3025850929940456840179914546843642076011f) |
const float | ONE_OVER_LN10 = (0.43429448190325177635683940025f) |
const float | LN2_OVER_LN10 = LN2*ONE_OVER_LN10 |
const float | TIMES20LN2_OVER_LN10 = 20*LN2_OVER_LN10 |
const long | LONG_OFFSET = 4096L |
const float | FLOAT_OFFSET = 4096.0 |
const float | HUGE_ = 1.0e8 |
const float | ROOT2 = (1.4142135623730950488016887242096980785697f) |
#define CLAM_DB_SCALING 20 |
Definition at line 450 of file CLAM_Math.hxx.
float CLAM_20log10 | ( | register float | x | ) | [inline] |
Definition at line 338 of file CLAM_Math.hxx.
References CLAM_log2(), and TIMES20LN2_OVER_LN10.
Referenced by CLAM::Spectrum::ToDB(), and CLAM::SpectralPeakArray::TodB().
float CLAM_atan | ( | register float | x | ) | [inline] |
Definition at line 98 of file CLAM_Math.hxx.
References PI_2.
Referenced by CLAM::FFT_ooura::makect(), and CLAM::FFT_ooura::makewt().
float CLAM_atan2 | ( | float | Imag, | |
float | Real | |||
) | [inline] |
Definition at line 132 of file CLAM_Math.hxx.
Referenced by CLAM::Complex::Ang(), CLAM::FDCombFilter::Do(), CLAM::Polar::operator+(), CLAM::Polar::operator-(), and CLAM::Polar::operator-=().
float CLAM_cos | ( | register float | x | ) | [inline] |
Definition at line 73 of file CLAM_Math.hxx.
References ONE_OVER_PI.
Referenced by CLAM::FDCombFilter::Do(), CLAM::FFT_ooura::makect(), CLAM::FFT_ooura::makewt(), CLAM::Polar::operator+(), CLAM::Polar::operator+=(), CLAM::Polar::operator-(), CLAM::Polar::operator-=(), CLAM::Polar::Real(), CLAM::Spectrum::SetMag(), CLAM::Spectrum::SetPhase(), and CLAM::Complex::ToPolar().
float CLAM_exp | ( | register float | x | ) | [inline] |
Definition at line 347 of file CLAM_Math.hxx.
References CLAM_exp2(), and ONE_OVER_LN2.
Referenced by log2lin().
float CLAM_exp2 | ( | register float | x | ) | [inline] |
Definition at line 192 of file CLAM_Math.hxx.
References FLOAT_OFFSET, LN2, and LONG_OFFSET.
Referenced by CLAM_exp(), and CLAM_pow().
float CLAM_log | ( | register float | x | ) | [inline] |
Definition at line 320 of file CLAM_Math.hxx.
References CLAM_log2(), and LN2.
float CLAM_log10 | ( | register float | x | ) | [inline] |
Definition at line 329 of file CLAM_Math.hxx.
References CLAM_log2(), and LN2_OVER_LN10.
Referenced by CLAM::DB().
float CLAM_log2 | ( | register float | x | ) | [inline] |
Definition at line 225 of file CLAM_Math.hxx.
References HUGE_, and ONE_OVER_LN2.
Referenced by CLAM_20log10(), CLAM_log(), CLAM_log10(), and CLAM_pow().
float CLAM_pow | ( | float | x, | |
float | y | |||
) | [inline] |
Definition at line 266 of file CLAM_Math.hxx.
References CLAM_exp2(), and CLAM_log2().
Referenced by CLAM::PointTmpl< TData, TData >::Distance(), CLAM::SpectralEnvelopeExtract::Do(), CLAM::FDFilterGen::Do(), CLAM::Lin(), CLAM::SpectralAnalysisConfig::SetWindowSize(), and CLAM::SpectralAnalysisConfig::SetZeroPadding().
float CLAM_sin | ( | register float | x | ) | [inline] |
Efficient versions of common functions.
Definition at line 50 of file CLAM_Math.hxx.
References ONE_OVER_PI.
Referenced by CLAM::FDCombFilter::Do(), CLAM::Polar::Imag(), CLAM::FFT_ooura::makect(), CLAM::FFT_ooura::makewt(), CLAM::Polar::operator+(), CLAM::Polar::operator+=(), CLAM::Polar::operator-(), CLAM::Polar::operator-=(), CLAM::Spectrum::SetMag(), CLAM::Spectrum::SetPhase(), and CLAM::Complex::ToPolar().
float CLAM_sqrt | ( | register float | x | ) | [inline] |
Definition at line 275 of file CLAM_Math.hxx.
References ROOT2.
Referenced by CLAM::FDCombFilter::Do(), CLAM::Complex::Mag(), CLAM::StandardDeviationTmpl< abs, TData, TData >::operator()(), CLAM::RMSTmpl< FrameDescriptors >::operator()(), CLAM::Polar::operator+(), CLAM::Polar::operator-(), CLAM::Polar::operator-=(), CLAM::Spectrum::ToDB(), and CLAM::Spectrum::ToLinear().
bool isPowerOfTwo | ( | CLAM::TUInt32 | n | ) | [inline] |
Returns true if the given (unsigned) integer n is a power-of-two.
Will return true for n = 0 and n = 1.
Definition at line 414 of file CLAM_Math.hxx.
Referenced by CLAM::IFFT_ooura::Do(), CLAM::FFT_ooura::Do(), and CLAM::FFT_numrec::FFT_numrec().
float log2lin | ( | float | x | ) | [inline] |
Fast "pow" for converting a logarithmic value into linear value ( assumes a log scale factor of 20 ).
Warning, float should be TData but includes should then be changed
Definition at line 400 of file CLAM_Math.hxx.
References CLAM_exp().
Referenced by CLAM::SpectralNotch::Do(), CLAM::Lin(), CLAM::Spectrum::ToLinear(), and CLAM::SpectralPeakArray::ToLinear().
CLAM::TUInt32 nextPowerOfTwo | ( | CLAM::TUInt32 | n | ) | [inline] |
Returns the closest power-of-two number greater or equal to n for the given (unsigned) integer n.
Will return 0 when n = 0 and 1 when n = 1.
Definition at line 424 of file CLAM_Math.hxx.
Referenced by CLAM::SpectralAnalysisConfig::SetWindowSize(), and CLAM::SpectralAnalysisConfig::SetZeroPadding().
float round | ( | float | _X | ) | [inline] |
Definition at line 392 of file CLAM_Math.hxx.
double round | ( | double | _X | ) | [inline] |
Definition at line 390 of file CLAM_Math.hxx.
const float FLOAT_OFFSET = 4096.0 |
Definition at line 45 of file CLAM_Math.hxx.
Referenced by CLAM_exp2().
const float HUGE_ = 1.0e8 |
Definition at line 46 of file CLAM_Math.hxx.
Referenced by CLAM_log2().
const float LN10 = (2.3025850929940456840179914546843642076011f) |
Definition at line 40 of file CLAM_Math.hxx.
const float LN2 = (0.6931471805599453094172321214581765680755f) |
Definition at line 38 of file CLAM_Math.hxx.
Referenced by CLAM_exp2(), and CLAM_log().
const float LN2_OVER_LN10 = LN2*ONE_OVER_LN10 |
Definition at line 42 of file CLAM_Math.hxx.
Referenced by CLAM_log10().
const long LONG_OFFSET = 4096L |
Definition at line 44 of file CLAM_Math.hxx.
Referenced by CLAM_exp2().
const float ONE_OVER_LN10 = (0.43429448190325177635683940025f) |
Definition at line 41 of file CLAM_Math.hxx.
const float ONE_OVER_LN2 = (1.44269504088896333066907387547f) |
Definition at line 39 of file CLAM_Math.hxx.
Referenced by CLAM_exp(), and CLAM_log2().
const float ONE_OVER_PI = (0.3183098861837906661338147750939f) |
Definition at line 33 of file CLAM_Math.hxx.
Referenced by CLAM_cos(), and CLAM_sin().
const float ONE_OVER_TWOPI = (0.15915494309189535682609381638f) |
Definition at line 35 of file CLAM_Math.hxx.
const float PI_ = 3.1415926535897932384626433832795028841972 |
Definition at line 32 of file CLAM_Math.hxx.
Referenced by CLAM_atan2().
const float PI_2 = (1.5707963267948966192313216916397514420986f) |
Definition at line 36 of file CLAM_Math.hxx.
Referenced by CLAM_atan(), and CLAM_atan2().
const float ROOT2 = (1.4142135623730950488016887242096980785697f) |
Definition at line 47 of file CLAM_Math.hxx.
Referenced by CLAM_sqrt().
const float TIMES20LN2_OVER_LN10 = 20*LN2_OVER_LN10 |
Definition at line 43 of file CLAM_Math.hxx.
Referenced by CLAM_20log10().
const float TWO_OVER_PI = (0.636619772367581332267629550188f) |
Definition at line 37 of file CLAM_Math.hxx.
const float TWOPI = (6.2831853071795864769252867665590057683943f) |
Definition at line 34 of file CLAM_Math.hxx.