37 #ifndef MPBLOCKS_CUDA_POWERS_OF_TWO_H 
   38 #define MPBLOCKS_CUDA_POWERS_OF_TWO_H 
   73     return ((x&(x-1))==0);
 
  101 template <
typename T>
 
  107     for(
unsigned int i=1; i <= 
sizeof(T)*CHAR_BIT; i++)
 
  136 template <
typename T>
 
  181 template <
typename T>
 
  184     if (p == 0) 
return 1;
 
  185     if (p == 1) 
return x;
 
  186     return x * intPow<T>(
x, p-1);
 
  196 template <
typename T>
 
  213 template <
typename T>
 
  224         while(  (x & 1) == 0 )
 
  240 template <
typename T>
 
  253 template <
typename T>
 
  269 template <
typename T>
 
  282 template <
typename T>
 
  285     return ((x & 0x01) == 0x01);
 
  294 template <
typename T>
 
  297     return ((x & 0x01) == 0x00);
 
  307 template <
unsigned int I, 
typename T>
 
  310     return x & (0x01 << I);
 
  320 template <
typename T>
 
  331 #endif //#ifndef POWERS_OF_TWO_H 
T log2(T x)
if x is a power of two then it returns the log of x with base 2 
T getBit(T x)
returns the value of the specified bit 
T intPow(T x, T p)
returns x to the power of p 
T times2(const T &x)
returns x*2 (using bit shift) 
T twoPow(T x)
returns 2 to the power of x (2^x) 
T intDivideRoundUp(T x, T y)
integer divide with round up 
T isOdd(T x)
returns true if the number is odd 
bool isPow2(T x)
returns true if the parameter is an exact power of two 
T dividePow2(T x, T y)
returns x/y if x and y are both powers of two, otherwise the result is undefined 
T prevPow2(T x)
returns the largest power of two that is not greater than x 
T isEven(T x)
returns true if the number is even 
T divideBy2(const T &x)
returns x/2 (using bit shift), if x is odd then the result is floor(x/2) 
T nextPow2(T x)
returns the smallest power of two that is not less than x