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

◆ sqr

kyosu::sqr = {}
inlineconstexpr

Computes the square value.

Defined in Header

#include <kyosu/functions.hpp>

Callable Signatures

namespace kyosu
{
template<kyosu::concepts::cayley_dickson T> constexpr T sqr(T z) noexcept;
template<eve::floating_ordered_value T> constexpr T sqr(T z) noexcept;
}
constexpr tags::callable_sqr sqr
Computes the square value.
Definition: sqr.hpp:72
Main KYOSU namespace.
Definition: types.hpp:14

Parameters

  • z: Value to for which square is computed.

Return value

Returns the square of its argument. i.e. z*z in an optimized way.

Example

#include <kyosu/kyosu.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
using kyosu::sqr;
std::cout << "Real: "<< "\n";
std::cout << 72.9f << " -> " << sqr(72.9f) << "\n";
std::cout << 72.9f << " -> " << (72.9f)*(72.9f) << "\n";
std::cout << "Complex: "<< "\n";
std::cout << kyosu::complex_t<float>(3.5f,-2.9f) << " -> " << sqr(kyosu::complex_t<float>(3.5f,-2.9f)) << "\n";
std::cout << kyosu::complex_t<float>(3.5f,-2.9f) << " -> " << (kyosu::complex_t<float>(3.5f,-2.9f))*(kyosu::complex_t<float>(3.5f,-2.9f)) << "\n";
std::cout << "Quaternion: "<< "\n";
std::cout << kyosu::quaternion_t<double>(1.1,2.2,-3.3,4.4) << " -> " << sqr(kyosu::quaternion_t<double>(1.1,2.2,-3.3,4.4)) << "\n";
std::cout << kyosu::quaternion_t<double>(1.1,2.2,-3.3,4.4) << " -> " << (kyosu::quaternion_t<double>(1.1,2.2,-3.3,4.4))*(kyosu::quaternion_t<double>(1.1,2.2,-3.3,4.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)) << " -> " << sqr(wc_t(kyosu::complex_t<double>(1.3,-3.7))) << "\n";
std::cout << wc_t(kyosu::complex_t<double>(1.3,-3.7)) << " -> " << (wc_t(kyosu::complex_t<double>(1.3,-3.7)))*(wc_t(kyosu::complex_t<double>(1.3,-3.7)))<< "\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