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

◆ is_unitary

auto kyosu::is_unitary = eve::functor<is_unitary_t>
inlineconstexpr

test if the parameter is unitary (absolute value one).

Header file

#include <kyosu/functions.hpp>

Callable Signatures

namespace kyosu
{
Regular call
template<kyosu::concepts::cayley_dickson_like T> constexpr auto is_unitary(T z) noexcept;
Semantic modifyier
template<kyosu::concepts::cayley_dickson_like T> constexpr auto is_unitary[pedantic](T z) noexcept;
}
constexpr auto is_unitary
test if the parameter is unitary (absolute value one).
Definition is_unitary.hpp:69
Main KYOSU namespace.
Definition cinf.hpp:13

Parameters

  • z: Value to process.

Return value

  1. Returns elementwise true if the element is of absolute value one (with some ulps laxism).
  2. Insists on the norm being strictly equal to one.
Note
normalization of cayley-dickson values is rarely perfect, so by default is_unitary tolerate that the computed norm is almost equal to one. The rationale is that if one normalize a cayley-dickson (using for example the sign function) he probably intends that is_unitary has to return true on the result of the normalization.

Example

#include <eve/wide.hpp>
#include <iostream>
#include <kyosu/kyosu.hpp>
int main()
{
using e_t = float;
using we_t = eve::wide<e_t, eve::fixed<2>>;
using wc_t = eve::wide<c_t, eve::fixed<2>>;
using wq_t = eve::wide<q_t, eve::fixed<2>>;
std::cout << "Real: \n";
e_t e(2.9f);
we_t we = we_t(e);
std::cout << e << " -> " << is_unitary(e) << "\n";
std::cout << we << " -> " << is_unitary(we) << "\n";
std::cout << is_unitary(c_t(e)) << "\n";
std::cout << is_unitary(q_t(e)) << "\n";
std::cout << is_unitary(wc_t(e)) << "\n";
std::cout << is_unitary(wq_t(e)) << "\n";
std::cout << "Complex: \n";
c_t c(3.5f, -2.9f);
wc_t wc = wc_t(c);
std::cout << c << " -> " << is_unitary(c) << "\n";
std::cout << wc << " -> " << is_unitary(wc) << "\n";
std::cout << is_unitary(q_t(c)) << "\n";
std::cout << is_unitary(wq_t(c)) << "\n";
std::cout << "Quaternion: \n";
q_t q(3.5f, -2.9f, 2.1f, 3.2f);
wq_t wq = wq_t(q);
std::cout << q << " -> " << is_unitary(q) << "\n";
std::cout << wq << " -> " << is_unitary(wq) << "\n";
return 0;
}
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