ftz 0.0.1
Fast, reproducible floating-point arithmetic
Loading...
Searching...
No Matches
Register-array math

Functions

template<class R, std::size_t N>
requires detail::ftz32_vector<R>
constexpr std::array< R, N > ftz::add (std::array< R, N > const &a, std::array< R, N > const &b) noexcept
 Adds matching register arrays; a non-array operand is converted once and broadcast, with conversion noexcept retained. Returns std::array<R,N>.
template<class R, std::size_t N, class B>
requires detail::ftz32_vector<R> && std::convertible_to<B const &,R>
constexpr std::array< R, N > ftz::add (std::array< R, N > const &a, B const &b) noexcept(std::is_nothrow_constructible_v< R, B const & >)
 Adds matching register arrays; a non-array operand is converted once and broadcast, with conversion noexcept retained. Returns std::array<R,N>.
template<class R, std::size_t N, class A>
requires detail::ftz32_vector<R> && std::convertible_to<A const &,R>
constexpr std::array< R, N > ftz::add (A const &a, std::array< R, N > const &b) noexcept(std::is_nothrow_constructible_v< R, A const & >)
 Adds matching register arrays; a non-array operand is converted once and broadcast, with conversion noexcept retained. Returns std::array<R,N>.
template<class R, std::size_t N>
requires detail::ftz32_vector<R>
constexpr std::array< R, N > ftz::sub (std::array< R, N > const &a, std::array< R, N > const &b) noexcept
 Subtracts matching register arrays; a non-array operand is converted once and broadcast, with conversion noexcept retained. Returns std::array<R,N>.
template<class R, std::size_t N, class B>
requires detail::ftz32_vector<R> && std::convertible_to<B const &,R>
constexpr std::array< R, N > ftz::sub (std::array< R, N > const &a, B const &b) noexcept(std::is_nothrow_constructible_v< R, B const & >)
 Subtracts matching register arrays; a non-array operand is converted once and broadcast, with conversion noexcept retained. Returns std::array<R,N>.
template<class R, std::size_t N, class A>
requires detail::ftz32_vector<R> && std::convertible_to<A const &,R>
constexpr std::array< R, N > ftz::sub (A const &a, std::array< R, N > const &b) noexcept(std::is_nothrow_constructible_v< R, A const & >)
 Subtracts matching register arrays; a non-array operand is converted once and broadcast, with conversion noexcept retained. Returns std::array<R,N>.
template<class R, std::size_t N>
requires detail::ftz32_vector<R>
constexpr std::array< R, N > ftz::mul (std::array< R, N > const &a, std::array< R, N > const &b) noexcept
 Multiplies matching register arrays; a non-array operand is converted once and broadcast, with conversion noexcept retained. Returns std::array<R,N>.
template<class R, std::size_t N, class B>
requires detail::ftz32_vector<R> && std::convertible_to<B const &,R>
constexpr std::array< R, N > ftz::mul (std::array< R, N > const &a, B const &b) noexcept(std::is_nothrow_constructible_v< R, B const & >)
 Multiplies matching register arrays; a non-array operand is converted once and broadcast, with conversion noexcept retained. Returns std::array<R,N>.
template<class R, std::size_t N, class A>
requires detail::ftz32_vector<R> && std::convertible_to<A const &,R>
constexpr std::array< R, N > ftz::mul (A const &a, std::array< R, N > const &b) noexcept(std::is_nothrow_constructible_v< R, A const & >)
 Multiplies matching register arrays; a non-array operand is converted once and broadcast, with conversion noexcept retained. Returns std::array<R,N>.
template<class R, std::size_t N>
requires detail::ftz32_vector<R>
constexpr std::array< R, N > ftz::fma (std::array< R, N > const &a, std::array< R, N > const &b, std::array< R, N > const &c) noexcept
 Evaluates fused a*b+c in one FTZ policy; array results retain the same element type and extent. Returns std::array<R,N>.
template<detail::ftz32_value R, std::size_t N>
constexpr auto ftz::sin (std::array< R, N > const &input) noexcept
 Computes sine in radians with dedicated output reconstruction and the scalar FTZ special-value rules. Returns std::array<R,N>.
template<detail::ftz32_value R, std::size_t N>
constexpr auto ftz::cos (std::array< R, N > const &input) noexcept
 Computes cosine in radians with dedicated output reconstruction and the scalar FTZ special-value rules. Returns std::array<R,N>.
template<unsigned int Degree = 6, detail::ftz32_value R, std::size_t N>
requires (Degree >= 1 && Degree <= 7)
constexpr auto ftz::exp (std::array< R, N > const &input) noexcept
 Computes the exponential with the scalar FTZ underflow, overflow and special-value rules. Returns std::array<R,N>.
template<detail::ftz32_value R, std::size_t N, bool Flush, unsigned int Degree>
requires (!Flush && Degree >= 1 && Degree <= 7)
constexpr auto ftz::exp (std::array< R, N > const &input, std::bool_constant< Flush >, std::integral_constant< unsigned int, Degree >) noexcept
 Delegates native's degree-aware ADL call to the register-array FTZ exponential.
template<detail::ftz32_value R, std::size_t N>
constexpr auto ftz::expm1 (std::array< R, N > const &input) noexcept
 Computes exp(x)-1 with the scalar FTZ graph, preserving signed zero. Returns std::array<R,N>.
template<detail::ftz32_value R, std::size_t N>
constexpr auto ftz::sincos (std::array< R, N > const &input) noexcept
 Computes sine and cosine in radians with the scalar special-value rules; returns a pair in that order. Each member is std::array<R,N>.
template<detail::ftz32_value R, std::size_t N>
constexpr std::array< R, N > ftz::tanh (std::array< R, N > const &input) noexcept
 Computes hyperbolic tangent with the scalar FTZ graph, preserving signed zero and saturating infinities. Returns std::array<R,N>.
template<detail::ftz32_value R, std::size_t N>
constexpr std::array< R, N > ftz::log (std::array< R, N > const &input) noexcept
 Computes natural logarithms; either zero gives negative infinity, negative nonzero values give NaN. Returns std::array<R,N>.
template<detail::ftz32_value R, std::size_t N>
constexpr std::array< R, N > ftz::log1p (std::array< R, N > const &input) noexcept
 Computes log(1+x), preserving signed zero; -1 gives negative infinity and x < -1 gives NaN. Returns std::array<R,N>.
template<detail::ftz32_value R, std::size_t N>
constexpr std::array< R, N > ftz::atan2 (std::array< R, N > const &y, std::array< R, N > const &x) noexcept
 Computes atan2(y,x) in radians with the scalar FTZ signed-axis and infinity rules. Returns std::array<R,N>.
template<detail::ftz32_value R, std::size_t N>
constexpr std::array< R, N > ftz::floor (std::array< R, N > const &input) noexcept
 Rounds toward negative infinity, independently of ambient rounding mode; signed zero and infinities survive. Returns std::array<R,N>.
template<detail::ftz32_value R, std::size_t N>
constexpr std::array< R, N > ftz::ceil (std::array< R, N > const &input) noexcept
 Rounds toward positive infinity, independently of ambient rounding mode; signed zero and infinities survive. Returns std::array<R,N>.
template<detail::ftz32_value R, std::size_t N>
constexpr std::array< R, N > ftz::trunc (std::array< R, N > const &input) noexcept
 Rounds toward zero, independently of ambient rounding mode; signed zero and infinities survive. Returns std::array<R,N>.

Detailed Description

Matching arrays retain their element type and extent, including extent zero. Transcendental arrays accept FTZ scalars or FTZ vectors. Batched add/sub/mul and fma accept FTZ vectors, issuing native operations before boundary repair. These named overloads also supply the array path used by ::native::wide.

std::array<V,2> registers{V(F(.25f)),V(F(.5f))};
auto exponential = ftz::expm1(registers); // std::array<V,2>.
auto [array_sine,array_cosine] = ftz::sincos(registers);
auto fused_registers = ftz::fma(registers, registers, registers);
static_assert(std::is_same_v<decltype(exponential),std::array<V,2>>);

Function Documentation

◆ exp() [1/2]

template<unsigned int Degree = 6, detail::ftz32_value R, std::size_t N>
requires (Degree >= 1 && Degree <= 7)
auto ftz::exp ( std::array< R, N > const & input)
inlinenodiscardconstexprnoexcept

Computes the exponential with the scalar FTZ underflow, overflow and special-value rules. Returns std::array<R,N>.

Template Parameters
DegreePolynomial degree in [1,7]; the default is 6.

Definition at line 1204 of file simd.h.

◆ exp() [2/2]

template<detail::ftz32_value R, std::size_t N, bool Flush, unsigned int Degree>
requires (!Flush && Degree >= 1 && Degree <= 7)
auto ftz::exp ( std::array< R, N > const & input,
std::bool_constant< Flush > ,
std::integral_constant< unsigned int, Degree >  )
inlinenodiscardconstexprnoexcept

Delegates native's degree-aware ADL call to the register-array FTZ exponential.

Template Parameters
FlushMust be false; the element type determines the FTZ policy.
DegreePolynomial degree in [1,7].

Definition at line 1212 of file simd.h.