QUDA  1.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
math_helper.cuh
Go to the documentation of this file.
1 
6 namespace quda
7 {
8 
9  /*
10  @brief Fast power function that works for negative "a" argument
11  @param a argument we want to raise to some power
12  @param b power that we want to raise a to
13  @return pow(a,b)
14  */
15  template <typename real> __device__ __host__ inline real __fast_pow(real a, int b)
16  {
17 #ifdef __CUDA_ARCH__
18  if (sizeof(real) == sizeof(double)) {
19  return pow(a, b);
20  } else {
21  float sign = signbit(a) ? -1.0f : 1.0f;
22  float power = __powf(fabsf(a), b);
23  return b & 1 ? sign * power : power;
24  }
25 #else
26  return std::pow(a, b);
27 #endif
28  }
29 
30 } // namespace quda
__device__ __host__ real __fast_pow(real a, int b)
Definition: math_helper.cuh:15
__host__ __device__ ValueType pow(ValueType x, ExponentType e)
Definition: complex_quda.h:111