kaldi-math.h File Reference
#include <cmath>
#include <limits>
#include <vector>
#include "base/kaldi-types.h"
#include "base/kaldi-common.h"
Include dependency graph for kaldi-math.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  RandomState
 

Namespaces

 kaldi
 This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for mispronunciations detection tasks, the reference:
 

Macros

#define DBL_EPSILON   2.2204460492503131e-16
 
#define FLT_EPSILON   1.19209290e-7f
 
#define M_PI   3.1415926535897932384626433832795
 
#define M_SQRT2   1.4142135623730950488016887
 
#define M_2PI   6.283185307179586476925286766559005
 
#define M_SQRT1_2   0.7071067811865475244008443621048490
 
#define M_LOG_2PI   1.8378770664093454835606594728112
 
#define M_LN2   0.693147180559945309417232121458
 
#define M_LN10   2.302585092994045684017991454684
 
#define KALDI_ISNAN   std::isnan
 
#define KALDI_ISINF   std::isinf
 
#define KALDI_ISFINITE(x)   std::isfinite(x)
 
#define KALDI_SQR(x)   ((x) * (x))
 

Functions

double Exp (double x)
 
float Exp (float x)
 
double Log (double x)
 
float Log (float x)
 
double Log1p (double x)
 
float Log1p (float x)
 
int Rand (struct RandomState *state)
 
int32 RandInt (int32 min_val, int32 max_val, struct RandomState *state)
 
bool WithProb (BaseFloat prob, struct RandomState *state)
 
float RandUniform (struct RandomState *state=NULL)
 Returns a random number strictly between 0 and 1. More...
 
float RandGauss (struct RandomState *state=NULL)
 
int32 RandPoisson (float lambda, struct RandomState *state)
 
void RandGauss2 (float *a, float *b, RandomState *state)
 
void RandGauss2 (double *a, double *b, RandomState *state)
 
template<class Float >
Float RandPrune (Float post, BaseFloat prune_thresh, struct RandomState *state=NULL)
 
double LogAdd (double x, double y)
 
float LogAdd (float x, float y)
 
double LogSub (double x, double y)
 
float LogSub (float x, float y)
 
static bool ApproxEqual (float a, float b, float relative_tolerance=0.001)
 return abs(a - b) <= relative_tolerance * (abs(a)+abs(b)). More...
 
static void AssertEqual (float a, float b, float relative_tolerance=0.001)
 assert abs(a - b) <= relative_tolerance * (abs(a)+abs(b)) More...
 
int32 RoundUpToNearestPowerOfTwo (int32 n)
 
static int32 DivideRoundingDown (int32 a, int32 b)
 Returns a / b, rounding towards negative infinity in all cases. More...
 
template<class I >
Gcd (I m, I n)
 
template<class I >
Lcm (I m, I n)
 Returns the least common multiple of two integers. More...
 
template<class I >
void Factorize (I m, std::vector< I > *factors)
 
double Hypot (double x, double y)
 
float Hypot (float x, float y)
 

Variables

static const double kMinLogDiffDouble = Log(DBL_EPSILON)
 
static const float kMinLogDiffFloat = Log(FLT_EPSILON)
 
const float kLogZeroFloat = -std::numeric_limits<float>::infinity()
 
const double kLogZeroDouble = -std::numeric_limits<double>::infinity()
 
const BaseFloat kLogZeroBaseFloat = -std::numeric_limits<BaseFloat>::infinity()
 

Macro Definition Documentation

◆ DBL_EPSILON

#define DBL_EPSILON   2.2204460492503131e-16

Definition at line 37 of file kaldi-math.h.

Referenced by kaldi::UnitTestDefines().

◆ FLT_EPSILON

#define FLT_EPSILON   1.19209290e-7f

Definition at line 40 of file kaldi-math.h.

Referenced by kaldi::UnitTestDefines().

◆ KALDI_ISFINITE

◆ KALDI_ISINF

◆ KALDI_ISNAN

◆ KALDI_SQR

#define KALDI_SQR (   x)    ((x) * (x))

Definition at line 77 of file kaldi-math.h.

◆ M_2PI

◆ M_LN10

#define M_LN10   2.302585092994045684017991454684

Definition at line 68 of file kaldi-math.h.

Referenced by ArpaFileParser::Read().

◆ M_LN2

#define M_LN2   0.693147180559945309417232121458

Definition at line 64 of file kaldi-math.h.

◆ M_LOG_2PI

◆ M_PI

◆ M_SQRT1_2

#define M_SQRT1_2   0.7071067811865475244008443621048490

Definition at line 56 of file kaldi-math.h.

Referenced by SplitRadixComplexFft< float >::ComputeRecursive().

◆ M_SQRT2

#define M_SQRT2   1.4142135623730950488016887

Definition at line 48 of file kaldi-math.h.

Referenced by MfccComputer::Compute(), and IvectorExtractorStats::UpdatePrior().