Namespaces | Macros | Functions
Math.hh File Reference
#include "likely.hh"
#include <cassert>
#include <cmath>
#include <cstdint>
Include dependency graph for Math.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.




#define M_E   2.7182818284590452354
#define M_LN2   0.69314718055994530942
#define M_LN10   2.30258509299404568402
#define M_PI   3.14159265358979323846


template<typename T >
constexpr T Math::log2p1 (T x) noexcept
 Returns the number of bits needed to store the value 'x', that is: for x==0 : 0 for x!=0 : 1 + floor(log2(x)) This will be part of c++20: More...
template<typename T >
constexpr bool Math::ispow2 (T x) noexcept
 Is the given number an integral power of two? That is, does it have exactly one 1-bit in binary representation. More...
template<typename T >
constexpr T Math::floodRight (T x) noexcept
 Returns the smallest number of the form 2^n-1 that is greater or equal to the given number. More...
template<typename T >
constexpr T Math::ceil2 (T x) noexcept
 Returns the smallest number that is both >=a and a power of two. More...
int16_t Math::clipIntToShort (int x)
 Clip x to range [-32768,32767]. More...
uint8_t Math::clipIntToByte (int x)
 Clip x to range [0,255]. More...
constexpr unsigned Math::reverseNBits (unsigned x, unsigned bits)
 Reverse the lower N bits of a given value. More...
constexpr uint8_t Math::reverseByte (uint8_t a)
 Reverse the bits in a byte. More...
constexpr unsigned Math::countLeadingZeros (uint32_t x)
 Count the number of leading zero-bits in the given word. More...
constexpr int Math::countTrailingZeros (uint64_t x)
 Count the number of trailing zero-bits in the given word. More...
unsigned Math::findFirstSet (uint32_t x)
 Find the least significant bit that is set. More...
constexpr float Math::cubicHermite (const float *y, float x)

Macro Definition Documentation

◆ M_E

#define M_E   2.7182818284590452354

Definition at line 18 of file Math.hh.

◆ M_LN10

#define M_LN10   2.30258509299404568402

Definition at line 24 of file Math.hh.

◆ M_LN2

#define M_LN2   0.69314718055994530942

Definition at line 21 of file Math.hh.

◆ M_PI

#define M_PI   3.14159265358979323846

Definition at line 27 of file Math.hh.