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

◆ convert

kyosu::convert = {}
inlineconstexpr

convert to a target typek

Defined in Header

#include <kyosu/functions.hpp>

Callable Signatures

namespace kyosu
{
template<eve::floating_scalar_ordered_value U> constexpr auto convert(auto x, eve::as<U> ) noexcept;
}
constexpr tags::callable_convert convert
convert to a target typek
Definition: convert.hpp:79
Main KYOSU namespace.
Definition: types.hpp:14

Parameter

  • x: floating or Cayley Dickinson value to process.

Template Parameter

  • U: target type to convert to.

Return value

 a value resulting of the conversion of each of its elements to type U.

Example

#include <kyosu/kyosu.hpp>
#include <eve/wide.hpp>
#include <iostream>
#include <iomanip>
int main()
{
double f = 72.987654321;
std::cout << "Real to complex of floats: ";
std::cout << std::setprecision(10) << f << " -> " << convert(f, eve::as<complex_t<float>>()) << "\n";
std::cout << "Real to quaternion of double: " ;
std::cout << f << " -> " << convert(f, eve::as<quaternion_t<double>>()) << "\n";
std::cout << "Complex to quaternion ofdouble: ";
auto c = kyosu::complex(3.5f,-2.9f);
std::cout << c << " -> " << convert(c, eve::as<quaternion_t<double>>()) << "\n";
return 0;
}
constexpr tags::callable_complex complex
Constructs a kyosu::complex.
Definition: to_complex.hpp:70
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