kyosu v0.1.0
Complex Without Complexes
 
Loading...
Searching...
No Matches

◆ fma

kyosu::fma = eve::functor<fma_t>
inlineconstexpr

Computes fused multiply add.

Header file

#include <kyosu/functions.hpp>

Callable Signatures

namespace kyosu
{
constexpr auto fma(auto z0, auto z1, auto z2) noexcept;
}
constexpr auto fma
Computes fused multiply add.
Definition: fma.hpp:62
Main KYOSU namespace.
Definition: cinf.hpp:13

Parameters

  • z0, z1,z2: Values to process.

Return value

The call is semantically equivalent to z0*z1+z2.

Example

#include <kyosu/kyosu.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
using kyosu::fma;
using e_t = float;
using we_t = eve::wide<float, eve::fixed<2>>;
using wq_t = eve::wide<kyosu::quaternion_t<float>, eve::fixed<2>>;
std::cout << "Real: "<< "\n";
e_t e0(1);
e_t e1(2);
e_t e2(3);
std::cout << e0 << ", " << e1 << ", " << e2 << " -> " << fma(e0, e1, e2) << "\n";
std::cout << e0 << ", " << e0 << ", " << e2 << " -> " << fma(e0, e0, e2) << "\n";
we_t we0(e0);
we_t we1(e1);
we_t we2(e2, e0);
std::cout << we0 << ", " << we1 << ", " << we2<< " -> " << fma(we0, we1, we2) << "\n";
std::cout << "Complex: "<< "\n";
c_t c0(1, 5);
c_t c1(5, 9);
c_t c2(2, -5);
std::cout << c0 << ", " << c1 << ", " << c2 << " -> " << fma(c0, c1, e2) << "\n";
std::cout << c0 << ", " << c0 << ", " << c2 << " -> " << fma(c0, c0, e2) << "\n";
std::cout << "Quaternion: "<< "\n";
q_t q0(1, 5, 2, 3);
q_t q1(5, 9, 6, 7);
q_t q2(7, -3, 0, 1);
wq_t wq1(q1, q2);
std::cout << q0 << ", " << q1 << ", " << q2 << " -> " << fma(q0, q1, q2) << "\n";
std::cout << q0 << ", " << q0 << ", " << q2 << " -> " << fma(q0, q0, q2) << "\n";
std::cout << "Mixed: "<< "\n";
std::cout << c0 << ", " << q1 << ", " << e2 << " -> " << kyosu::fma(c0, q1, e2) << std::endl;
std::cout << e0 << ", " << q1 << ", " << q2 << " -> " << kyosu::fma(e0, q1, q2) << std::endl;
std::cout << c0 << ", " << wq1<< ", " << e2 << " -> " << kyosu::fma(c0, we1, q2) << std::endl;
std::cout << we0<< ", " << q1 << ", " << e2 << " -> " << kyosu::fma(we0, q1, e2) << std::endl;
return 0;
}
as_cayley_dickson_n_t< 4, T > quaternion_t
Type alias for quaternion numbers.
Definition: quaternion.hpp:24
as_cayley_dickson_n_t< 2, T > complex_t
Type alias for complex numbers.
Definition: complex.hpp:27