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

◆ quaternion

kyosu::quaternion = {}
inlineconstexpr

Constructs a kyosu::quaternion.

Defined in Header

#include <kyosu/functions.hpp>

Callable Signatures

namespace kyosu
{
template<eve::floating_ordered_value T> constexpr auto quaternion(T r, T i = 0, T j = 0, T k = 0) noexcept;
template<eve::floating_ordered_value T> constexpr auto quaternion(complex_t<T> c0, complex_t<T> c1 = 0) noexcept;
template<kyosu::concepts::cayley_dickson T> constexpr T quaternion(T z) noexcept;
}
constexpr tags::callable_quaternion quaternion
Constructs a kyosu::quaternion.
Definition: to_quaternion.hpp:72
constexpr tags::callable_i i
Computes the complex number cinf i.e. complex(nan, inf) in the chosen type.
Definition: i.hpp:77
as_cayley_dickson_n_t< 2, T > complex_t
Type alias for complex numbers.
Definition: complex.hpp:27
Main KYOSU namespace.
Definition: types.hpp:14

Parameters

  • z : Quaternion value.
  • c0,c1 : Complex values generates the quaternion c0+j*conj(c1) i.e. real(c0+i*imag(c1)+j*real(1)+k*imag(c1)
  • r, i, j, k : Real and unreal parts sued to construct a kyosu::quaternion from its components

Return value

Returns a kyosu::quaternion constructed from its arguments.

Example

#include <kyosu/kyosu.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
std::cout << "Real: ";
std::cout << "quaternion(72.9f) -> " << quaternion(72.9f) << "\n";
std::cout << "Complex: ";
std::cout << "quaternion(3.5f, 2.9f) -> " << quaternion(3.5f,-2.9f) << "\n";
std::cout << "Quaternion: ";
std::cout << "quaternion(1.0, 2.0, 3.0, 4.0) -> " << quaternion(1.,2.,3.,4.) << "\n";
auto c0 = complex(1.0, 2.3);
auto c1 = complex(-4.0, -1.5);
std::cout << "c0 = " << c0 << "\n";
std::cout << "c1 = " << c1 << "\n";
std::cout << "quaternion(c0, c1) -> " << quaternion(c0, c1) << "\n";
std::cout << "SIMD quaternion: \n";
using w_t = eve::wide<double, eve::fixed<2>>;
w_t a(3.5f,-2.9f), b(1.0, -3.0);
std::cout << "a = " << a << "\n";
std::cout << "b = " << b << "\n";
std::cout << "quaternion(a, b) -> " << quaternion(a, b) << "\n";
return 0;
}
constexpr tags::callable_complex complex
Constructs a kyosu::complex.
Definition: to_complex.hpp:70