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

◆ abs

auto kyosu::abs = eve::functor<abs_t>
inlineconstexpr

Computes the absolute value of the parameter.

Header file

#include <kyosu/functions.hpp>

Callable Signatures

namespace kyosu
{
//regular call
template<kyosu::concepts::cayley_dickson_like T> constexpr as_real_type_t<T> abs(T z) noexcept; // 1
// Semantic modifyiers
template<kyosu::concepts::cayley_dickson_like T> constexpr as_real_type_t<T> abs[raw](T z) noexcept; // 2
template<kyosu::concepts::cayley_dickson_like T> constexpr as_real_type_t<T> abs[flat](T z) noexcept; // 3
}
constexpr auto abs
Computes the absolute value of the parameter.
Definition abs.hpp:69
typename as_real_type< T >::type as_real_type_t
Compute the real type associated to a Cayley-Dickson-like type.
Definition traits.hpp:83
Main KYOSU namespace.
Definition cinf.hpp:13

Parameters

  • z: Value to process.

Return value

  1. The modulus of its parameter (always a floating ordered value). The modulus is the square root of the sum of the squares of the absolute value of each component.
  2. With the raw option no provision is made to enhance accuracy and avoid overflows
  3. With the flat otpion it is the \(l_\infty\) norm of the components that is computed.

External references

Example

#include <eve/wide.hpp>
#include <iostream>
#include <kyosu/kyosu.hpp>
int main()
{
using kyosu::abs;
std::cout << "Real: ";
std::cout << 72.9f << " -> " << abs(72.9f) << "\n";
std::cout << "Complex: ";
std::cout << kyosu::complex_t<float>(3.5f, -2.9f) << " -> " << abs(kyosu::complex_t<float>(3.5f, -2.9f)) << "\n";
std::cout << "Quaternion: ";
std::cout << kyosu::quaternion_t<double>(1., 2., 3., 4.) << " -> " << abs(kyosu::quaternion_t<double>(1., 2., 3., 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)) << " -> " << abs(wc_t(kyosu::complex_t<double>(1.3, -3.7)))
<< "\n";
return 0;
}
as_cayley_dickson_n_t< 2, T > complex_t
Type alias for complex numbers.
Definition complex.hpp:27
as_cayley_dickson_n_t< 4, T > quaternion_t
Type alias for quaternion numbers.
Definition quaternion.hpp:24