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

◆ inject

auto kyosu::inject = eve::functor<inject_t>
inlineconstexpr

inject a real in the complex plane a nan producing a fnan.

Header file

#include <kyosu/functions.hpp>

Callable Signatures

namespace kyosu
{
template<kyosu::concepts::cayley_dickson_like Z> constexpr complexify_t<Z> inject(Z z) noexcept;
}
constexpr auto inject
inject a real in the complex plane a nan producing a fnan.
Definition inject.hpp:58
Main KYOSU namespace.
Definition cinf.hpp:13

Parameters

  • z: Value to process.

Return value

  • same as complex(z) for real typed z, except that real nan produces complex fnan if pedantic option is usedand acts as identity on other cayley_dickson_like

Example

#include <eve/wide.hpp>
#include <iostream>
#include <kyosu/kyosu.hpp>
int main()
{
std::cout << "Real:\n";
std::cout << 72.9f << " -> " << inject(72.9f) << "\n";
std::cout << 72.9f << " -> " << complex(72.9f) << "\n";
std::cout << "nan" << " -> " << inject(eve::nan(eve::as<float>())) << "\n";
std::cout << "nan" << " -> " << complex(eve::nan(eve::as<float>())) << "\n";
std::cout << "Complex:\n";
std::cout << kyosu::complex_t<float>(3.5f, -2.9f) << " -> " << inject(kyosu::complex_t<float>(3.5f, -2.9f)) << "\n";
std::cout << "Quaternion:\n ";
std::cout << kyosu::quaternion_t<double>(1., 2., 3., 4.) << " -> " << inject(kyosu::quaternion_t<double>(1., 2., 3., 4.))
<< "\n";
std::cout << "SIMD: ";
using wc_t = eve::wide<kyosu::complex_t<double>, eve::fixed<2>>;
std::cout << wc_t(kyosu::complex_t<double>(1.3, -3.7)) << " -> " << inject(wc_t(kyosu::complex_t<double>(1.3, -3.7)))
<< "\n";
return 0;
}
constexpr auto complex
Constructs a kyosu::complex_t instance.
Definition to_complex.hpp:69
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