16 #include "LvArrayConfig.hpp" 21 #include <type_traits> 43 template<
typename T >
45 std::enable_if_t< std::is_arithmetic< T >::value, T >
46 max( T
const a, T
const b )
48 #if defined(__CUDA_ARCH__) 49 static_assert( std::is_same< decltype( ::
max( a, b ) ), T >::value,
"Should return a T." );
62 template<
typename T >
64 std::enable_if_t< std::is_arithmetic< T >::value, T >
65 min( T
const a, T
const b )
67 #if defined(__CUDA_ARCH__) 68 static_assert( std::is_same< decltype( ::
min( a, b ) ), T >::value,
"Should return a T." );
81 float abs(
float const x )
82 { return ::fabsf( x ); }
86 double abs(
double const x )
87 { return ::fabs( x ); }
93 template<
typename T >
95 std::enable_if_t< std::is_integral< T >::value, T >
98 #if defined(__CUDA_ARCH__) 99 static_assert( std::is_same< decltype( ::
abs( x ) ), T >::value,
"Should return a T." );
102 static_assert( std::is_same< decltype(
std::abs( x ) ), T >::value,
"Should return a T." );
122 { return ::sqrtf( x ); }
128 template<
typename T >
130 std::enable_if_t< std::is_arithmetic< T >::value,
double >
133 #if defined(__CUDA_ARCH__) 149 #if defined(__CUDA_ARCH__) 150 return ::rsqrtf( x );
160 template<
typename T >
162 std::enable_if_t< std::is_arithmetic< T >::value,
double >
165 #if defined(__CUDACC__) 166 return ::rsqrt(
double( x ) );
184 float sin(
float const theta )
185 { return ::sinf( theta ); }
189 double sin(
double const theta )
197 float cos(
float const theta )
198 { return ::cosf( theta ); }
202 double cos(
double const theta )
210 float tan(
float const theta )
211 { return ::tanf( theta ); }
215 double tan(
double const theta )
225 void sincos(
float const theta,
float & sinTheta,
float & cosTheta )
227 #if defined(__CUDACC__) 228 ::sincosf( theta, &sinTheta, &cosTheta );
230 sinTheta =
::sin( theta );
231 cosTheta =
::cos( theta );
237 void sincos(
double const theta,
double & sinTheta,
double & cosTheta )
239 #if defined(__CUDACC__) 240 ::sincos( theta, &sinTheta, &cosTheta );
242 sinTheta =
::sin( theta );
243 cosTheta =
::cos( theta );
260 { return ::asinf( x ); }
273 { return ::acosf( x ); }
286 float atan2(
float const y,
float const x )
287 { return ::atan2f( y, x ); }
291 double atan2(
double const y,
double const x )
float sin(float const theta)
double asin(double const x)
double atan2(double const y, double const x)
std::enable_if_t< std::is_integral< T >::value, T > abs(T const x)
double sin(double const theta)
float sqrt(float const x)
float tan(float const theta)
double tan(double const theta)
double cos(double const theta)
float acos(float const x)
float invSqrt(float const x)
void sincos(float const theta, float &sinTheta, float &cosTheta)
Compute the sine and cosine of theta.
std::enable_if_t< std::is_arithmetic< T >::value, double > sqrt(T const x)
float asin(float const x)
Contains a bunch of macro definitions.
double acos(double const x)
constexpr std::enable_if_t< std::is_arithmetic< T >::value, T > min(T const a, T const b)
constexpr std::enable_if_t< std::is_arithmetic< T >::value, T > max(T const a, T const b)
#define LVARRAY_HOST_DEVICE
Mark a function for both host and device usage.
float atan2(float const y, float const x)
float cos(float const theta)