Annotate noexcept and constexpr with HEDLEY, and add interval containment, ChaCha, and the dyadic range tables.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
875f09fec1
commit
0d8a5a8131
97 changed files with 9212 additions and 1159 deletions
|
|
@ -40,6 +40,7 @@ namespace detail
|
|||
|
||||
/// @brief Integer value of an already-rounded finite double, as a 256-bit word.
|
||||
/// Values that do not fit saturate to all-ones.
|
||||
HEDLEY_NO_THROW
|
||||
inline uint256_t uint256_from_rounded_double(double rounded) noexcept
|
||||
{
|
||||
if (!(rounded > 0.0) || !std::isfinite(rounded))
|
||||
|
|
@ -99,6 +100,7 @@ struct is_static_castable<To, From,
|
|||
|
||||
/// Low `bits` of `wide`, saturated to all-ones when `wide` does not fit.
|
||||
template <typename Raw, std::size_t Bits>
|
||||
HEDLEY_NO_THROW
|
||||
Raw saturate_low_bits(uint256_t wide) noexcept
|
||||
{
|
||||
static_assert(Bits > 0 && Bits <= 256);
|
||||
|
|
@ -151,6 +153,7 @@ Raw saturate_low_bits(uint256_t wide) noexcept
|
|||
}
|
||||
|
||||
template <typename IntegralType>
|
||||
HEDLEY_NO_THROW
|
||||
inline IntegralType rounded_double_to_integral(double rounded) noexcept
|
||||
{
|
||||
if constexpr (std::is_integral_v<IntegralType>
|
||||
|
|
@ -206,6 +209,7 @@ template <typename IntegralType,
|
|||
typename T>
|
||||
HEDLEY_ALWAYS_INLINE
|
||||
HEDLEY_CONST
|
||||
HEDLEY_NO_THROW
|
||||
constexpr IntegralType scale_integer_to_fixed_raw(T integer_value) noexcept
|
||||
{
|
||||
using unsigned_type = dpf::utils::make_unsigned_t<IntegralType>;
|
||||
|
|
@ -228,6 +232,7 @@ inline constexpr bool is_signed_rep_v =
|
|||
template <typename IntegralType>
|
||||
HEDLEY_ALWAYS_INLINE
|
||||
HEDLEY_CONST
|
||||
HEDLEY_NO_THROW
|
||||
constexpr IntegralType raw_neg(IntegralType x) noexcept
|
||||
{
|
||||
using unsigned_type = dpf::utils::make_unsigned_t<IntegralType>;
|
||||
|
|
@ -238,6 +243,7 @@ constexpr IntegralType raw_neg(IntegralType x) noexcept
|
|||
template <typename IntegralType>
|
||||
HEDLEY_ALWAYS_INLINE
|
||||
HEDLEY_CONST
|
||||
HEDLEY_NO_THROW
|
||||
constexpr IntegralType raw_abs(IntegralType x) noexcept
|
||||
{
|
||||
if constexpr (is_signed_rep_v<IntegralType>)
|
||||
|
|
@ -252,6 +258,7 @@ constexpr IntegralType raw_abs(IntegralType x) noexcept
|
|||
template <typename IntegralType>
|
||||
HEDLEY_ALWAYS_INLINE
|
||||
HEDLEY_CONST
|
||||
HEDLEY_NO_THROW
|
||||
constexpr IntegralType raw_fmod(IntegralType a, IntegralType b) noexcept
|
||||
{
|
||||
if (b == IntegralType{})
|
||||
|
|
@ -265,6 +272,7 @@ constexpr IntegralType raw_fmod(IntegralType a, IntegralType b) noexcept
|
|||
|
||||
template <unsigned FractionalBits,
|
||||
typename IntegralType>
|
||||
HEDLEY_NO_THROW
|
||||
auto constexpr make_fixed_from_integral_type(IntegralType value) noexcept;
|
||||
|
||||
/// @tparam FractionalBits Number of fractional bits used in the fixed-point
|
||||
|
|
@ -378,6 +386,7 @@ public:
|
|||
~fixedpoint() = default;
|
||||
|
||||
/// @brief Cast to `double`
|
||||
HEDLEY_NO_THROW
|
||||
HEDLEY_ALWAYS_INLINE
|
||||
HEDLEY_PURE
|
||||
explicit constexpr operator double() const noexcept
|
||||
|
|
@ -728,6 +737,7 @@ public:
|
|||
template <unsigned FractionalBits,
|
||||
typename IntegralType,
|
||||
typename Mask>
|
||||
HEDLEY_NO_THROW
|
||||
constexpr bool operator&(const Mask & mask,
|
||||
const fixedpoint<FractionalBits, IntegralType> & x) noexcept
|
||||
{
|
||||
|
|
@ -739,6 +749,7 @@ template <class CharT,
|
|||
class Traits,
|
||||
unsigned FractionalBits,
|
||||
typename IntegralType>
|
||||
HEDLEY_NO_THROW
|
||||
std::basic_ostream<CharT, Traits> &
|
||||
operator<<(std::basic_ostream<CharT, Traits> & os,
|
||||
const fixedpoint<FractionalBits, IntegralType> & f) noexcept
|
||||
|
|
@ -762,6 +773,7 @@ operator>>(std::basic_istream<CharT, Traits> & is,
|
|||
|
||||
template <unsigned FractionalBits,
|
||||
typename IntegralType>
|
||||
HEDLEY_NO_THROW
|
||||
auto constexpr make_fixed_from_integral_type(IntegralType value) noexcept
|
||||
{
|
||||
return fixedpoint<FractionalBits, IntegralType>::from_raw(value);
|
||||
|
|
@ -811,6 +823,7 @@ static auto make_fixed_safe(double d)
|
|||
template <unsigned ToFractionalBits,
|
||||
unsigned FromFractionalBits,
|
||||
typename IntegralType>
|
||||
HEDLEY_NO_THROW
|
||||
constexpr auto precision_cast(const fixedpoint<FromFractionalBits, IntegralType> & f) noexcept
|
||||
{
|
||||
auto value = f.integral_representation();
|
||||
|
|
@ -826,6 +839,7 @@ constexpr auto precision_cast(const fixedpoint<FromFractionalBits, IntegralType>
|
|||
|
||||
template <unsigned FractionalBits,
|
||||
typename IntegralType>
|
||||
HEDLEY_NO_THROW
|
||||
static constexpr auto precision_of(fixedpoint<FractionalBits, IntegralType>) noexcept
|
||||
{
|
||||
return FractionalBits;
|
||||
|
|
@ -1466,6 +1480,7 @@ struct countl_zero_symmetric_difference<grotto::fixedpoint<FractionalBits, Integ
|
|||
using T = grotto::fixedpoint<FractionalBits, IntegralType>;
|
||||
static constexpr auto clz = dpf::utils::countl_zero_symmetric_difference<typename T::integral_type>{};
|
||||
|
||||
HEDLEY_NO_THROW
|
||||
HEDLEY_PURE
|
||||
HEDLEY_ALWAYS_INLINE
|
||||
constexpr std::size_t operator()(const T & lhs, const T & rhs) const noexcept
|
||||
|
|
@ -1499,6 +1514,7 @@ struct mod_pow_2<grotto::fixedpoint<FractionalBits, IntegralType>>
|
|||
using fixed_type = grotto::fixedpoint<FractionalBits, IntegralType>;
|
||||
static constexpr auto mod = mod_pow_2<IntegralType>{};
|
||||
|
||||
HEDLEY_NO_THROW
|
||||
std::size_t operator()(fixed_type val, std::size_t n) const noexcept
|
||||
{
|
||||
return mod(val.integral_representation(), n);
|
||||
|
|
@ -1512,6 +1528,7 @@ struct make_from_integral_value<grotto::fixedpoint<FractionalBits, IntegralType>
|
|||
using fixed_type = grotto::fixedpoint<FractionalBits, IntegralType>;
|
||||
using integral_type = typename to_integral_type<fixed_type>::integral_type;
|
||||
|
||||
HEDLEY_NO_THROW
|
||||
constexpr fixed_type operator()(integral_type val) const noexcept
|
||||
{
|
||||
return grotto::make_fixed_from_integral_type<FractionalBits, IntegralType>(
|
||||
|
|
@ -1617,6 +1634,7 @@ class numeric_limits<grotto::fixedpoint<FractionalBits, IntegralType>>
|
|||
static constexpr int bitwidth =
|
||||
static_cast<int>(dpf::utils::bitlength_of_v<I>);
|
||||
|
||||
HEDLEY_NO_THROW
|
||||
static constexpr I raw_lowest() noexcept
|
||||
{
|
||||
if constexpr (signed_rep)
|
||||
|
|
@ -1627,6 +1645,7 @@ class numeric_limits<grotto::fixedpoint<FractionalBits, IntegralType>>
|
|||
return I{};
|
||||
}
|
||||
|
||||
HEDLEY_NO_THROW
|
||||
static constexpr I raw_max() noexcept
|
||||
{
|
||||
if constexpr (signed_rep)
|
||||
|
|
@ -1664,8 +1683,11 @@ class numeric_limits<grotto::fixedpoint<FractionalBits, IntegralType>>
|
|||
static constexpr bool traps = false;
|
||||
static constexpr bool tinyness_before = false;
|
||||
|
||||
HEDLEY_NO_THROW
|
||||
static constexpr T lowest() noexcept { return T::from_raw(raw_lowest()); }
|
||||
HEDLEY_NO_THROW
|
||||
static constexpr T max() noexcept { return T::from_raw(raw_max()); }
|
||||
HEDLEY_NO_THROW
|
||||
static constexpr T min() noexcept
|
||||
{
|
||||
if constexpr (FractionalBits == 0)
|
||||
|
|
@ -1674,17 +1696,23 @@ class numeric_limits<grotto::fixedpoint<FractionalBits, IntegralType>>
|
|||
}
|
||||
return T::from_raw(I{1});
|
||||
}
|
||||
HEDLEY_NO_THROW
|
||||
static constexpr T epsilon() noexcept
|
||||
{
|
||||
return FractionalBits ? T::from_raw(I{1}) : T::from_raw(I{});
|
||||
}
|
||||
HEDLEY_NO_THROW
|
||||
static constexpr T round_error() noexcept
|
||||
{
|
||||
return FractionalBits ? T(0.5) : T(0);
|
||||
}
|
||||
HEDLEY_NO_THROW
|
||||
static constexpr T infinity() noexcept { return max(); }
|
||||
HEDLEY_NO_THROW
|
||||
static constexpr T quiet_NaN() noexcept { return T::from_raw(I{}); }
|
||||
HEDLEY_NO_THROW
|
||||
static constexpr T signalling_NaN() noexcept { return T::from_raw(I{}); }
|
||||
HEDLEY_NO_THROW
|
||||
static constexpr T denorm_min() noexcept { return min(); }
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue