|
cheshirekow
v0.1.0
|
Functions | |
| template<typename T > | |
| 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 > | |
| 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 > | |
| T | mpblocks::cuda::getBit (T x) |
| returns the value of the specified bit More... | |
| template<typename T > | |
| T | mpblocks::cuda::intDivideRoundUp (T x, T y) |
| integer divide with round up More... | |
| template<typename T > | |
| T | mpblocks::cuda::intPow (T x, T p) |
returns x to the power of p More... | |
| template<typename T > | |
| T | mpblocks::cuda::isEven (T x) |
| returns true if the number is even More... | |
| template<typename T > | |
| 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 > | |
| 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 > | |
| T | mpblocks::cuda::nextPow2 (T x) |
returns the smallest power of two that is not less than x More... | |
| template<typename T > | |
| T | mpblocks::cuda::times2 (const T &x) |
| returns x*2 (using bit shift) More... | |
| template<typename T > | |
| T | mpblocks::cuda::twoPow (T x) |
returns 2 to the power of x (2^x) More... | |
Contains inline template functions with meaningful names that use bitwise operators to do the actual math
|
inline |
returns x/2 (using bit shift), if x is odd then the result is floor(x/2)
Definition at line 254 of file powersOfTwo.h.
|
inline |
returns x/y if x and y are both powers of two, otherwise the result is undefined
Definition at line 321 of file powersOfTwo.h.
|
inline |
returns the value of the specified bit
Definition at line 308 of file powersOfTwo.h.
|
inline |
integer divide with round up
returns the smallest integer not less than x/y (i.e. if x/y is a whole number then it returns x/y, otherwise it returns ceil(x/y) )
Definition at line 270 of file powersOfTwo.h.
|
inline |
returns x to the power of p
For Example
(x,y) : x^y ---------------- (1,0) : 1 (1,1) : 1 (1,2) : 1 (1,3) : 1 (1,4) : 1 (2,0) : 1 (2,1) : 2 (2,2) : 4 (2,3) : 8 (2,4) : 16 (3,0) : 1 (3,1) : 3 (3,2) : 9 (3,3) : 27 (3,4) : 81 (4,0) : 1 (4,1) : 4 (4,2) : 16 (4,3) : 64 (4,4) : 256
Definition at line 182 of file powersOfTwo.h.
|
inline |
returns true if the number is even
Definition at line 295 of file powersOfTwo.h.
|
inline |
returns true if the number is odd
Definition at line 283 of file powersOfTwo.h.
|
inline |
returns true if the parameter is an exact power of two
As an example:
2 : true
4 : true
8 : true
16 : true
1 : true
2 : true
3 : false
4 : true
5 : false
6 : false
7 : false
8 : true
Definition at line 71 of file powersOfTwo.h.
|
inline |
if x is a power of two then it returns the log of x with base 2
In other words if
then this function returns
. If x is not in fact a power of two, then the output is unspecified (though I guess it's similar to prevPow2
Definition at line 214 of file powersOfTwo.h.
|
inline |
returns the smallest power of two that is not less than x
If x is a power of two, then it returns x. If it is not a power of two, it returns the next higher one.
For example:
x prev next
------ ------ ------
0 : 0 0
1 : 1 1
2 : 2 2
3 : 2 4
4 : 4 4
5 : 4 8
6 : 4 8
7 : 4 8
8 : 8 8
Definition at line 102 of file powersOfTwo.h.
|
inline |
returns x*2 (using bit shift)
Definition at line 241 of file powersOfTwo.h.
|
inline |
returns 2 to the power of x (2^x)
Definition at line 197 of file powersOfTwo.h.