Callable object computing the polar coordinates from a complex.
#include <kyosu/kyosu.hpp>
#include <eve/wide.hpp>
#include <iostream>
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 = " << t0 << "\n";
we_t we0(e0);
we_t we1(e1);
std::cout << we0 << " -> r0 = " << wr0 << ", wt0 = " << wt0 << "\n";
std::cout << we1 << " -> wr0 = " << wr1 << ", wt1 = " << wt0 << "\n";
}
{
std::cout << "Complex: "<< "\n";
c_t c0(3, -4);
c_t c1(1, 2);
std::cout << c0 << " -> r0 = " << r0 << ", t0 = " << t0 << "\n";
std::cout << c1 << " -> r0 = " << r1 << ", t1 = " << t0 << "\n";
wc_t wc1(c1, c0);
std::cout << wc0 << " -> r0 = " << wr0 << ", wt0 = " << wt0 << "\n";
std::cout << wc1 << " -> wr0 = " << wr1 << ", wt1 = " << wt0 << "\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 tags::callable_to_polar to_polar
Callable object computing the polar coordinates from a complex.
Definition: to_polar.hpp:95
constexpr tags::callable_sqr sqr
Computes the square value.
Definition: sqr.hpp:72
constexpr tags::callable_exp exp
Computes the exponential of the argument.
Definition: exp.hpp:93
constexpr tags::callable_i i
Computes the complex number cinf i.e. complex(nan, inf) in the chosen type.
Definition: i.hpp:77
as_cayley_dickson_n_t< 4, T > quaternion_t
Type alias for quaternion numbers.
Definition: quaternion.hpp:27
as_cayley_dickson_n_t< 2, T > complex_t
Type alias for complex numbers.
Definition: complex.hpp:27