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

◆ proj

kyosu::proj = {}
inlineconstexpr

Callable object computing proj(x), the projection of the cayley_dickson number z onto the (hyper) Riemann sphere.

Defined in Header

#include <kyosu/functions.hpp>

Callable Signatures

namespace kyosu
{
template<kyosu::concepts::cayley_dickson T> constexpr T proj(T z) noexcept;
template<eve::floating_ordered_value T> constexpr T proj(T z) noexcept;
}
constexpr tags::callable_proj proj
Callable object computing proj(x), the projection of the cayley_dickson number z onto the (hyper) Rie...
Definition: proj.hpp:78
Main KYOSU namespace.
Definition: types.hpp:14

Parameters

  • z: Value to project.

Return value

  • For most z, proj(z)==z, but all infinities, even the numbers where one component is infinite and the other is NaN, become positive real
    infinity, (inf, 0...) or (inf, -0...).
    The sign of the pure (zero) components are the signs of the components of pure(z).

Example

#include <kyosu/kyosu.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
using kyosu::proj;
auto inf = eve::inf(eve::as<float>());
std::cout << "Real: \n";
std::cout << " " << 72.9f << " -> " << proj(72.9f) << "\n";
std::cout << " " << inf << " -> " << proj(inf) << "\n";
std::cout << " " << -inf << " -> " << proj(-inf) << "\n";
std::cout << "Complex: \n";
std::cout << " " << kyosu::complex_t<float>(3.5f,-2.9f) << " -> " << proj(kyosu::complex_t<float>(3.5f,-2.9f)) << "\n";
std::cout << " " << kyosu::complex_t<float>(3.5f,inf) << " -> " << proj(kyosu::complex_t<float>(3.5f,inf)) << "\n";
std::cout << " " << kyosu::complex_t<float>(3.5f,-inf) << " -> " << proj(kyosu::complex_t<float>(3.5f,-inf)) << "\n";
std::cout << " " << kyosu::complex_t<float>(inf,-2.9f) << " -> " << proj(kyosu::complex_t<float>(inf,-2.9f)) << "\n";
std::cout << " " << kyosu::complex_t<float>(inf, 2.9f) << " -> " << proj(kyosu::complex_t<float>(inf,2.9f)) << "\n";
std::cout << "Quaternion: \n";
std::cout << " " << kyosu::quaternion_t<double>(1.f,2.f,3.f,4.f) << " -> " << proj(kyosu::quaternion_t<double>(1.f,2.f,3.f,4.f)) << "\n";
std::cout << " " << kyosu::quaternion_t<double>(-1.f,inf,3.f,-4.f) << " -> " << proj(kyosu::quaternion_t<double>(-1.f,inf,3.f,-4.f)) << "\n";
using T = eve::wide < float, eve::fixed < 2 > >;
auto g = c_t(32, 44, 55, 34);
std::cout << g << std::endl;
return 0;
}
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