E.V.E
v2022.09.01

◆ three_fma

eve::three_fma = {}
inlineconstexpr

Computes the elementwise triple of fma and errors,.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< eve::floating_value T, eve::floating_value U , eve::floating_value V >
auto three_fma(T x, U y, V z) noexcept;
}
constexpr callable_three_fma_ three_fma
Computes the elementwise triple of fma and errors,.
Definition: three_fma.hpp:65
Definition: all_of.hpp:22

Parameters

x, y, z: floating values.

Return value

Computes elementwise a triple of values [a,b,c] such that:

  • a is x*y+z
  • b, c are values such that (a \(\oplus\)b) \(\oplus\)cis exactly to x \(\otimes\)y \(\oplus\)z

where \(\oplus\) (resp. \(\otimes\)) adds (resp. multiplies) its two parameters with infinite precision..

Example

#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
#include <iomanip>
int main()
{
float ep = eve::eps(eve::as<float>());
wide_ft pf = {1.0f+ep, 0.5f*(1.0f+ep*4), -1.3f, 1.0f+4*ep};
wide_ft qf = {1.0f-ep, 0.5f, -1.3f, 1.0f-ep/2};
wide_ft rf = {1.0f-ep, 0.5f, -1.3f, 1.0f-ep/2};
auto [a, b, c] = eve::three_fma(pf, qf, rf);
std::cout << "---- simd" << std::setprecision(8) << '\n'
<< "<- pf = " << pf << '\n'
<< "<- qf = " << qf << '\n'
<< "<- rf = " << qf << '\n'
<< "-> three_fma(pf, qf, rf) = [" << '\n'
<< " " << a << ", \n"
<< " " << b << ", \n"
<< " " << c << '\n'
<< " ]\n";
float xf = 0.5f*(1.0f+ep*4), yf = -1.3f, zf = -1.3f;
auto [sa, sb, sc] = eve::three_fma(xf, yf, zf);
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "<- yf = " << yf << '\n'
<< "<- zf = " << zf << '\n'
<< "-> three_fma(xf, yf, zf) = [" << sa << ", " << sb << ", " << sc << "]\n"
<< "-> fma(double(xf), double(yf), double(zf) = " << fma(double(xf), double(yf), double(zf)) << '\n'
<< "-> double(sa)+double(sb)+double(sc) " << double(sa)+double(sb)+double(sc) << '\n';
return 0;
}
constexpr callable_fma_ fma
Computes the fused multiply add of its three parameters.
Definition: fma.hpp:82
Lightweight type-wrapper.
Definition: as.hpp:29
Wrapper for SIMD registers.
Definition: wide.hpp:65