LvArray
LvArray::math Namespace Reference

Contains protable wrappers around cmath functions and some cuda specific functions. More...

Functions

Square root and inverse square root.
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE float sqrt (float const x)
 
template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE double sqrt (T const x)
 
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE float invSqrt (float const x)
 
template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE double invSqrt (T const x)
 
Trigonometric functions
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE float sin (float const theta)
 
template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE double sin (T const theta)
 
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE float cos (float const theta)
 
template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE double cos (T const theta)
 
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE void sincos (float const theta, float &sinTheta, float &cosTheta)
 Compute the sine and cosine of theta. More...
 
template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE void sincos (double const theta, double &sinTheta, double &cosTheta)
 Compute the sine and cosine of theta. More...
 
template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE void sincos (T const theta, double &sinTheta, double &cosTheta)
 Compute the sine and cosine of theta. More...
 
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE float tan (float const theta)
 
template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE double tan (T const theta)
 
Inverse trigonometric functions
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE float asin (float const x)
 
template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE double asin (T const x)
 
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE float acos (float const x)
 
template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE double acos (T const x)
 
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE float atan2 (float const y, float const x)
 
template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE double atan2 (T const y, T const x)
 
Exponential functions
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE float exp (float const x)
 
template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE double exp (T const x)
 
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE float log (float const x)
 
template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE double log (T const x)
 

General purpose functions

template<typename T >
using SingleType = typename internal::SingleType< T >::type
 The type of a single value of type T. More...
 
template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE constexpr int numValues ()
 Return the number of values stored in type. More...
 
template<typename T , typename U >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE constexpr T convert (U const u)
 Convert u to type. More...
 
template<typename T , typename U , typename V >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE constexpr T convert (U const u, V const v)
 Convert u and v to a dual type. More...
 
template<typename T >
LVARRAY_DEVICE LVARRAY_FORCE_INLINE SingleType< T > getFirst (T const x)
 
template<typename T >
LVARRAY_DEVICE LVARRAY_FORCE_INLINE SingleType< T > getSecond (T const x)
 
template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE constexpr std::enable_if_t< std::is_arithmetic< T >::value, T > max (T const a, T const b)
 
template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE constexpr std::enable_if_t< std::is_arithmetic< T >::value, T > min (T const a, T const b)
 
template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE constexpr T abs (T const x)
 
template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE constexpr T square (T const x)
 

Detailed Description

Contains protable wrappers around cmath functions and some cuda specific functions.

Typedef Documentation

◆ SingleType

template<typename T >
using LvArray::math::SingleType = typedef typename internal::SingleType< T >::type

The type of a single value of type T.

Template Parameters
TThe type to query.

Function Documentation

◆ abs()

template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE constexpr T LvArray::math::abs ( T const  x)
Returns
The absolute value of x.
Parameters
xThe number to get the absolute value of.
Note
This set of overloads is valid for any numeric type.

◆ acos() [1/2]

LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE float LvArray::math::acos ( float const  x)
Returns
The arccosine of the value x.
Parameters
xThe value to get the arccosine of, must be in [-1, 1].
Note
This set of overloads is valid for any numeric type. If x is integral it is converted to double and the return type is double.

◆ acos() [2/2]

template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE double LvArray::math::acos ( T const  x)

Returns
The arccosine of the value x.
Parameters
xThe value to get the arccosine of, must be in [-1, 1].
Note
This set of overloads is valid for any numeric type. If x is integral it is converted to double and the return type is double.

◆ asin() [1/2]

LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE float LvArray::math::asin ( float const  x)
Returns
The arcsine of the value x.
Parameters
xThe value to get the arcsine of, must be in [-1, 1].
Note
This set of overloads is valid for any numeric type. If x is integral it is converted to double and the return type is double.

◆ asin() [2/2]

template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE double LvArray::math::asin ( T const  x)

Returns
The arcsine of the value x.
Parameters
xThe value to get the arcsine of, must be in [-1, 1].
Note
This set of overloads is valid for any numeric type. If x is integral it is converted to double and the return type is double.

◆ atan2() [1/2]

LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE float LvArray::math::atan2 ( float const  y,
float const  x 
)
Returns
The angle corresponding to the point (x, y).
Parameters
yThe y coordinate.
xThe x coordinate.
Note
This set of overloads is valid for any numeric type. If x is integral it is converted to double and the return type is double.

◆ atan2() [2/2]

template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE double LvArray::math::atan2 ( T const  y,
T const  x 
)

Returns
The angle corresponding to the point (x, y).
Parameters
yThe y coordinate.
xThe x coordinate.
Note
This set of overloads is valid for any numeric type. If x is integral it is converted to double and the return type is double.

◆ convert() [1/2]

template<typename T , typename U >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE constexpr T LvArray::math::convert ( U const  u)

Convert u to type.

Template Parameters
T.
TThe type to convert to.
UThe type to convert from.
Parameters
uThe value to convert.
Note
No checking is done to ensure the conversion is safe. Ie you could convert -1 to uint.
Returns
u converted to
Template Parameters
T.

◆ convert() [2/2]

template<typename T , typename U , typename V >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE constexpr T LvArray::math::convert ( U const  u,
V const  v 
)

Convert u and v to a dual type.

Template Parameters
T.
TThe type to convert to, must hold two values such as __half2.
UThe first type to convert from.
UThe second type to convert from.
Parameters
uThe first value to convert.
vThe second value to convert.
Note
No checking is done to ensure the conversion is safe. Ie you could convert -1 to uint.
Returns
u, v converted to
Template Parameters
T.

◆ cos() [1/2]

LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE float LvArray::math::cos ( float const  theta)
Returns
The cosine of theta.
Parameters
thetaThe angle in radians.
Note
This set of overloads is valid for any numeric type. If theta is not a float it is converted to a double and the return type is double.

◆ cos() [2/2]

template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE double LvArray::math::cos ( T const  theta)

Returns
The cosine of theta.
Parameters
thetaThe angle in radians.
Note
This set of overloads is valid for any numeric type. If theta is not a float it is converted to a double and the return type is double.

◆ exp() [1/2]

LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE float LvArray::math::exp ( float const  x)
Returns
e raised to the x.
Parameters
xThe power to raise e to.
Note
This set of overloads is valid for any numeric type. If x is integral it is converted to double and the return type is double.

◆ exp() [2/2]

template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE double LvArray::math::exp ( T const  x)

Returns
e raised to the x.
Parameters
xThe power to raise e to.
Note
This set of overloads is valid for any numeric type. If x is integral it is converted to double and the return type is double.

◆ getFirst()

template<typename T >
LVARRAY_DEVICE LVARRAY_FORCE_INLINE SingleType< T > LvArray::math::getFirst ( T const  x)
Returns
The fist value in x.
Template Parameters
TThe type of x.
Parameters
xThe value to query.
Note
If
numValues< T >() == 1
then x is returned.

◆ getSecond()

template<typename T >
LVARRAY_DEVICE LVARRAY_FORCE_INLINE SingleType< T > LvArray::math::getSecond ( T const  x)
Returns
The second value in x.
Template Parameters
TThe type of x.
Parameters
xThe value to query.
Note
If
numValues< T >() == 1
then x is returned.

◆ invSqrt() [1/2]

LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE float LvArray::math::invSqrt ( float const  x)
Returns
One over the square root of x.
Parameters
xThe number to get the inverse square root of.
Note
This set of overloads is valid for any numeric type. If x is integral it is converted to double and the return type is double.

◆ invSqrt() [2/2]

template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE double LvArray::math::invSqrt ( T const  x)

Returns
One over the square root of x.
Parameters
xThe number to get the inverse square root of.
Note
This set of overloads is valid for any numeric type. If x is integral it is converted to double and the return type is double.

◆ log() [1/2]

LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE float LvArray::math::log ( float const  x)
Returns
The natural logarithm of x.
Parameters
xThe number to get the natural logarithm of.
Note
This set of overloads is valid for any numeric type. If x is integral it is converted to double and the return type is double.

◆ log() [2/2]

template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE double LvArray::math::log ( T const  x)

Returns
The natural logarithm of x.
Parameters
xThe number to get the natural logarithm of.
Note
This set of overloads is valid for any numeric type. If x is integral it is converted to double and the return type is double.

◆ max()

template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE constexpr std::enable_if_t< std::is_arithmetic< T >::value, T > LvArray::math::max ( T const  a,
T const  b 
)
Returns
Return the maximum of the numbers a and b.
Template Parameters
TA numeric type.
Parameters
aThe first number.
bThe second number.

◆ min()

template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE constexpr std::enable_if_t< std::is_arithmetic< T >::value, T > LvArray::math::min ( T const  a,
T const  b 
)
Returns
Return the minimum of the numbers a and b.
Template Parameters
TA numeric type.
Parameters
aThe first number.
bThe second number.

◆ numValues()

template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE constexpr int LvArray::math::numValues ( )

Return the number of values stored in type.

Template Parameters
T.
Parameters
TThe type to query.
Returns
The number of values stored in type
Template Parameters
T.

◆ sin() [1/2]

LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE float LvArray::math::sin ( float const  theta)
Returns
The sine of theta.
Parameters
thetaThe angle in radians.
Note
This set of overloads is valid for any numeric type. If x is integral it is converted to double and the return type is double.

◆ sin() [2/2]

template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE double LvArray::math::sin ( T const  theta)

Returns
The sine of theta.
Parameters
thetaThe angle in radians.
Note
This set of overloads is valid for any numeric type. If x is integral it is converted to double and the return type is double.

◆ sincos() [1/3]

LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE void LvArray::math::sincos ( float const  theta,
float &  sinTheta,
float &  cosTheta 
)

Compute the sine and cosine of theta.

Parameters
thetaThe angle in radians.
sinThetaThe sine of theta.
cosThetaThe cosine of theta.

◆ sincos() [2/3]

template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE void LvArray::math::sincos ( double const  theta,
double &  sinTheta,
double &  cosTheta 
)

Compute the sine and cosine of theta.

Parameters
thetaThe angle in radians.
sinThetaThe sine of theta.
cosThetaThe cosine of theta.

◆ sincos() [3/3]

template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE void LvArray::math::sincos ( T const  theta,
double &  sinTheta,
double &  cosTheta 
)

Compute the sine and cosine of theta.

Parameters
thetaThe angle in radians.
sinThetaThe sine of theta.
cosThetaThe cosine of theta.

◆ sqrt() [1/2]

LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE float LvArray::math::sqrt ( float const  x)
Returns
The square root of x.
Parameters
xThe number to get the square root of.
Note
This set of overloads is valid for any numeric type. If x is integral it is converted to double and the return type is double.

◆ sqrt() [2/2]

template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE double LvArray::math::sqrt ( T const  x)

Returns
The square root of x.
Parameters
xThe number to get the square root of.
Note
This set of overloads is valid for any numeric type. If x is integral it is converted to double and the return type is double.

◆ square()

template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE constexpr T LvArray::math::square ( T const  x)
Returns
x * x
.
Template Parameters
TThe typeof x.
Parameters
xThe value to square.

◆ tan() [1/2]

LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE float LvArray::math::tan ( float const  theta)
Returns
The tangent of theta.
Parameters
thetaThe angle in radians.
Note
This set of overloads is valid for any numeric type. If theta is not a float it is converted to a double and the return type is double.

◆ tan() [2/2]

template<typename T >
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE double LvArray::math::tan ( T const  theta)

Returns
The tangent of theta.
Parameters
thetaThe angle in radians.
Note
This set of overloads is valid for any numeric type. If theta is not a float it is converted to a double and the return type is double.