MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
Loading...
Searching...
No Matches
pow2_rescale.hpp File Reference
#include <mtl/concepts/scalar.hpp>
#include <mtl/concepts/magnitude.hpp>
#include <mtl/math/pow2_scaling.hpp>
#include <cmath>
#include <limits>

Namespaces

namespace  mtl
namespace  mtl::itl
namespace  mtl::itl::detail

Functions

template<typename Value>
bool mtl::itl::detail::is_normal_magnitude (const Value &d)
 Whether |d| is a normal number: neither zero, subnormal, infinite nor NaN.
template<typename Value>
Value mtl::itl::detail::by_pow2 (const Value &v, int k)
 v * 2^k, exact also where 2^k itself is not representable (a subnormal v scaled up by 2^1074, which as a factor would be inf).
template<typename Vec>
int mtl::itl::detail::max_abs_exponent (const Vec &v)
 The e with 2^e <= max_i |v_i| < 2^(e+1); 0 for a zero or non-finite maximum (NaN cannot win the max).
template<typename Value>
int mtl::itl::detail::value_exponent (const Value &v)
 The e with 2^e <= |v| < 2^(e+1), |v| the larger of a complex value's parts; 0 for a zero or non-finite v.
template<typename Value>
Value mtl::itl::detail::scaled_quotient (const Value &num, const Value &den, int k)
 2^k num / den without an intermediate leaving the range: the quotient of the two mantissas, near 1, then one exact scaling by 2^(k + e_num - e_den).
template<typename Vec, typename Out>
void mtl::itl::detail::scale_by_pow2 (const Vec &v, int k, Out &out)
 out = 2^k v, value by value.