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

◆ from_polar

kyosu::from_polar = {}
inlineconstexpr

Callable object computing a complex or a general Cayley-Dickson from a polar representation.

This function is the reciprocal of to_polar

Defined in header

#include eve/module/quaternion.hpp>`

Callable Signatures

namespace eve
{
template<eve::floating_ordered_value T0, eve::floating_ordered_value T1>,
auto from_polar( T0 rho, T1 theta) const noexcept; // 1
template<eve::floating_ordered_value T0, eve::floating_ordered_value T1, kyosu::concepts::cayley_dickson C>,
auto from_polar( T0 rho, T1 theta, C iz) const noexcept; // 2
}
constexpr tags::callable_from_polar from_polar
Callable object computing a complex or a general Cayley-Dickson from a polar representation.
Definition: from_polar.hpp:106

Parameters

rho : modulus.

theta: argument.

iz : unitary cayley dickson value.

Return value

  1. the complex number rho*exp(i*theta).
  2. the cayley_dickson value rho*exp(iz*theta).
Note
the entries constitue a proper polar representation if rho is non-negative and if iz present it must be pure unitary with non-negative jpart. However the formula is taken anyway.

Example

#include <kyosu/kyosu.hpp>
#include <eve/wide.hpp>
#include <array>
#include <iostream>
int main()
{
auto theta = eve::pio_3(eve::as<double>());
auto rho = 3.0;
auto iz0 = kyosu::sign(kyosu::quaternion(0., 1.));
auto iz1 = kyosu::sign(kyosu::quaternion(0., 1., 2., 3.));
std::cout << " <- theta = " << theta << std::endl;
std::cout << " <- rho = " << rho << std::endl;
std::cout << " -> " << from_polar(theta, rho) << "\n";
std::cout << " -> " << from_polar(theta, rho, iz0) << "\n";
std::cout << " -> " << from_polar(theta, rho, iz1) << "\n";
return 0;
}
constexpr tags::callable_sign sign
Computes tne normalized value z/abs(z) if z is not zero else 0.
Definition: sign.hpp:75
constexpr tags::callable_quaternion quaternion
Constructs a kyosu::quaternion.
Definition: to_quaternion.hpp:72
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