kblib 0.2.3
General utilities library for modern C++
stats.h File Reference

Provides numerical and mathematical utilities. More...

#include <array>
#include <cassert>
#include <cinttypes>
#include <cstdlib>
#include <limits>
#include <numeric>
#include "fakestd.h"
#include "logic.h"
#include "tdecl.h"
Include dependency graph for stats.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  kblib::trivial_pair< T >
 std::pair isn't constexpr enough, so I'm stuck with this. All I use it for is removing a temporary variable from calc_fib_size(). More...
 
struct  kblib::trivial_array< T, N >
 std::array isn't constexpr enough in C++14, so a dedicated array class is needed for constexpr functions. More...
 
struct  kblib::nums::max_t
 Shorthand for std::numeric_limits::max(). More...
 
struct  kblib::nums::min_t
 Shorthand for std::numeric_limits::min() More...
 

Namespaces

namespace  kblib
 The main namespace in which all entities from kblib are defined.
 
namespace  kblib::nums
 

Functions

template<typename T , typename U >
constexpr auto kblib::div (T num, U den) noexcept -> decltype(std::div(num, den))
 
template<typename U >
constexpr auto kblib::calc_fib_size () noexcept -> std::size_t
 Calculate the index of the largest fibonacci number that can be represented by a given unsigned integral type. More...
 
template<typename U , std::size_t N = calc_fib_size<U>() + 1>
constexpr auto kblib::make_fib_arr () noexcept -> trivial_array< U, N >
 Generates the first N values of the fibonacci sequence. More...
 
template<typename U = std::uintmax_t>
constexpr auto kblib::fibonacci (int n) noexcept -> U
 Compile-time table fibonacci function. More...
 
template<typename T = double>
constexpr auto kblib::pi () -> T
 
template<typename T = double>
constexpr auto kblib::tau () -> T
 
template<typename T = double>
constexpr auto kblib::e () -> T
 
template<typename T = double>
constexpr auto kblib::root_2 () -> T
 
template<typename T = double>
constexpr auto kblib::phi () -> T
 
template<typename A , typename F >
constexpr auto kblib::saturating_cast (F x) noexcept -> enable_if_t< std::is_integral< A >::value and std::is_integral< F >::value and std::is_unsigned< A >::value, A >
 
template<typename T , typename F >
constexpr auto kblib::quantize_step (F low, F delta, F val) noexcept -> T
 Quantize a real-valued value into a discrete integer. More...
 
template<typename T , typename F >
constexpr auto kblib::quantize_range (F low, F high, F val) noexcept -> T
 Quantize a real-valued value into a discrete integer. More...
 

Variables

constexpr struct kblib::nums::max_t kblib::nums::max
 
constexpr struct kblib::nums::min_t kblib::nums::min
 

Detailed Description

Provides numerical and mathematical utilities.

Author
killerbee
Date
2019-2021

Definition in file stats.h.