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 float sqrt (float const x)
 
template<typename T >
LVARRAY_HOST_DEVICE double sqrt (T const x)
 
LVARRAY_HOST_DEVICE float invSqrt (float const x)
 
template<typename T >
LVARRAY_HOST_DEVICE double invSqrt (T const x)
 
Trigonometric functions
LVARRAY_HOST_DEVICE float sin (float const theta)
 
template<typename T >
LVARRAY_HOST_DEVICE double sin (T const theta)
 
LVARRAY_HOST_DEVICE float cos (float const theta)
 
template<typename T >
LVARRAY_HOST_DEVICE double cos (T const theta)
 
LVARRAY_HOST_DEVICE void sincos (float const theta, float &sinTheta, float &cosTheta)
 Compute the sine and cosine of theta. More...
 
template<typename T >
LVARRAY_HOST_DEVICE void sincos (double const theta, double &sinTheta, double &cosTheta)
 Compute the sine and cosine of theta. More...
 
template<typename T >
LVARRAY_HOST_DEVICE void sincos (T const theta, double &sinTheta, double &cosTheta)
 Compute the sine and cosine of theta. More...
 
LVARRAY_HOST_DEVICE float tan (float const theta)
 
template<typename T >
LVARRAY_HOST_DEVICE double tan (T const theta)
 
Inverse trigonometric functions
LVARRAY_HOST_DEVICE float asin (float const x)
 
template<typename T >
LVARRAY_HOST_DEVICE double asin (T const x)
 
LVARRAY_HOST_DEVICE float acos (float const x)
 
template<typename T >
LVARRAY_HOST_DEVICE double acos (T const x)
 
LVARRAY_HOST_DEVICE float atan2 (float const y, float const x)
 
template<typename T >
LVARRAY_HOST_DEVICE double atan2 (T const y, T const x)
 
Exponential functions
LVARRAY_HOST_DEVICE float exp (float const x)
 
template<typename T >
LVARRAY_HOST_DEVICE double exp (T const x)
 
LVARRAY_HOST_DEVICE float log (float const x)
 
template<typename T >
LVARRAY_HOST_DEVICE 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 constexpr int numValues ()
 Return the number of values stored in type. More...
 
template<typename T , typename U >
LVARRAY_HOST_DEVICE constexpr T convert (U const u)
 Convert u to type. More...
 
template<typename T , typename U , typename V >
LVARRAY_HOST_DEVICE constexpr T convert (U const u, V const v)
 Convert u and v to a dual type. More...
 
template<typename T >
LVARRAY_DEVICE SingleType< T > getFirst (T const x)
 
template<typename T >
LVARRAY_DEVICE SingleType< T > getSecond (T const x)
 
template<typename T >
LVARRAY_HOST_DEVICE constexpr std::enable_if_t< std::is_arithmetic< T >::value, T > max (T const a, T const b)
 
template<typename T >
LVARRAY_HOST_DEVICE constexpr std::enable_if_t< std::is_arithmetic< T >::value, T > min (T const a, T const b)
 
template<typename T >
LVARRAY_HOST_DEVICE constexpr T abs (T const x)
 
template<typename T >
LVARRAY_HOST_DEVICE 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 constexpr T LvArray::math::abs ( T const  x)
inline
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 float LvArray::math::acos ( float const  x)
inline
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 double LvArray::math::acos ( T const  x)
inline

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 float LvArray::math::asin ( float const  x)
inline
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 double LvArray::math::asin ( T const  x)
inline

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 float LvArray::math::atan2 ( float const  y,
float const  x 
)
inline
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 double LvArray::math::atan2 ( T const  y,
T const  x 
)
inline

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 constexpr T LvArray::math::convert ( U const  u)
inline

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 constexpr T LvArray::math::convert ( U const  u,
V const  v 
)
inline

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 float LvArray::math::cos ( float const  theta)
inline
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 double LvArray::math::cos ( T const  theta)
inline

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 float LvArray::math::exp ( float const  x)
inline
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 double LvArray::math::exp ( T const  x)
inline

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 SingleType< T > LvArray::math::getFirst ( T const  x)
inline
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 SingleType< T > LvArray::math::getSecond ( T const  x)
inline
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 float LvArray::math::invSqrt ( float const  x)
inline
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 double LvArray::math::invSqrt ( T const  x)
inline

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 float LvArray::math::log ( float const  x)
inline
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 double LvArray::math::log ( T const  x)
inline

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 constexpr std::enable_if_t< std::is_arithmetic< T >::value, T > LvArray::math::max ( T const  a,
T const  b 
)
inline
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 constexpr std::enable_if_t< std::is_arithmetic< T >::value, T > LvArray::math::min ( T const  a,
T const  b 
)
inline
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 constexpr int LvArray::math::numValues ( )
inline

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 float LvArray::math::sin ( float const  theta)
inline
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 double LvArray::math::sin ( T const  theta)
inline

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 void LvArray::math::sincos ( float const  theta,
float &  sinTheta,
float &  cosTheta 
)
inline

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 void LvArray::math::sincos ( double const  theta,
double &  sinTheta,
double &  cosTheta 
)
inline

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 void LvArray::math::sincos ( T const  theta,
double &  sinTheta,
double &  cosTheta 
)
inline

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 float LvArray::math::sqrt ( float const  x)
inline
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 double LvArray::math::sqrt ( T const  x)
inline

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 constexpr T LvArray::math::square ( T const  x)
inline
Returns
x * x
.
Template Parameters
TThe typeof x.
Parameters
xThe value to square.

◆ tan() [1/2]

LVARRAY_HOST_DEVICE float LvArray::math::tan ( float const  theta)
inline
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 double LvArray::math::tan ( T const  theta)
inline

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.