cheshirekow  v0.1.0
powersOfTwo.h File Reference

inline functions for fast math involving powers of two More...

#include <climits>

Go to the source code of this file.

Namespaces

 mpblocks
 
 mpblocks::cuda
 

Functions

template<typename T >
mpblocks::cuda::divideBy2 (const T &x)
 returns x/2 (using bit shift), if x is odd then the result is floor(x/2) More...
 
template<typename T >
mpblocks::cuda::dividePow2 (T x, T y)
 returns x/y if x and y are both powers of two, otherwise the result is undefined More...
 
template<unsigned int I, typename T >
mpblocks::cuda::getBit (T x)
 returns the value of the specified bit More...
 
template<typename T >
mpblocks::cuda::intDivideRoundUp (T x, T y)
 integer divide with round up More...
 
template<typename T >
mpblocks::cuda::intPow (T x, T p)
 returns x to the power of p More...
 
template<typename T >
mpblocks::cuda::isEven (T x)
 returns true if the number is even More...
 
template<typename T >
mpblocks::cuda::isOdd (T x)
 returns true if the number is odd More...
 
template<typename T >
bool mpblocks::cuda::isPow2 (T x)
 returns true if the parameter is an exact power of two More...
 
template<typename T >
mpblocks::cuda::log2 (T x)
 if x is a power of two then it returns the log of x with base 2 More...
 
template<typename T >
mpblocks::cuda::nextPow2 (T x)
 returns the smallest power of two that is not less than x More...
 
template<typename T >
mpblocks::cuda::prevPow2 (T x)
 returns the largest power of two that is not greater than x More...
 
template<typename T >
mpblocks::cuda::times2 (const T &x)
 returns x*2 (using bit shift) More...
 
template<typename T >
mpblocks::cuda::twoPow (T x)
 returns 2 to the power of x (2^x) More...
 

Detailed Description

inline functions for fast math involving powers of two

Date
Feb 28, 2011
Author
Josh Bialkowski (jbial.nosp@m.k@mi.nosp@m.t.edu) These functions aren't antything special, it just makes the code a lot easier to read instead of trying to decode all these bit operations

Definition in file powersOfTwo.h.