Universal Numbers Library C++ API
sw::universal -- header-only custom arithmetic types (posit, cfloat, lns, fixpnt, dd/qd, and more)
Loading...
Searching...
No Matches
sw::universal::bposit_math Namespace Reference

Classes

struct  wide_accumulator

Enumerations

enum class  engine { libm_then_qd , qd_only }
enum class  integral_rule { floor , ceil , trunc , round }

Functions

qd dyadic_to_qd (bool negative, std::uint64_t m, int e)
template<typename B>
qd to_qd (const B &x)
template<typename B>
qd one_plus (const B &x, int s)
template<typename B>
B round_to (const qd &v)
template<typename B>
std::optional< B > decide (const qd &y, const qd &err)
template<typename B>
B snap (const qd &y)
template<typename B>
B from_qd (const qd &y, double magnitude_floor=0.0)
template<typename B>
std::optional< B > from_libm (double y, double ulps=BPOSIT_MATH_LIBM_ULPS, double magnitude_floor=0.0)
template<engine E, typename B, typename Libm, typename Kernel>
B evaluate (const B &x, Libm libm, Kernel kernel)
template<engine E, typename B, typename Libm, typename Kernel>
B evaluate (const B &x, const B &y, Libm libm, Kernel kernel)
template<typename B>
constexpr bool above_range (double log2_magnitude)
template<typename B>
constexpr bool below_range (double log2_magnitude)
template<typename B>
bool gamma_pole (const B &x)
template<typename B>
bool gamma_negative (const B &x)
template<typename B>
double lgamma_estimate (const B &x)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > erf (const bposit< nbits, rs, es, bt > &x)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > erfc (const bposit< nbits, rs, es, bt > &x)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > tgamma (const bposit< nbits, rs, es, bt > &x)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > lgamma (const bposit< nbits, rs, es, bt > &x)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > exp (const bposit< nbits, rs, es, bt > &x)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > exp2 (const bposit< nbits, rs, es, bt > &x)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > exp10 (const bposit< nbits, rs, es, bt > &x)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > expm1 (const bposit< nbits, rs, es, bt > &x)
template<typename B>
B remainder_exact (const B &x, const B &y, bool nearest)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sinh (const bposit< nbits, rs, es, bt > &x)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > cosh (const bposit< nbits, rs, es, bt > &x)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > tanh (const bposit< nbits, rs, es, bt > &x)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > asinh (const bposit< nbits, rs, es, bt > &x)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > acosh (const bposit< nbits, rs, es, bt > &x)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > atanh (const bposit< nbits, rs, es, bt > &x)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > hypot (const bposit< nbits, rs, es, bt > &x, const bposit< nbits, rs, es, bt > &y)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > hypot (const bposit< nbits, rs, es, bt > &x, const bposit< nbits, rs, es, bt > &y, const bposit< nbits, rs, es, bt > &z)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > log (const bposit< nbits, rs, es, bt > &x)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > log2 (const bposit< nbits, rs, es, bt > &x)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > log10 (const bposit< nbits, rs, es, bt > &x)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > log1p (const bposit< nbits, rs, es, bt > &x)
template<engine E, typename BP>
BP pow_exact (const BP &x, const qd &yq, int parity, double yd, bool y_exact)
template<unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > pow (const bposit< nbits, rs, es, bt > &x, const bposit< nbits, rs, es, bt > &y)
qd log1p_small (const qd &u)
qd log1p_qd (const qd &u)
template<typename B>
qd log_kernel (const B &x)
template<typename B>
qd log1p_kernel (const B &x)
qd expm1_qd (const qd &t)
template<typename B>
void sincos_kernel (const B &x, qd &s, qd &c)
template<typename B>
qd sin_kernel (const B &x)
template<typename B>
qd cos_kernel (const B &x)
template<typename B>
qd tan_kernel (const B &x)
template<typename B>
qd asin_kernel (const B &x)
template<typename B>
qd acos_kernel (const B &x)
qd sinh_qd (const qd &x)
qd cosh_qd (const qd &x)
qd tanh_qd (const qd &x)
qd asinh_qd (const qd &x)
template<typename B>
qd acosh_kernel (const B &x)
template<typename B>
qd atanh_kernel (const B &x)
qd cbrt_qd (const qd &a)
qd hypot_qd (const qd &x, const qd &y, const qd &z=qd(0.0))
template<typename B>
B atan2_tiny (const B &y, const B &x)
template<typename B>
int integer_parity (const B &y)
int integer_parity (double y)
std::uint64_t two_over_pi_window (int j)
void mul64 (std::uint64_t a, std::uint64_t b, std::uint64_t &hi, std::uint64_t &lo)
template<typename B>
std::pair< int, qd > reduce_pio2 (const B &x)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sqrt (const bposit< nbits, rs, es, bt > &x)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > cbrt (const bposit< nbits, rs, es, bt > &x)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sin (const bposit< nbits, rs, es, bt > &x)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > cos (const bposit< nbits, rs, es, bt > &x)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > tan (const bposit< nbits, rs, es, bt > &x)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > asin (const bposit< nbits, rs, es, bt > &x)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > acos (const bposit< nbits, rs, es, bt > &x)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > atan (const bposit< nbits, rs, es, bt > &x)
template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > atan2 (const bposit< nbits, rs, es, bt > &y, const bposit< nbits, rs, es, bt > &x)
template<integral_rule R, typename B>
B integral (const B &x)

Variables

template<typename B>
constexpr bool exact_in_double = (B::fbits + 1 <= 53) && (B::maxscale < 1000) && (B::minscale > -1000)
template<typename B>
constexpr bool qd_engine = (B::maxscale <= 600) && (B::minscale >= -600)
constexpr int qd_error_exponent = -170
constexpr int snap_exponent = -160
constexpr std::uint64_t two_over_pi_bits [20]

Enumeration Type Documentation

◆ engine

Enumerator
libm_then_qd 
qd_only 

◆ integral_rule

Enumerator
floor 
ceil 
trunc 
round 

Function Documentation

◆ above_range()

template<typename B>
bool sw::universal::bposit_math::above_range ( double log2_magnitude)
constexpr

◆ acos()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::acos ( const bposit< nbits, rs, es, bt > & x)

◆ acos_kernel()

template<typename B>
qd sw::universal::bposit_math::acos_kernel ( const B & x)

◆ acosh()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::acosh ( const bposit< nbits, rs, es, bt > & x)

◆ acosh_kernel()

template<typename B>
qd sw::universal::bposit_math::acosh_kernel ( const B & x)

◆ asin()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::asin ( const bposit< nbits, rs, es, bt > & x)

◆ asin_kernel()

template<typename B>
qd sw::universal::bposit_math::asin_kernel ( const B & x)

◆ asinh()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::asinh ( const bposit< nbits, rs, es, bt > & x)

◆ asinh_qd()

qd sw::universal::bposit_math::asinh_qd ( const qd & x)
inline

◆ atan()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::atan ( const bposit< nbits, rs, es, bt > & x)

◆ atan2()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::atan2 ( const bposit< nbits, rs, es, bt > & y,
const bposit< nbits, rs, es, bt > & x )

◆ atan2_tiny()

template<typename B>
B sw::universal::bposit_math::atan2_tiny ( const B & y,
const B & x )

◆ atanh()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::atanh ( const bposit< nbits, rs, es, bt > & x)

◆ atanh_kernel()

template<typename B>
qd sw::universal::bposit_math::atanh_kernel ( const B & x)

◆ below_range()

template<typename B>
bool sw::universal::bposit_math::below_range ( double log2_magnitude)
constexpr

◆ cbrt()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::cbrt ( const bposit< nbits, rs, es, bt > & x)

◆ cbrt_qd()

qd sw::universal::bposit_math::cbrt_qd ( const qd & a)
inline

◆ cos()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::cos ( const bposit< nbits, rs, es, bt > & x)

◆ cos_kernel()

template<typename B>
qd sw::universal::bposit_math::cos_kernel ( const B & x)

◆ cosh()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::cosh ( const bposit< nbits, rs, es, bt > & x)

◆ cosh_qd()

qd sw::universal::bposit_math::cosh_qd ( const qd & x)
inline

◆ decide()

template<typename B>
std::optional< B > sw::universal::bposit_math::decide ( const qd & y,
const qd & err )

◆ dyadic_to_qd()

qd sw::universal::bposit_math::dyadic_to_qd ( bool negative,
std::uint64_t m,
int e )
inline

◆ erf()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::erf ( const bposit< nbits, rs, es, bt > & x)

◆ erfc()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::erfc ( const bposit< nbits, rs, es, bt > & x)

◆ evaluate() [1/2]

template<engine E, typename B, typename Libm, typename Kernel>
B sw::universal::bposit_math::evaluate ( const B & x,
const B & y,
Libm libm,
Kernel kernel )

◆ evaluate() [2/2]

template<engine E, typename B, typename Libm, typename Kernel>
B sw::universal::bposit_math::evaluate ( const B & x,
Libm libm,
Kernel kernel )

◆ exp()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::exp ( const bposit< nbits, rs, es, bt > & x)

◆ exp10()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::exp10 ( const bposit< nbits, rs, es, bt > & x)

◆ exp2()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::exp2 ( const bposit< nbits, rs, es, bt > & x)

◆ expm1()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::expm1 ( const bposit< nbits, rs, es, bt > & x)

◆ expm1_qd()

qd sw::universal::bposit_math::expm1_qd ( const qd & t)
inline

◆ from_libm()

template<typename B>
std::optional< B > sw::universal::bposit_math::from_libm ( double y,
double ulps = BPOSIT_MATH_LIBM_ULPS,
double magnitude_floor = 0.0 )

◆ from_qd()

template<typename B>
B sw::universal::bposit_math::from_qd ( const qd & y,
double magnitude_floor = 0.0 )

◆ gamma_negative()

template<typename B>
bool sw::universal::bposit_math::gamma_negative ( const B & x)

◆ gamma_pole()

template<typename B>
bool sw::universal::bposit_math::gamma_pole ( const B & x)

◆ hypot() [1/2]

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::hypot ( const bposit< nbits, rs, es, bt > & x,
const bposit< nbits, rs, es, bt > & y )

◆ hypot() [2/2]

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::hypot ( const bposit< nbits, rs, es, bt > & x,
const bposit< nbits, rs, es, bt > & y,
const bposit< nbits, rs, es, bt > & z )

◆ hypot_qd()

qd sw::universal::bposit_math::hypot_qd ( const qd & x,
const qd & y,
const qd & z = qd(0.0) )
inline

◆ integer_parity() [1/2]

template<typename B>
int sw::universal::bposit_math::integer_parity ( const B & y)

◆ integer_parity() [2/2]

int sw::universal::bposit_math::integer_parity ( double y)
inline

◆ integral()

template<integral_rule R, typename B>
B sw::universal::bposit_math::integral ( const B & x)

◆ lgamma()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::lgamma ( const bposit< nbits, rs, es, bt > & x)

◆ lgamma_estimate()

template<typename B>
double sw::universal::bposit_math::lgamma_estimate ( const B & x)

◆ log()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::log ( const bposit< nbits, rs, es, bt > & x)

◆ log10()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::log10 ( const bposit< nbits, rs, es, bt > & x)

◆ log1p()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::log1p ( const bposit< nbits, rs, es, bt > & x)

◆ log1p_kernel()

template<typename B>
qd sw::universal::bposit_math::log1p_kernel ( const B & x)

◆ log1p_qd()

qd sw::universal::bposit_math::log1p_qd ( const qd & u)
inline

◆ log1p_small()

qd sw::universal::bposit_math::log1p_small ( const qd & u)
inline

◆ log2()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::log2 ( const bposit< nbits, rs, es, bt > & x)

◆ log_kernel()

template<typename B>
qd sw::universal::bposit_math::log_kernel ( const B & x)

◆ mul64()

void sw::universal::bposit_math::mul64 ( std::uint64_t a,
std::uint64_t b,
std::uint64_t & hi,
std::uint64_t & lo )
inline

◆ one_plus()

template<typename B>
qd sw::universal::bposit_math::one_plus ( const B & x,
int s )

◆ pow()

template<unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::pow ( const bposit< nbits, rs, es, bt > & x,
const bposit< nbits, rs, es, bt > & y )

◆ pow_exact()

template<engine E, typename BP>
BP sw::universal::bposit_math::pow_exact ( const BP & x,
const qd & yq,
int parity,
double yd,
bool y_exact )

◆ reduce_pio2()

template<typename B>
std::pair< int, qd > sw::universal::bposit_math::reduce_pio2 ( const B & x)

◆ remainder_exact()

template<typename B>
B sw::universal::bposit_math::remainder_exact ( const B & x,
const B & y,
bool nearest )

◆ round_to()

template<typename B>
B sw::universal::bposit_math::round_to ( const qd & v)

◆ sin()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::sin ( const bposit< nbits, rs, es, bt > & x)

◆ sin_kernel()

template<typename B>
qd sw::universal::bposit_math::sin_kernel ( const B & x)

◆ sincos_kernel()

template<typename B>
void sw::universal::bposit_math::sincos_kernel ( const B & x,
qd & s,
qd & c )

◆ sinh()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::sinh ( const bposit< nbits, rs, es, bt > & x)

◆ sinh_qd()

qd sw::universal::bposit_math::sinh_qd ( const qd & x)
inline

◆ snap()

template<typename B>
B sw::universal::bposit_math::snap ( const qd & y)

◆ sqrt()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::sqrt ( const bposit< nbits, rs, es, bt > & x)

◆ tan()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::tan ( const bposit< nbits, rs, es, bt > & x)

◆ tan_kernel()

template<typename B>
qd sw::universal::bposit_math::tan_kernel ( const B & x)

◆ tanh()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::tanh ( const bposit< nbits, rs, es, bt > & x)

◆ tanh_qd()

qd sw::universal::bposit_math::tanh_qd ( const qd & x)
inline

◆ tgamma()

template<engine E, unsigned nbits, unsigned rs, unsigned es, typename bt>
bposit< nbits, rs, es, bt > sw::universal::bposit_math::tgamma ( const bposit< nbits, rs, es, bt > & x)

◆ to_qd()

template<typename B>
qd sw::universal::bposit_math::to_qd ( const B & x)

◆ two_over_pi_window()

std::uint64_t sw::universal::bposit_math::two_over_pi_window ( int j)
inline

Variable Documentation

◆ exact_in_double

template<typename B>
bool sw::universal::bposit_math::exact_in_double = (B::fbits + 1 <= 53) && (B::maxscale < 1000) && (B::minscale > -1000)
inlineconstexpr

◆ qd_engine

template<typename B>
bool sw::universal::bposit_math::qd_engine = (B::maxscale <= 600) && (B::minscale >= -600)
inlineconstexpr

◆ qd_error_exponent

int sw::universal::bposit_math::qd_error_exponent = -170
inlineconstexpr

◆ snap_exponent

int sw::universal::bposit_math::snap_exponent = -160
inlineconstexpr

◆ two_over_pi_bits

std::uint64_t sw::universal::bposit_math::two_over_pi_bits[20]
inlineconstexpr
Initial value:
= {
0xA2F9836E4E441529ull, 0xFC2757D1F534DDC0ull, 0xDB6295993C439041ull, 0xFE5163ABDEBBC561ull,
0xB7246E3A424DD2E0ull, 0x06492EEA09D1921Cull, 0xFE1DEB1CB129A73Eull, 0xE88235F52EBB4484ull,
0xE99C7026B45F7E41ull, 0x3991D639835339F4ull, 0x9C845F8BBDF9283Bull, 0x1FF897FFDE05980Full,
0xEF2F118B5A0A6D1Full, 0x6D367ECF27CB09B7ull, 0x4F463F669E5FEA2Dull, 0x7527BAC7EBE5F17Bull,
0x3D0739F78A5292EAull, 0x6BFB5FB11F8D5D08ull, 0x56033046FC7B6BABull, 0xF0CFBC209AF4361Dull,
}