Dataflow Runtime API
3.1.1.0
|
Mathematical utility functions. More...
#include <Imt.Base.Core.Math/Maths.h>
Static Public Member Functions | |
template<typename Type > | |
static bool | areEqualNumbers (const Type left, const Type right) |
Compares two numbers. More... | |
template<typename Type > | |
static bool | areEqualFloats (const Type left, const Type right) |
Compares two floating point numbers. More... | |
template<typename Type > | |
static bool | areEqualArrayFloats (const Type *left, const Type *right, size_t size) |
Compares two floating point arrays. More... | |
template<typename Type > | |
static Type | sqrt (const Type sqVal) |
Find square root of a value. More... | |
template<typename Type > | |
static Type | nsqrt (const Type sqVal, Type n) |
Find n-th root of a value. More... | |
template<typename Type > | |
static Type | nsqrt (const Type sqVal, int32_t n) |
template<typename Type > | |
static Type | exp (const Type value) |
Computes e (Euler's number, 2.7182818...) raised to the given power arg. More... | |
template<typename Type > | |
static Type | ln (const Type arg) |
Computes the natural (base e) logarithm of arg. More... | |
template<typename Type > | |
static Type | log10 (const Type arg) |
Computes the common (base-10) logarithm of n. More... | |
template<typename Type > | |
static Type | pow (const Type base, const int32_t exp) |
Computes the value of base (m) raised to the power exponent (n) More... | |
static float64_t | pow10 (const int32_t exp) |
Computes the value of 10 raised to the power exp. More... | |
template<typename Type > | |
static Type | fabs (const Type value) |
Find absolute value of a given input. More... | |
template<typename Type > | |
static Type | abs (const Type value) |
Find absolute value of a given input. More... | |
template<typename Type > | |
static Type | sin (const Type value) |
Computes the sine of arg (measured in radians) More... | |
template<typename Type > | |
static Type | cos (const Type value) |
Computes the cosine of arg (measured in radians) More... | |
template<typename Type > | |
static Type | tan (const Type value) |
Computes the tangens of arg (measured in radians) More... | |
template<typename Type > | |
static Type | arcos (const Type value) |
Computes the arccos of arg. More... | |
template<typename Type > | |
static Type | arsin (const Type value) |
Computes the arsin of arg. More... | |
template<typename Type > | |
static Type | artan (const Type value) |
Computes the arctan of arg. More... | |
template<typename Type > | |
static Type | artan2 (const Type y, const Type x) |
Computes the arc tangent of y/x using the signs of arguments to determine the correct quadrant. More... | |
template<typename Type > | |
static Type | cosh (const Type value) |
Computes the cosh of arg (measured in radians) More... | |
template<typename Type > | |
static Type | sinh (const Type value) |
Computes the sinh of arg (measured in radians) More... | |
template<typename Type > | |
static Type | tanh (const Type value) |
Computes the tanh of arg (measured in radians) More... | |
template<typename Type > | |
static Type | arsinh (const Type value) |
Computes the arsinh of arg (measured in radians) More... | |
template<typename Type > | |
static Type | arcosh (const Type value) |
Computes the acosh of arg (measured in radians) More... | |
template<typename Type > | |
static Type | artanh (const Type value) |
Computes the inverse hyperbolic tangent of arg. More... | |
template<typename Type > | |
static Type | copysign (const Type &x, const Type &y) |
Returns a value with the magnitude of x and the sign of y. More... | |
template<typename Type > | |
static Type | erf (const Type &x) |
Compute error function. More... | |
template<typename Type > | |
static Type | erfc (const Type &x) |
Compute complementary error function. More... | |
template<typename Type > | |
static Type | expm1 (const Type &x) |
Compute exponential minus one. More... | |
template<typename Type > | |
static Type | fdim (const Type &x, const Type &y) |
Positive difference. More... | |
template<typename Type > | |
static Type | floor (const Type &x) |
Round down value. More... | |
template<typename Type > | |
static Type | fmod (const Type &numer, const Type &denom) |
Compute remainder of division. More... | |
template<typename Type > | |
static Type | frexp (const Type &x, int *exp) |
Get significand and exponent. More... | |
template<typename Type > | |
static Type | hypot (const Type &x, const Type &y) |
Compute hypotenuse. More... | |
template<typename Type > | |
static int | ilogb (const Type &x) |
Integer binary logarithm. More... | |
template<typename Type > | |
static bool | isinf (const Type &x) |
Is infinity. More... | |
template<typename Type > | |
static bool | isnan (const Type &x) |
Is Not-A-Number. More... | |
static double | nan (const char *tagp) |
Generate quiet NaN. More... | |
static float | nanf (const char *tagp) |
Generate quiet NaN. More... | |
template<typename Type > | |
static bool | ldexp (const Type &x, int exp) |
Generate value from significand and exponent. More... | |
template<typename Type > | |
static Type | log1p (const Type &x) |
Compute logarithm plus one. More... | |
template<typename Type > | |
static Type | log2 (const Type &x) |
Compute binary logarithm. More... | |
template<typename Type > | |
static Type | logb (const Type &x) |
Compute floating-point base logarithm. More... | |
template<typename Type > | |
static Type | modf (const Type &x, Type *intpart) |
Break into fractional and integral parts. More... | |
template<typename Type > | |
static Type | modf (const Type &x, const int8_t *tagp) |
Generate quiet NaN. More... | |
template<typename Type > | |
static Type | nextafter (const Type &x, const Type &y) |
Next representable value. More... | |
template<typename Type > | |
static Type | remainder (const Type &numer, const Type &denom) |
Compute remainder (IEC 60559) More... | |
template<typename Type > | |
static Type | remquo (const Type &numer, const Type &denom, int *quot) |
Compute remainder and quotient. More... | |
template<typename Type > | |
static Type | rint (const Type &x) |
Round to integral value. More... | |
template<typename Type > | |
static Type | scalbln (const Type &x, long int n) |
Scale significand using floating-point base exponent (long) More... | |
template<typename Type > | |
static Type | scalbn (const Type &x, int n) |
Scale significand using floating-point base exponent. More... | |
template<typename Type > | |
static Type | trunc (const Type &x) |
Truncate value. More... | |
Mathematical utility functions.
Pure static class.
|
inlinestatic |
Find absolute value of a given input.
value | The value to which absolute value has to be calculated. |
|
inlinestatic |
Computes the arccos of arg.
value | the value to compute |
|
inlinestatic |
Computes the acosh of arg (measured in radians)
value | representing in radians |
|
inlinestatic |
Compares two floating point arrays.
left | Pointer to first array. |
right | Pointer to second array. |
size | Number of elements of each array. |
|
inlinestatic |
Compares two floating point numbers.
left | First number. |
right | Second number. |
|
inlinestatic |
Compares two numbers.
left | First number. |
right | Second number. |
|
inlinestatic |
Computes the arsin of arg.
value | the value to compute |
|
inlinestatic |
Computes the arsinh of arg (measured in radians)
value | representing in radians |
|
inlinestatic |
Computes the arctan of arg.
value | the value |
|
inlinestatic |
Computes the arc tangent of y/x using the signs of arguments to determine the correct quadrant.
x | value x |
y | value y |
|
inlinestatic |
Computes the inverse hyperbolic tangent of arg.
value | the value |
|
inlinestatic |
Returns a value with the magnitude of x and the sign of y.
x | Value with the magnitude of the resulting value. |
y | Value with the sign of the resulting value. |
|
inlinestatic |
Computes the cosine of arg (measured in radians)
value | representing in radians |
|
inlinestatic |
Computes the cosh of arg (measured in radians)
value | representing in radians |
|
inlinestatic |
Compute error function.
x | Parameter for the error function. |
|
inlinestatic |
Compute complementary error function.
x | Parameter for the complementary error function. |
|
inlinestatic |
Computes e (Euler's number, 2.7182818...) raised to the given power arg.
value | the exponent n |
|
inlinestatic |
Compute exponential minus one.
Returns e raised to the power x minus one: ex-1. For small magnitude values of x, expm1 may be more accurate than exp(x)-1.
x | Value of the exponent. |
|
inlinestatic |
Find absolute value of a given input.
value | The value to which absolute value has to be calculated. |
|
inlinestatic |
Positive difference.
Returns the positive difference between x and y. The function returns x-y if x>y, and zero otherwise.
x | Values whose difference is calculated. |
y | Values whose difference is calculated. |
|
inlinestatic |
Round down value.
Rounds x downward, returning the largest integral value that is not greater than x.
x | Value to round down. |
|
inlinestatic |
Compute remainder of division.
Returns the floating-point remainder of numer/denom (rounded towards zero):
fmod = numer - tquot * denom
numer | Value of the quotient numerator. |
denom | Value of the quotient denominator. |
|
inlinestatic |
Get significand and exponent.
Breaks the floating point number x into its binary significand (a floating point with an absolute value between 0.5(included) and 1.0(excluded)) and an integral exponent for 2, such that:
x = significand * 2 exponent The exponent is stored in the location pointed by exp, and the significand is the value returned by the function.
If x is zero, both parts (significand and exponent) are zero. If x is negative, the significand returned by this function is negative.
x | Value to be decomposed. |
exp | Pointer to an int where the value of the exponent is stored. |
|
inlinestatic |
Compute hypotenuse.
Returns the hypotenuse of a right-angled triangle whose legs are x and y.
The function returns what would be the square root of the sum of the squares of x and y (as per the Pythagorean theorem), but without incurring in undue overflow or underflow of intermediate values.
x | Floating point values corresponding to the legs of a right-angled triangle for which the hypotenuse is computed. |
y | Floating point values corresponding to the legs of a right-angled triangle for which the hypotenuse is computed. |
|
inlinestatic |
Integer binary logarithm.
Returns the integral part of the logarithm of |x|, using FLT_RADIX as base for the logarithm.
This is the exponent used internally by the machine to express the floating-point value x, when it uses a significand between 1.0 and FLT_RADIX, so that, for a positive x:
x = significand * FLT_RADIX exponent
Generally, FLT_RADIX is 2, and the value returned by this function is one less than the exponent obtained with frexp (because of the different significand normalization as [1.0,2.0) instead of [0.5,1.0)).
x | Value whose ilogb is returned. |
|
inlinestatic |
Is infinity.
Returns whether x is an infinity value (either positive infinity or negative infinity).
x | A floating-point value. |
|
inlinestatic |
Is Not-A-Number.
Returns whether x is a NaN (Not-A-Number) value.
The NaN values are used to identify undefined or non-representable values for floating-point elements, such as the square root of negative numbers or the result of 0/0.
x | A floating-point value. |
|
inlinestatic |
Generate value from significand and exponent.
Returns the result of multiplying x (the significand) by 2 raised to the power of exp (the exponent).
lexpr(x,exp) = x * 2 exp
x | Floating point value representing the significand. |
exp | Value of the exponent. |
x * 2 exp
If the magnitude of the result is too large to be represented by a value of the return type, the function returns HUGE_VAL (or HUGE_VALF or HUGE_VALL) with the proper sign.
|
inlinestatic |
Computes the natural (base e) logarithm of arg.
arg | the value |
|
inlinestatic |
Computes the common (base-10) logarithm of n.
arg | the value n |
|
inlinestatic |
Compute logarithm plus one.
Returns the natural logarithm of one plus x.
For small magnitude values of x, logp1 may be more accurate than log(1+x).
x | Value whose logarithm is calculated. |
|
inlinestatic |
Compute binary logarithm.
Returns the binary (base-2) logarithm of x.
x | Value whose logarithm is calculated. |
|
inlinestatic |
Compute floating-point base logarithm.
Returns the logarithm of |x|, using FLT_RADIX as base for the logarithm.
On most platforms, FLT_RADIX is 2, and thus this function is equivalent to log2 for positive values.
x | Value whose logarithm is calculated. |
|
inlinestatic |
Generate quiet NaN.
Returns a quiet NaN (Not-A-Number) value of type double.
The NaN values are used to identify undefined or non-representable values for floating-point elements, such as the square root of negative numbers or the result of 0/0.
The argument can be used by library implementations to distinguish different NaN values in a implementation-specific manner.
Similarly, nanf and nanl return NaN values of type float and long double, respectively.
x | Floating point value to break into parts. |
tagp | An implementation-specific C-string. If this is an empty string (""), the function returns a generic NaN value (the same as returned by passing "NAN" to strtod). |
|
inlinestatic |
Break into fractional and integral parts.
Breaks x into an integral and a fractional part.
The integer part is stored in the object pointed by intpart, and the fractional part is returned by the function. Both parts have the same sign as x.
x | Floating point value to break into parts. |
intpart | Pointer to an object (of the same type as x) where the integral part is stored with the same sign as x. |
|
inlinestatic |
Generate quiet NaN.
Returns a quiet NaN (Not-A-Number) value of type double.
The NaN values are used to identify undefined or non-representable values for floating-point elements, such as the square root of negative numbers or the result of 0/0.
The argument can be used by library implementations to distinguish different NaN values in a implementation-specific manner.
Similarly, nanf and nanl return NaN values of type float and long double, respectively.
tagp | An implementation-specific C-string. If this is an empty string (""), the function returns a generic NaN value (the same as returned by passing "NAN" to strtod). |
|
inlinestatic |
Generate quiet NaN.
Returns a quiet NaN (Not-A-Number) value of type float.
The NaN values are used to identify undefined or non-representable values for floating-point elements, such as the square root of negative numbers or the result of 0/0.
The argument can be used by library implementations to distinguish different NaN values in a implementation-specific manner.
Similarly, nanf and nanl return NaN values of type float and long float, respectively.
tagp | An implementation-specific C-string. If this is an empty string (""), the function returns a generic NaN value (the same as returned by passing "NAN" to strtod). |
|
inlinestatic |
Next representable value.
Returns the next representable value after x in the direction of y.
The similar function, nexttoward has the same behavior, but it takes a long double as second argument.
If both parameters compare equal, the function returns y.
x | Base value |
y | Value toward which the return value is approximated. |
|
inlinestatic |
|
inlinestatic |
Find n-th root of a value.
sqVal | The value to which square root has to be calculated. |
n | The root type |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlinestatic |
Computes the value of base (m) raised to the power exponent (n)
base | the base m |
exp | the exponent n |
Computes the value of 10 raised to the power exp.
exp | the exponent n |
|
inlinestatic |
Compute remainder (IEC 60559)
Returns the floating-point remainder of numer/denom (rounded to nearest):
remainder = numer - rquot * denom
Where rquot is the result of: numer/denom, rounded toward the nearest integral value (with halfway cases rounded toward the even number).
numer | Value of the quotient numerator. |
denom | Value of the quotient denominator. |
|
inlinestatic |
Compute remainder and quotient.
Returns the same as remainder, but it additionally stores the quotient internally used to determine its result in the object pointed by quot.
The value pointed by quot contains the congruent modulo with at least 3 bits of the integral quotient numer/denom.
numer | Value of the quotient numerator. |
denom | Value of the quotient denominator. |
quot | Pointer to an object where the quotient internally used to determine the remainder is stored as a value of type int. |
|
inlinestatic |
Round to integral value.
Rounds x to an integral value, using the rounding direction specified by fegetround.
This function may raise an FE_INEXACT exception if the value returned differs in value from x. See nearbyint for an equivalent function that cannot raise such exception.
x | Value to round. |
|
inlinestatic |
Scale significand using floating-point base exponent (long)
Scales x by FLT_RADIX raised to the power of n, returning the result of computing:
scalbn(x,n) = x * FLT_RADIXn
Presumably, x and n are the components of a floating-point number in the system; In such a case, this function may be optimized to be more efficient than the theoretical operations to compute the value explicitly.
There also exists another version of this function: scalbn, which is identical, except that it takes an int as second argument.
x | floating point value |
n | integer value |
|
inlinestatic |
Scale significand using floating-point base exponent.
Scales x by FLT_RADIX raised to the power of n, returning the same as::
scalbn(x,n) = x * FLT_RADIXn
Presumably, x and n are the components of a floating-point number in the system; In such a case, this function may be optimized to be more efficient than the theoretical operations to compute the value explicitly.
On most platforms, FLT_RADIX is 2, making this function equivalent to ldexp.
x | Value representing the significand. |
n | Value of the exponent. |
|
inlinestatic |
Computes the sine of arg (measured in radians)
value | representing in radians |
|
inlinestatic |
Computes the sinh of arg (measured in radians)
value | representing in radians |
|
inlinestatic |
Find square root of a value.
sqVal | The value to which square root has to be calculated. |
|
inlinestatic |
Computes the tangens of arg (measured in radians)
value | representing in radians |
|
inlinestatic |
Computes the tanh of arg (measured in radians)
value | representing in radians |
|
inlinestatic |
Truncate value.
Rounds x toward zero, returning the nearest integral value that is not larger in magnitude than x.
x | Value to truncate. |