GCE-Math (Generalized Constant Expression Math) is a templated C++ library enabling compile-time computation of mathematical functions.
The library is written in C++11
constexprformat, and is C++11/14/17/20 compatible.
Continued fraction and series expansions are implemented using recursive templates.
gcem::syntax is identical to that of the C++ standard library (
Tested and accurate to floating-point precision against the C++ standard library.
Released under a permissive, non-GPL license.
Author: Keith O’Hara
License: Apache 2.0
The library is actively maintained, and is still being extended. A list of features includes:
- basic library functions:
log1p, and more
- trigonometric functions:
- hyperbolic (area) functions:
- special functions:
factorials and the binomial coefficient:
beta, gamma, and multivariate gamma functions:
the Gaussian error function and inverse error function:
(regularized) incomplete beta and incomplete gamma functions:
inverse incomplete beta and incomplete gamma functions:
GCE-Math functions are written as C++ templates with
constexpr specifiers. For example, the Gaussian error function (
erf) is defined as:
template<typename T> constexpr return_t<T> erf(const T x) noexcept;
A set of internal templated
constexpr functions will implement a continued fraction expansion and return a value of type
return_t<T>. The output type (’
return_t<T>’) is generally determined by the input type, e.g.,
long double, etc; when
T is an intergral type, the output will be upgraded to
return_t<T> = double, otherwise
return_t<T> = T. For types not covered by
std::is_integral, recasts should be used.