Speclib  0.1.2
The library for writing better CUDA libraries
Integer Math

Constexpr integer math, such as division that refuses to compile if the division has a remainder. More...

Functions

template<typename T , typename Q >
constexpr auto sp::divRoundUp (T x, Q y)
 Divide x by y, rounding up. More...
 
template<typename T , typename Q >
constexpr auto sp::roundUp (T x, Q to)
 Round x up to the next multiple of to More...
 
template<typename T , typename Q >
constexpr auto sp::roundDown (T x, Q to)
 Round x down to the next multiple of to More...
 
template<typename T >
constexpr auto sp::nextPowerOfTwo (T x)
 Get the next power of two >= x. More...
 
constexpr int sp::intSqrt (int n)
 Compile-time integer square root, hilariously. More...
 
template<int X, int Y>
constexpr int sp::divExact ()
 Compile-time pedantic divide. More...
 
template<typename IntT >
constexpr int sp::log2 (IntT x)
 Log base 2. More...
 
template<typename T >
constexpr T sp::gcd (T a, T b)
 Greatest common divisor, evaluated at compile-time. More...
 
template<typename T >
constexpr T sp::lcm (T a, T b)
 

Detailed Description

Constexpr integer math, such as division that refuses to compile if the division has a remainder.

Function Documentation

◆ divExact()

template<int X, int Y>
constexpr int sp::divExact ( )
constexpr

Compile-time pedantic divide.

◆ divRoundUp()

template<typename T , typename Q >
constexpr auto sp::divRoundUp ( x,
y 
)
constexpr

Divide x by y, rounding up.

◆ gcd()

template<typename T >
constexpr T sp::gcd ( a,
b 
)
constexpr

Greatest common divisor, evaluated at compile-time.

◆ intSqrt()

constexpr int sp::intSqrt ( int  n)
constexpr

Compile-time integer square root, hilariously.

◆ log2()

template<typename IntT >
constexpr int sp::log2 ( IntT  x)
constexpr

Log base 2.

◆ nextPowerOfTwo()

template<typename T >
constexpr auto sp::nextPowerOfTwo ( x)
constexpr

Get the next power of two >= x.

◆ roundDown()

template<typename T , typename Q >
constexpr auto sp::roundDown ( x,
to 
)
constexpr

Round x down to the next multiple of to

◆ roundUp()

template<typename T , typename Q >
constexpr auto sp::roundUp ( x,
to 
)
constexpr

Round x up to the next multiple of to