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

◆ convert

kyosu::convert = eve::functor<convert_t>
inlineconstexpr

convert to a target type

Header file

#include <kyosu/functions.hpp>

Callable Signatures

namespace kyosu
{
template<eve::scalar_value U> constexpr auto convert(auto x, eve::as<U> ) noexcept;
}
constexpr auto convert
convert to a target type
Definition: convert.hpp:74
Main KYOSU namespace.
Definition: cinf.hpp:13

Parameter

  • x: floating or Cayley Dickinson value to process.

Template Parameter

  • U: target type to convert to.

Return value

The 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 auto complex
Constructs a kyosu::complex_t instance.
Definition: to_complex.hpp:75
as_cayley_dickson_n_t< 4, T > quaternion_t
Type alias for quaternion numbers.
Definition: quaternion.hpp:24
as_cayley_dickson_n_t< 2, T > complex_t
Type alias for complex numbers.
Definition: complex.hpp:27