NVIDIA Iray: Math API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
function.h File Reference

Math functions and function templates on simple types or generic container and vector concepts. More...

Go to the source code of this file.

Classes

struct   mi::math::functor::Operator_equal_equal
  Functor for the equality comparison operator, ==. More...
 
struct   mi::math::functor::Operator_not_equal
  Functor for the inequality comparison operator, !=. More...
 
struct   mi::math::functor::Operator_less
  Functor for the less-than comparison operator, <. More...
 
struct   mi::math::functor::Operator_less_equal
  Functor for the less-than-or-equal comparison operator, <=. More...
 
struct   mi::math::functor::Operator_greater
  Functor for the greater-than comparison operator, >. More...
 
struct   mi::math::functor::Operator_greater_equal
  Functor for the greater-than-or-equal comparison operator, >=. More...
 
struct   mi::math::functor::Operator_plus
  Functor for the plus operator, +. More...
 
struct   mi::math::functor::Operator_minus
  Functor for the minus operator, -, unary and binary. More...
 
struct   mi::math::functor::Operator_multiply
  Functor for the multiplication operator, *. More...
 
struct   mi::math::functor::Operator_divide
  Functor for the division operator, /. More...
 
struct   mi::math::functor::Operator_and_and
  Functor for the logical and operator, &&. More...
 
struct   mi::math::functor::Operator_or_or
  Functor for the logical or operator, ||. More...
 
struct   mi::math::functor::Operator_xor
  Functor for the xor operator, ^. More...
 
struct   mi::math::functor::Operator_not
  Functor for the logical not operator, !. More...
 
struct   mi::math::functor::Operator_pre_incr
  Functor for the pre-increment operator, ++. More...
 
struct   mi::math::functor::Operator_post_incr
  Functor for the post-increment operator, ++. More...
 
struct   mi::math::functor::Operator_pre_decr
  Functor for the pre-decrement operator, --. More...
 
struct   mi::math::functor::Operator_post_decr
  Functor for the post-decrement operator, --. More...
 

Namespaces

  mi
  Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH.
 
  mi::math
  Namespace for the Math API.
 
  mi::math::functor
  Namespace for basic math functors in the Math API.
 
  mi::math::general
  Namespace for generic functions in the Math API.
 

Constant Groups

  mi
  Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH.
 
  mi::math
  Namespace for the Math API.
 
  mi::math::functor
  Namespace for basic math functors in the Math API.
 
  mi::math::general
  Namespace for generic functions in the Math API.
 

Functions

template<class Vector , class ResultVector , class UnaryFunctor >
void  mi::math::general::transform (const Vector &vec, ResultVector &result, UnaryFunctor f)
  Generic transform function that applies a unary functor (return value). More...
 
template<class Vector1 , class Vector2 , class ResultVector , class BinaryFunctor >
void  mi::math::general::transform (const Vector1 &vec1, const Vector2 &vec2, ResultVector &result, BinaryFunctor f)
  Generic transform function that applies a binary functor (return value). More...
 
template<class Scalar , class Vector , class ResultVector , class BinaryFunctor >
void  mi::math::general::transform_left_scalar (const Scalar &s, const Vector &vec, ResultVector &result, BinaryFunctor f)
  Generic transform function that applies a binary functor (return value, LHS scalar). More...
 
template<class Scalar , class Vector , class ResultVector , class BinaryFunctor >
void  mi::math::general::transform_right_scalar (const Vector &vec, const Scalar &s, ResultVector &result, BinaryFunctor f)
  Generic transform function that applies a binary functor (return value, RHS scalar). More...
 
template<class Vector , class UnaryFunctor >
void  mi::math::general::for_each (Vector &vec, UnaryFunctor f)
  Generic transform function that applies a unary functor (in-place). More...
 
template<class Vector1 , class Vector2 , class BinaryFunctor >
void  mi::math::general::for_each (Vector1 &vec1, const Vector2 &vec2, BinaryFunctor f)
  Generic transform function that applies a binary functor (in-place). More...
 
Float32  mi::math::exp (Float32 s)
  Returns the constant e to the power of s (exponential function). More...
 
Float64  mi::math::exp (Float64 s)
  Returns the constant e to the power of s (exponential function). More...
 
Float32  mi::math::log (Float32 s)
  Returns the natural logarithm of s. More...
 
Float64  mi::math::log (Float64 s)
  Returns the natural logarithm of s. More...
 
Float32  mi::math::fast_sqrt (Float32 i)
  A fast implementation of sqrt(x) for floats. More...
 
Float32  mi::math::fast_exp (Float32 x)
  A fast implementation of exp for floats. More...
 
Float32  mi::math::fast_pow2 (Float32 x)
  A fast implementation of pow(2,x) for floats. More...
 
Float32  mi::math::fast_log2 (Float32 i)
  A fast implementation of log2(x) for floats. More...
 
Float32  mi::math::fast_pow (Float32 b, Float32 e)
  A fast implementation of pow(x,y) for floats. More...
 
Float32  mi::math::acos (Float32 s)
  Returns the arc cosine of s in radians. More...
 
Float64  mi::math::acos (Float64 s)
  Returns the arc cosine of s in radians. More...
 
bool  mi::math::all (Uint8 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::all (Uint16 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::all (Uint32 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::all (Uint64 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::all (Sint8 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::all (Sint16 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::all (Sint32 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::all (Sint64 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::all (Float32 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::all (Float64 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::any (Uint8 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::any (Uint16 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::any (Uint32 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::any (Uint64 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::any (Sint8 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::any (Sint16 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::any (Sint32 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::any (Sint64 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::any (Float32 v)
  Returns true if v is not equal to zero. More...
 
bool  mi::math::any (Float64 v)
  Returns true if v is not equal to zero. More...
 
Float32  mi::math::asin (Float32 s)
  Returns the arc sine of s in radians. More...
 
Float64  mi::math::asin (Float64 s)
  Returns the arc sine of s in radians. More...
 
Float32  mi::math::atan (Float32 s)
  Returns the arc tangent of s. More...
 
Float64  mi::math::atan (Float64 s)
  Returns the arc tangent of s. More...
 
Float32  mi::math::atan2 (Float32 s, Float32 t)
  Returns the arc tangent of s / t. More...
 
Float64  mi::math::atan2 (Float64 s, Float64 t)
  Returns the arc tangent of s / t. More...
 
Float32  mi::math::ceil (Float32 s)
  Returns the smallest integral value that is not less than s. More...
 
Float64  mi::math::ceil (Float64 s)
  Returns the smallest integral value that is not less than s. More...
 
Uint8  mi::math::clamp (Uint8 s, Uint8 low, Uint8 high)
  Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high. More...
 
Uint16  mi::math::clamp (Uint16 s, Uint16 low, Uint16 high)
  Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high. More...
 
Uint32  mi::math::clamp (Uint32 s, Uint32 low, Uint32 high)
  Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high. More...
 
Uint64  mi::math::clamp (Uint64 s, Uint64 low, Uint64 high)
  Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high. More...
 
Sint8  mi::math::clamp (Sint8 s, Sint8 low, Sint8 high)
  Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high. More...
 
Sint16  mi::math::clamp (Sint16 s, Sint16 low, Sint16 high)
  Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high. More...
 
Sint32  mi::math::clamp (Sint32 s, Sint32 low, Sint32 high)
  Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high. More...
 
Sint64  mi::math::clamp (Sint64 s, Sint64 low, Sint64 high)
  Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high. More...
 
Float32  mi::math::clamp (Float32 s, Float32 low, Float32 high)
  Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high. More...
 
Float64  mi::math::clamp (Float64 s, Float64 low, Float64 high)
  Returns the value s if it is in the range [low, high], the value low if s < low, or the value high if s > high. More...
 
Float32  mi::math::cos (Float32 a)
  Returns the cosine of a. The angle a is specified in radians. More...
 
Float64  mi::math::cos (Float64 a)
  Returns the cosine of a. The angle a is specified in radians. More...
 
Float32  mi::math::degrees (Float32 r)
  Converts radians r to degrees. More...
 
Float64  mi::math::degrees (Float64 r)
  Converts radians r to degrees. More...
 
Float32  mi::math::exp2 (Float32 s)
  Returns the constant 2 to the power of s (exponential function). More...
 
Float64  mi::math::exp2 (Float64 s)
  Returns the constant 2 to the power of s (exponential function). More...
 
Float32  mi::math::floor (Float32 s)
  Returns the largest integral value that is not greater than s. More...
 
Float64  mi::math::floor (Float64 s)
  Returns the largest integral value that is not greater than s. More...
 
Float32  mi::math::fmod (Float32 a, Float32 b)
  Returns a modulo b, in other words, the remainder of a/b. More...
 
Float64  mi::math::fmod (Float64 a, Float64 b)
  Returns a modulo b, in other words, the remainder of a/b. More...
 
Float32  mi::math::frac (Float32 s)
  Returns the positive fractional part of s. More...
 
Float64  mi::math::frac (Float64 s)
  Returns the positive fractional part of s. More...
 
bool  mi::math::is_approx_equal (Float32 left, Float32 right, Float32 e)
  Compares the two given values for equality within the given epsilon. More...
 
bool  mi::math::is_approx_equal (Float64 left, Float64 right, Float64 e)
  Compares the two given values for equality within the given epsilon. More...
 
Float32  mi::math::log2 (Float32 s)
  Returns the base 2 logarithm of s. More...
 
Float64  mi::math::log2 (Float64 s)
  Returns the base 2 logarithm of s. More...
 
Float32  mi::math::log10 (Float32 s)
  Returns the base 10 logarithm of s. More...
 
Float64  mi::math::log10 (Float64 s)
  Returns the base 10 logarithm of s. More...
 
Float32  mi::math::lerp (Float32 s1, Float32 s2, Float32 t)
  Returns the linear interpolation between s1 and s2, i.e., it returns (1-t) * s1 + t * s2. More...
 
Float64  mi::math::lerp (Float64 s1, Float64 s2, Float64 t)
  Returns the linear interpolation between s1 and s2, i.e., it returns (1-t) * s1 + t * s2. More...
 
Float32  mi::math::modf (Float32 s, Float32 &i)
  Returns the fractional part of s and stores the integral part of s in i. More...
 
Float64  mi::math::modf (Float64 s, Float64 &i)
  Returns the fractional part of s and stores the integral part of s in i. More...
 
Uint32  mi::math::pow (Uint32 a, Uint32 b)
  Returns a to the power of b. More...
 
Uint64  mi::math::pow (Uint64 a, Uint64 b)
  Returns a to the power of b. More...
 
Sint32  mi::math::pow (Sint32 a, Sint32 b)
  Returns a to the power of b. More...
 
Sint64  mi::math::pow (Sint64 a, Sint64 b)
  Returns a to the power of b. More...
 
Float32  mi::math::pow (Float32 a, Float32 b)
  Returns a to the power of b. More...
 
Float64  mi::math::pow (Float64 a, Float64 b)
  Returns a to the power of b. More...
 
Float32  mi::math::radians (Float32 d)
  Converts degrees d to radians. More...
 
Float64  mi::math::radians (Float64 d)
  Converts degrees d to radians. More...
 
Float32  mi::math::round (Float32 s)
  Returns s rounded to the nearest integer value. More...
 
Float64  mi::math::round (Float64 s)
  Returns s rounded to the nearest integer value. More...
 
Float32  mi::math::rsqrt (Float32 s)
  Returns the reciprocal of the square root of s. More...
 
Float64  mi::math::rsqrt (Float64 s)
  Returns the reciprocal of the square root of s. More...
 
Float32  mi::math::saturate (Float32 s)
  Returns the value s clamped to the range [0,1]. More...
 
Float64  mi::math::saturate (Float64 s)
  Returns the value s clamped to the range [0,1]. More...
 
Sint8  mi::math::sign (Sint8 s)
  Returns -1 if s<0, 0 if s==0, and +1 if s>0. More...
 
Sint16  mi::math::sign (Sint16 s)
  Returns -1 if s<0, 0 if s==0, and +1 if s>0. More...
 
Sint32  mi::math::sign (Sint32 s)
  Returns -1 if s<0, 0 if s==0, and +1 if s>0. More...
 
Sint64  mi::math::sign (Sint64 s)
  Returns -1 if s<0, 0 if s==0, and +1 if s>0. More...
 
Float32  mi::math::sign (Float32 s)
  Returns -1 if s<0, 0 if s==0, and +1 if s>0. More...
 
Float64  mi::math::sign (Float64 s)
  Returns -1 if s<0, 0 if s==0, and +1 if s>0. More...
 
bool  mi::math::sign_bit (Sint8 s)
  Returns true if s<0 and false if s>= 0. More...
 
bool  mi::math::sign_bit (Sint16 s)
  Returns true if s<0 and false if s>= 0. More...
 
bool  mi::math::sign_bit (Sint32 s)
  Returns true if s<0 and false if s>= 0. More...
 
bool  mi::math::sign_bit (Sint64 s)
  Returns true if s<0 and false if s>= 0. More...
 
bool  mi::math::sign_bit (Float32 s)
  Extracts the sign bit of a single-precision floating point number. More...
 
bool  mi::math::sign_bit (Float64 s)
  Extracts the sign bit of a double-precision floating point number. More...
 
bool  mi::math::isnan (const Float32 x)
  Checks a single-precision floating point number for "not a number". More...
 
bool  mi::math::isnan (const Float64 x)
  Checks a double-precision floating point number for "not a number". More...
 
bool  mi::math::isinfinite (const Float32 x)
  Checks a single-precision floating point number for "infinity". More...
 
bool  mi::math::isinfinite (const Float64 x)
  Checks a double-precision floating point number for "infinity". More...
 
bool  mi::math::isfinite (const Float32 x)
  Checks a single-precision floating point number for neither "not a number" nor "infinity". More...
 
bool  mi::math::isfinite (const Float64 x)
  Checks a double-precision floating point number for neither "not a number" nor "infinity". More...
 
Float32  mi::math::sin (Float32 a)
  Returns the sine of a. The angle a is specified in radians. More...
 
Float64  mi::math::sin (Float64 a)
  Returns the sine of a. The angle a is specified in radians. More...
 
void  mi::math::sincos (Float32 a, Float32 &s, Float32 &c)
  Computes the sine s and cosine c of angle a simultaneously. More...
 
void  mi::math::sincos (Float64 a, Float64 &s, Float64 &c)
  Computes the sine s and cosine c of angle a simultaneously. More...
 
Float32  mi::math::smoothstep (Float32 a, Float32 b, Float32 x)
  Returns 0 if x is less than a and 1 if x is greater than b. More...
 
Float64  mi::math::smoothstep (Float64 a, Float64 b, Float64 x)
  Returns 0 if x is less than a and 1 if x is greater than b. More...
 
Float32  mi::math::sqrt (Float32 s)
  Returns the square root of s. More...
 
Float64  mi::math::sqrt (Float64 s)
  Returns the square root of s. More...
 
Float32  mi::math::step (Float32 a, Float32 x)
  Returns 0 if x is less than a and 1 otherwise. More...
 
Float64  mi::math::step (Float64 a, Float64 x)
  Returns 0 if x is less than a and 1 otherwise. More...
 
Float32  mi::math::tan (Float32 a)
  Returns the tangent of a. The angle a is specified in radians. More...
 
Float64  mi::math::tan (Float64 a)
  Returns the tangent of a. The angle a is specified in radians. More...
 
void  mi::math::to_rgbe (const Float32 color[3], Uint32 &rgbe)
  Encodes a color into RGBE representation. More...
 
void  mi::math::to_rgbe (const Float32 color[3], Uint8 rgbe[4])
  Encodes a color into RGBE representation. More...
 
void  mi::math::from_rgbe (const Uint8 rgbe[4], Float32 color[3])
  Decodes a color from RGBE representation. More...
 
void  mi::math::from_rgbe (const Uint32 rgbe, Float32 color[3])
  Decodes a color from RGBE representation. More...
 
Sint32  mi::math::dot (Sint32 a, Sint32 b)
  Returns the inner product (a.k.a. dot or scalar product) of two integers. More...
 
Float32  mi::math::dot (Float32 a, Float32 b)
  Returns the inner product (a.k.a. dot or scalar product) of two scalars. More...
 
Float64  mi::math::dot (Float64 a, Float64 b)
  Returns the inner product (a.k.a. dot or scalar product) of two scalars. More...
 
template<class V >
V::value_type  mi::math::dot (const V &lhs, const V &rhs)
  Returns the inner product (a.k.a. dot or scalar product) of two vectors. More...
 
template<class V >
V::value_type  mi::math::square_length (const V &v)
  Returns the squared Euclidean norm of the vector v. More...
 
Float32  mi::math::length (Float32 a)
  Returns the Euclidean norm of the scalar a (its absolute value). More...
 
Float64  mi::math::length (Float64 a)
  Returns the Euclidean norm of the scalar a (its absolute value). More...
 
template<class V >
V::value_type  mi::math::length (const V &v)
  Returns the Euclidean norm of the vector v. More...
 
template<class V >
V::value_type  mi::math::square_euclidean_distance (const V &lhs, const V &rhs)
  Returns the squared Euclidean distance from the vector lhs to the vector rhs. More...
 
template<class V >
V::value_type  mi::math::euclidean_distance (const V &lhs, const V &rhs)
  Returns the Euclidean distance from the vector lhs to the vector rhs. More...
 
template<class V >
void  mi::math::set_bounds (V &v, const V &low, const V &high)
  Bounds the value of vector v elementwise to the given low and high vector values. More...
 
template<class V >
bool  mi::math::is_equal (const V &lhs, const V &rhs)
  Returns true if vector lhs is elementwise equal to vector rhs, and false otherwise. More...
 
template<class V >
Comparison_result  mi::math::lexicographically_compare (const V &lhs, const V &rhs)
  Compares two vectors lexicographically. More...
 
template<class V >
bool  mi::math::lexicographically_less (const V &lhs, const V &rhs)
  Returns true if vector lhs is lexicographically less than vector rhs, and false otherwise. More...
 

Detailed Description

Math functions and function templates on simple types or generic container and vector concepts.

See Math Functions.