General Utility Library for C++14
2.11
|
Declaration of numerical utility functions.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the license, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see https://www.gnu.org/licenses/.
#include <algorithm>
#include <cmath>
#include <limits>
#include <type_traits>
#include "gul14/internal.h"
Go to the source code of this file.
Namespaces | |
gul14 | |
Namespace gul14 contains all functions and classes of the General Utility Library. | |
Functions | |
template<typename ValueT > | |
constexpr auto | gul14::abs (ValueT n) noexcept -> std::enable_if_t< std::is_unsigned< ValueT >::value, ValueT > |
Compute the absolute value of a number. More... | |
template<typename NumT , typename OrderT , typename = std::enable_if_t< std::is_arithmetic<NumT>::value and std::is_arithmetic<OrderT>::value >> | |
bool | gul14::within_orders (const NumT a, const NumT b, const OrderT orders) noexcept(false) |
Determine if two numbers are almost equal, comparing only some significant digits. More... | |
template<typename NumT > | |
bool | gul14::within_abs (NumT a, NumT b, NumT tol) noexcept |
Determine if two numbers are almost equal, allowing for an absolute difference. More... | |
template<typename NumT , typename = std::enable_if_t<std::is_floating_point<NumT>::value>> | |
bool | gul14::within_ulp (NumT a, NumT b, unsigned int ulp) |
Determine if two numbers are almost equal, allowing for a difference of a given number of units-in-the-last-place (ULPs). More... | |
template<class NumT > | |
constexpr const NumT & | gul14::clamp (const NumT &v, const NumT &lo, const NumT &hi) |
Coerce a value to be within a given range. More... | |
template<class NumT , class Compare > | |
constexpr const NumT & | gul14::clamp (const NumT &v, const NumT &lo, const NumT &hi, Compare comp) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |