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

◆ real

kyosu::real = {}
inlineconstexpr

Extracts the real part of a value.

Defined in Header

#include <kyosu/functions.hpp>

Callable Signatures

namespace kyosu
{
template<kyosu::concepts::cayley_dickson T> constexpr auto& real(T& z) noexcept;
template<kyosu::concepts::cayley_dickson T> constexpr auto real(T const& z) noexcept;
template<eve::floating_ordered_value T> constexpr T& real(T& z) noexcept;
template<eve::floating_ordered_value T> constexpr T real(T const& z) noexcept;
}
constexpr tags::callable_real real
Extracts the real part of a value.
Definition: real.hpp:83
Main KYOSU namespace.
Definition: types.hpp:14

Parameters

  • z: Original value.

Return value

Returns the real part of its argument. For real inputs the call reduces to identity.

Example

#include <kyosu/kyosu.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
using kyosu::real;
std::cout << "Real: ";
float f = 72.9f;
std::cout << f << " -> " << real(f) << " => ";
real(f) = -9.f;
std::cout << f << "\n";
std::cout << "Complex: ";
auto z = kyosu::complex_t<float>(3.5f,-2.9f);
std::cout << z << " -> " << real(z) << " => ";
real(z) = 11.23f;
std::cout << z << "\n";
std::cout << "Quaternion: ";
auto q = kyosu::quaternion_t<double>(1.,2.,3.,4.);
std::cout << q << " -> " << real(q) << " => ";
real(q) = 42.7;
std::cout << q << "\n";
std::cout << "SIMD: ";
eve::wide<kyosu::complex_t<double>, eve::fixed<2>> wz(kyosu::complex_t<double>(1.3,-3.7));
std::cout << wz << " -> " << real(wz) << " => ";
real(wz) = eve::wide<double, eve::fixed<2>>{13.37,63.24};
std::cout << wz << "\n";
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