kaldi-native-fbank C++ API
Kaldi-compatible feature extraction C++ API
Loading...
Searching...
No Matches
kaldi-math.h File Reference

Math constants and small math helpers. More...

#include <cmath>
#include <cstdint>
#include <cstdlib>
Include dependency graph for kaldi-math.h:

Go to the source code of this file.

Classes

struct  knf::RandomState
 State for the thread-safe random number generator. More...

Namespaces

namespace  knf
 This file is part of kaldi-native-fbank.

Macros

#define M_PI   3.1415926535897932384626433832795
#define M_2PI   6.283185307179586476925286766559005
#define M_SQRT2   1.4142135623730950488016887

Functions

float knf::Log (float x)
 Natural logarithm of x (float overload; matches kaldi's Log).
double knf::Log (double x)
 Natural logarithm of x (double overload; matches kaldi's Log).
float knf::Exp (float x)
 Exponential of x (float overload; matches kaldi's Exp).
double knf::Exp (double x)
 Exponential of x (double overload; matches kaldi's Exp).
template<typename I>
I knf::Gcd (I m, I n)
 Greatest common divisor of two integers.
template<typename I>
I knf::Lcm (I m, I n)
 Least common multiple of two integers.
template<typename Real>
bool knf::ApproxEqual (Real a, Real b, Real tol=0.01)
 Approximate floating-point equality test.
int knf::Rand (struct RandomState *state=nullptr)
 Return a random integer between 0 and RAND_MAX, inclusive.
float knf::RandUniform (struct RandomState *state=nullptr)
 Returns a random number strictly between 0 and 1.
float knf::RandGauss (struct RandomState *state=nullptr)
 Return a random sample from the standard normal distribution.
void knf::Sqrt (float *in_out, int32_t n)
 Compute the square root of each element of an array in place.

Detailed Description

Math constants and small math helpers.

This file is an excerpt from src/base/kaldi-math.h.

Macro Definition Documentation

◆ M_2PI

#define M_2PI   6.283185307179586476925286766559005

◆ M_PI

#define M_PI   3.1415926535897932384626433832795

◆ M_SQRT2

#define M_SQRT2   1.4142135623730950488016887