returns modulus and argument of the input.
#include <eve/wide.hpp>
#include <iostream>
#include <kyosu/kyosu.hpp>
int main()
{
using e_t = float;
using we_t = eve::wide<float, eve::fixed<2>>;
using wc_t = eve::wide<kyosu::complex_t<float>, eve::fixed<2>>;
using wq_t = eve::wide<kyosu::quaternion_t<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);
std::cout << e0 << " -> r0 = " << r0 << ", t0 = " << t0 << "\n";
std::cout << e1 << " -> r0 = " << r1 << ", t1 = " << t1 << "\n";
we_t we0(e0);
we_t we1(e1);
std::cout << we0 << " -> r0 = " << wr0 << ", wt0 = " << wt0 << "\n";
std::cout << we1 << " -> wr0 = " << wr1 << ", wt1 = " << wt1 << "\n";
}
{
std::cout << "Complex: " << "\n";
c_t c0(3, -4);
c_t c1(1, 2);
auto [r0, t0] = to_polar(c0);
std::cout << c0 << " -> r0 = " << r0 << ", t0 = " << t0 << "\n";
auto [r1, t1] = to_polar(c1);
std::cout << c1 << " -> r0 = " << r1 << ", t1 = " << t1 << "\n";
wc_t wc1(c1, c0);
auto [wr0, wt0] = to_polar(wc0);
std::cout << wc0 << " -> r0 = " << wr0 << ", wt0 = " << wt0 << "\n";
auto [wr1, wt1] = to_polar(wc1);
std::cout << wc1 << " -> wr0 = " << wr1 << ", wt1 = " << wt1 << "\n";
}
{
std::cout << "Quaternion: " << "\n";
q_t q0(3, -4, 2, -1);
std::cout << "q0= " << q0 << std::endl;
std::cout << "r = " << r << std::endl;
std::cout << "t = " << t << std::endl;
std::cout <<
"i = " <<
i << std::endl;
std::cout <<
"r*exp(i*t) = " << r *
kyosu::exp(i * t) << std::endl;
wq_t wq0(q0, q0 * (1.0 - q0));
std::cout << "wq0= " << wq0 << std::endl;
std::cout << "wr = " << wr << std::endl;
std::cout << "wt = " << wt << std::endl;
std::cout << "wi = " << wi << std::endl;
std::cout <<
"wr*exp(wi*wt) = " << wr *
kyosu::exp(wi * wt) << std::endl;
}
return 0;
}
constexpr auto i
Computes the complex number in the chosen type.
Definition i.hpp:68
constexpr auto sqr
Computes the square value.
Definition sqr.hpp:56
constexpr auto exp
Computes the exponential of the argument.
Definition exp.hpp:79
as_cayley_dickson_n_t< 2, T > complex_t
Type alias for complex numbers.
Definition complex.hpp:27
as_cayley_dickson_n_t< 4, T > quaternion_t
Type alias for quaternion numbers.
Definition quaternion.hpp:24