|
LvArray
|
Contains some portable math functions. More...


Go to the source code of this file.
Classes | |
| struct | LvArray::math::internal::SingleType< T > |
The type of a single value of type T. More... | |
Namespaces | |
| LvArray | |
| The top level namespace. | |
| LvArray::math | |
| Contains protable wrappers around cmath functions and some cuda specific functions. | |
Functions | |
| template<typename T , typename U > | |
| LVARRAY_HOST_DEVICE constexpr T | LvArray::math::internal::convert (T const, U const u) |
Convert u to type. More... | |
| template<typename T > | |
| LVARRAY_HOST_DEVICE constexpr int | LvArray::math::internal::numValues (T const) |
| Return the number of values stored in. More... | |
| template<typename T > | |
| LVARRAY_HOST_DEVICE constexpr SingleType< T > | LvArray::math::internal::getFirst (T const x) |
| template<typename T > | |
| LVARRAY_HOST_DEVICE constexpr SingleType< T > | LvArray::math::internal::getSecond (T const x) |
| template<typename T > | |
| LVARRAY_HOST_DEVICE constexpr T | LvArray::math::internal::lessThan (T const x, T const y) |
| template<typename T > | |
| LVARRAY_DEVICE T | LvArray::math::internal::asinImpl (T const x) |
| template<typename T > | |
| LVARRAY_DEVICE T | LvArray::math::internal::acosImpl (T const x) |
| template<typename T > | |
| LVARRAY_DEVICE T | LvArray::math::internal::atan2Impl (T const y, T const x) |
Square root and inverse square root. | |
| LVARRAY_HOST_DEVICE float | LvArray::math::sqrt (float const x) |
| template<typename T > | |
| LVARRAY_HOST_DEVICE double | LvArray::math::sqrt (T const x) |
| LVARRAY_HOST_DEVICE float | LvArray::math::invSqrt (float const x) |
| template<typename T > | |
| LVARRAY_HOST_DEVICE double | LvArray::math::invSqrt (T const x) |
Trigonometric functions | |
| LVARRAY_HOST_DEVICE float | LvArray::math::sin (float const theta) |
| template<typename T > | |
| LVARRAY_HOST_DEVICE double | LvArray::math::sin (T const theta) |
| LVARRAY_HOST_DEVICE float | LvArray::math::cos (float const theta) |
| template<typename T > | |
| LVARRAY_HOST_DEVICE double | LvArray::math::cos (T const theta) |
| LVARRAY_HOST_DEVICE void | LvArray::math::sincos (float const theta, float &sinTheta, float &cosTheta) |
Compute the sine and cosine of theta. More... | |
| template<typename T > | |
| LVARRAY_HOST_DEVICE void | LvArray::math::sincos (double const theta, double &sinTheta, double &cosTheta) |
Compute the sine and cosine of theta. More... | |
| template<typename T > | |
| LVARRAY_HOST_DEVICE void | LvArray::math::sincos (T const theta, double &sinTheta, double &cosTheta) |
Compute the sine and cosine of theta. More... | |
| LVARRAY_HOST_DEVICE float | LvArray::math::tan (float const theta) |
| template<typename T > | |
| LVARRAY_HOST_DEVICE double | LvArray::math::tan (T const theta) |
Inverse trigonometric functions | |
| LVARRAY_HOST_DEVICE float | LvArray::math::asin (float const x) |
| template<typename T > | |
| LVARRAY_HOST_DEVICE double | LvArray::math::asin (T const x) |
| LVARRAY_HOST_DEVICE float | LvArray::math::acos (float const x) |
| template<typename T > | |
| LVARRAY_HOST_DEVICE double | LvArray::math::acos (T const x) |
| LVARRAY_HOST_DEVICE float | LvArray::math::atan2 (float const y, float const x) |
| template<typename T > | |
| LVARRAY_HOST_DEVICE double | LvArray::math::atan2 (T const y, T const x) |
Exponential functions | |
| LVARRAY_HOST_DEVICE float | LvArray::math::exp (float const x) |
| template<typename T > | |
| LVARRAY_HOST_DEVICE double | LvArray::math::exp (T const x) |
| LVARRAY_HOST_DEVICE float | LvArray::math::log (float const x) |
| template<typename T > | |
| LVARRAY_HOST_DEVICE double | LvArray::math::log (T const x) |
General purpose functions | |
| template<typename T > | |
| using | LvArray::math::SingleType = typename internal::SingleType< T >::type |
The type of a single value of type T. More... | |
| template<typename T > | |
| LVARRAY_HOST_DEVICE constexpr int | LvArray::math::numValues () |
| Return the number of values stored in type. More... | |
| template<typename T , typename U > | |
| LVARRAY_HOST_DEVICE constexpr T | LvArray::math::convert (U const u) |
Convert u to type. More... | |
| template<typename T , typename U , typename V > | |
| LVARRAY_HOST_DEVICE constexpr T | LvArray::math::convert (U const u, V const v) |
Convert u and v to a dual type. More... | |
| template<typename T > | |
| LVARRAY_DEVICE SingleType< T > | LvArray::math::getFirst (T const x) |
| template<typename T > | |
| LVARRAY_DEVICE SingleType< T > | LvArray::math::getSecond (T const x) |
| 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) |
| 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) |
| template<typename T > | |
| LVARRAY_HOST_DEVICE constexpr T | LvArray::math::abs (T const x) |
| template<typename T > | |
| LVARRAY_HOST_DEVICE constexpr T | LvArray::math::square (T const x) |
Contains some portable math functions.
|
inline |
x. | x | The value to get the arcsine of, must be in [-1, 1]. |
Has a max error of 2.64e-3 and max relative error of 1.37e-3 for half precision.
|
inline |
x. | x | The value to get the arcsine of, must be in [-1, 1]. |
Has a max error of 1.36e-3 and max relative error of 6.95e-3 for half precision. The largeish relative error occurs where the algorithm transitions away from the small value approximation. The original algorithm didn't the small value approximation and it had huge (~3.0x) relative error, I believe due to the poor cancellation when subtracting from pi/2. acos doesn't have this problem and calculating asin as
led to the the same error. To improve precision you could always add in another term in the taylor series (x^3 / 6) but I don't think it's worth it.
|
inline |
x, y. | y | The y coordinate. |
| x | The x coordinate. |
Has a max error of 2.29e-3 and max relative error of 1.51e-3 for half precision.
|
inline |
Convert u to type.
| T. | |
| T | The type to convert to. |
| U | The type to convert from. |
| u | The value to convert. |
u converted to | T. |
|
inline |
x. | T | The type of x. |
| x | The value to return. |
|
inline |
x. | T | The type of x. |
| x | The value to return. |
|
inline |
x is less than y, else 0. | T | The type of x and y. |
| x | The first value. |
| y | The second value. |
|
inline |
Return the number of values stored in.
| T,by | default this is 1. |
| T | The type to query. |
| T,by | default this is 1. |
1.8.13