Fleet  0.0.9
Inference in the LOT
Macros | Functions | Variables
Numerics.h File Reference
#include <random>
#include <iostream>
#include <assert.h>
#include <math.h>
Include dependency graph for Numerics.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define _REENTRANT   1
 

Functions

template<typename T >
get_log1pexp_breakout_bound (const double precision, T f(T), const T lower=-1e6, const T upper=1e6)
 Tis takes a function f(x) and finds a bound B so that f(x) < precision for all x < B. This is useful in logsumexp where at compile time we don't bother adding if the addition will be too tiny. For instance: constexpr auto f = +[](T x) -> const double {return log1p(exp(x));}; const T bound = get_fx_compiletime_bound<T>(1e-6, f);. More...
 
template<typename T >
logplusexp (const T a, const T b)
 
template<typename T >
logplusexp_full (const T a, const T b)
 logsumexp with no shortcuts for precision More...
 
template<typename t >
double logsumexp (const t &v)
 Compute log(sum(exp(v)). For now, this just unrolls logplusexp, but we might consider the faster (standard) variant where we pull out the max. More...
 
template<typename t >
double logsumexp (const std::vector< t > &v, double f(const t &))
 
double mylgamma (double v)
 
double mygamma (double v)
 
double lfactorial (double x)
 

Variables

const double LOG2 = log(2.0)
 
const double ROOT2 = sqrt(2.0)
 
constexpr double infinity = std::numeric_limits<double>::infinity()
 
constexpr double NaN = std::numeric_limits<double>::quiet_NaN()
 
constexpr double pi = M_PI
 
constexpr double tau = 2*pi
 

Macro Definition Documentation

◆ _REENTRANT

#define _REENTRANT   1

Function Documentation

◆ get_log1pexp_breakout_bound()

template<typename T >
T get_log1pexp_breakout_bound ( const double  precision,
T   fT,
const T  lower = -1e6,
const T  upper = 1e6 
)

Tis takes a function f(x) and finds a bound B so that f(x) < precision for all x < B. This is useful in logsumexp where at compile time we don't bother adding if the addition will be too tiny. For instance: constexpr auto f = +[](T x) -> const double {return log1p(exp(x));}; const T bound = get_fx_compiletime_bound<T>(1e-6, f);.

◆ lfactorial()

double lfactorial ( double  x)

◆ logplusexp()

template<typename T >
T logplusexp ( const T  a,
const T  b 
)

◆ logplusexp_full()

template<typename T >
T logplusexp_full ( const T  a,
const T  b 
)

logsumexp with no shortcuts for precision

Parameters
a
b
Returns

◆ logsumexp() [1/2]

template<typename t >
double logsumexp ( const t &  v)

Compute log(sum(exp(v)). For now, this just unrolls logplusexp, but we might consider the faster (standard) variant where we pull out the max.

Parameters
v
Returns

◆ logsumexp() [2/2]

template<typename t >
double logsumexp ( const std::vector< t > &  v,
double   fconst t & 
)

◆ mygamma()

double mygamma ( double  v)

◆ mylgamma()

double mylgamma ( double  v)

Variable Documentation

◆ infinity

constexpr double infinity = std::numeric_limits<double>::infinity()

◆ LOG2

const double LOG2 = log(2.0)

◆ NaN

constexpr double NaN = std::numeric_limits<double>::quiet_NaN()

◆ pi

constexpr double pi = M_PI

◆ ROOT2

const double ROOT2 = sqrt(2.0)

◆ tau

constexpr double tau = 2*pi