Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
math Namespace Reference

Functions

MTS_EXPORT_CORE Float erf (Float x)
 Cross-platform implementation of the error function. More...
 
MTS_EXPORT_CORE Float erfinv (Float x)
 Cross-platform implementation of the inverse error function. More...
 
MTS_EXPORT_CORE float hypot2 (float a, float b)
 sqrt(a^2 + b^2) without range issues (like 'hypot' on compilers that support C99, single precision) More...
 
MTS_EXPORT_CORE double hypot2 (double a, double b)
 sqrt(a^2 + b^2) without range issues (like 'hypot' on compilers that support C99, double precision) More...
 
MTS_EXPORT_CORE float log2 (float value)
 Base-2 logarithm (single precision) More...
 
MTS_EXPORT_CORE double log2 (double value)
 Base-2 logarithm (double precision) More...
 
template<typename Scalar >
Scalar clamp (Scalar value, Scalar min, Scalar max)
 Generic clamping function. More...
 
template<typename Scalar >
Scalar lerp (Scalar t, Scalar v1, Scalar v2)
 Linearly interpolate between two values. More...
 
template<typename Scalar >
Scalar smoothStep (Scalar min, Scalar max, Scalar value)
 S-shaped smoothly varying interpolation between two values. More...
 
int32_t modulo (int32_t a, int32_t b)
 Always-positive modulo function (assumes b > 0) More...
 
int64_t modulo (int64_t a, int64_t b)
 Always-positive modulo function (assumes b > 0) More...
 
float modulo (float a, float b)
 Always-positive modulo function, single precision version (assumes b > 0) More...
 
double modulo (double a, double b)
 Always-positive modulo function, double precision version (assumes b > 0) More...
 
template<typename Scalar >
int floorToInt (Scalar value)
 Integer floor function (single precision) More...
 
template<typename Scalar >
int ceilToInt (Scalar value)
 Integer ceil function (single precision) More...
 
int roundToInt (float value)
 Integer round function (single precision) More...
 
int roundToInt (double value)
 Integer round function (double precision) More...
 
MTS_EXPORT_CORE int log2i (uint32_t value)
 Base-2 logarithm (32-bit integer version) More...
 
MTS_EXPORT_CORE int log2i (uint64_t value)
 Base-2 logarithm (64-bit integer version) More...
 
bool isPowerOfTwo (uint32_t i)
 Check if an integer is a power of two (unsigned 32 bit version) More...
 
bool isPowerOfTwo (int32_t i)
 Check if an integer is a power of two (signed 32 bit version) More...
 
bool isPowerOfTwo (uint64_t i)
 Check if an integer is a power of two (64 bit version) More...
 
bool isPowerOfTwo (int64_t i)
 Check if an integer is a power of two (signed 64 bit version) More...
 
MTS_EXPORT_CORE uint32_t roundToPowerOfTwo (uint32_t i)
 Round an integer to the next power of two. More...
 
MTS_EXPORT_CORE uint64_t roundToPowerOfTwo (uint64_t i)
 Round an integer to the next power of two (64 bit version) More...
 
float fastexp (float value)
 
double fastexp (double value)
 
float fastlog (float value)
 
double fastlog (double value)
 
void sincos (float theta, float *_sin, float *_cos)
 
void sincos (double theta, double *_sin, double *_cos)
 
float safe_asin (float value)
 Arcsine variant that gracefully handles arguments > 1 that are due to roundoff errors. More...
 
double safe_asin (double value)
 Arcsine variant that gracefully handles arguments > 1 that are due to roundoff errors. More...
 
float safe_acos (float value)
 Arccosine variant that gracefully handles arguments > 1 that are due to roundoff errors. More...
 
double safe_acos (double value)
 Arccosine variant that gracefully handles arguments > 1 that are due to roundoff errors. More...
 
float safe_sqrt (float value)
 Square root variant that gracefully handles arguments < 0 that are due to roundoff errors. More...
 
double safe_sqrt (double value)
 Square root variant that gracefully handles arguments < 0 that are due to roundoff errors. More...
 
Float signum (Float value)
 Simple signum function – note that it returns the FP sign of the input (and never zero) More...
 
float castflt_up (float val)
 Cast to single precision and round up if not exactly representable (passthrough) More...
 
float castflt_up (double val)
 Cast to single precision and round up if not exactly representable. More...
 
float castflt_down (float val)
 Cast to single precision and round down if not exactly representable (passthrough) More...
 
float castflt_down (double val)
 Cast to single precision and round down if not exactly representable. More...
 

Detailed Description

Contains elementary 1D math functions that were either not provided by the standard, or which are not consistently provided on all platforms/compilers

Function Documentation

float math::castflt_down ( float  val)
inline

Cast to single precision and round down if not exactly representable (passthrough)

float math::castflt_down ( double  val)
inline

Cast to single precision and round down if not exactly representable.

float math::castflt_up ( float  val)
inline

Cast to single precision and round up if not exactly representable (passthrough)

float math::castflt_up ( double  val)
inline

Cast to single precision and round up if not exactly representable.

template<typename Scalar >
int math::ceilToInt ( Scalar  value)
inline

Integer ceil function (single precision)

template<typename Scalar >
Scalar math::clamp ( Scalar  value,
Scalar  min,
Scalar  max 
)
inline

Generic clamping function.

MTS_EXPORT_CORE Float math::erf ( Float  x)

Cross-platform implementation of the error function.

MTS_EXPORT_CORE Float math::erfinv ( Float  x)

Cross-platform implementation of the inverse error function.

float math::fastexp ( float  value)
inline
double math::fastexp ( double  value)
inline
float math::fastlog ( float  value)
inline
double math::fastlog ( double  value)
inline
template<typename Scalar >
int math::floorToInt ( Scalar  value)
inline

Integer floor function (single precision)

MTS_EXPORT_CORE float math::hypot2 ( float  a,
float  b 
)

sqrt(a^2 + b^2) without range issues (like 'hypot' on compilers that support C99, single precision)

MTS_EXPORT_CORE double math::hypot2 ( double  a,
double  b 
)

sqrt(a^2 + b^2) without range issues (like 'hypot' on compilers that support C99, double precision)

bool math::isPowerOfTwo ( uint32_t  i)
inline

Check if an integer is a power of two (unsigned 32 bit version)

bool math::isPowerOfTwo ( int32_t  i)
inline

Check if an integer is a power of two (signed 32 bit version)

bool math::isPowerOfTwo ( uint64_t  i)
inline

Check if an integer is a power of two (64 bit version)

bool math::isPowerOfTwo ( int64_t  i)
inline

Check if an integer is a power of two (signed 64 bit version)

template<typename Scalar >
Scalar math::lerp ( Scalar  t,
Scalar  v1,
Scalar  v2 
)
inline

Linearly interpolate between two values.

MTS_EXPORT_CORE float math::log2 ( float  value)

Base-2 logarithm (single precision)

MTS_EXPORT_CORE double math::log2 ( double  value)

Base-2 logarithm (double precision)

MTS_EXPORT_CORE int math::log2i ( uint32_t  value)

Base-2 logarithm (32-bit integer version)

MTS_EXPORT_CORE int math::log2i ( uint64_t  value)

Base-2 logarithm (64-bit integer version)

int32_t math::modulo ( int32_t  a,
int32_t  b 
)
inline

Always-positive modulo function (assumes b > 0)

int64_t math::modulo ( int64_t  a,
int64_t  b 
)
inline

Always-positive modulo function (assumes b > 0)

float math::modulo ( float  a,
float  b 
)
inline

Always-positive modulo function, single precision version (assumes b > 0)

double math::modulo ( double  a,
double  b 
)
inline

Always-positive modulo function, double precision version (assumes b > 0)

int math::roundToInt ( float  value)
inline

Integer round function (single precision)

int math::roundToInt ( double  value)
inline

Integer round function (double precision)

MTS_EXPORT_CORE uint32_t math::roundToPowerOfTwo ( uint32_t  i)

Round an integer to the next power of two.

MTS_EXPORT_CORE uint64_t math::roundToPowerOfTwo ( uint64_t  i)

Round an integer to the next power of two (64 bit version)

float math::safe_acos ( float  value)
inline

Arccosine variant that gracefully handles arguments > 1 that are due to roundoff errors.

double math::safe_acos ( double  value)
inline

Arccosine variant that gracefully handles arguments > 1 that are due to roundoff errors.

float math::safe_asin ( float  value)
inline

Arcsine variant that gracefully handles arguments > 1 that are due to roundoff errors.

double math::safe_asin ( double  value)
inline

Arcsine variant that gracefully handles arguments > 1 that are due to roundoff errors.

float math::safe_sqrt ( float  value)
inline

Square root variant that gracefully handles arguments < 0 that are due to roundoff errors.

double math::safe_sqrt ( double  value)
inline

Square root variant that gracefully handles arguments < 0 that are due to roundoff errors.

Float math::signum ( Float  value)
inline

Simple signum function – note that it returns the FP sign of the input (and never zero)

void math::sincos ( float  theta,
float *  _sin,
float *  _cos 
)
inline
void math::sincos ( double  theta,
double *  _sin,
double *  _cos 
)
inline
template<typename Scalar >
Scalar math::smoothStep ( Scalar  min,
Scalar  max,
Scalar  value 
)
inline

S-shaped smoothly varying interpolation between two values.