Loading [MathJax]/extensions/tex2jax.js
kyosu v0.1.0
Complex Without Complexes
 
All Classes Namespaces Functions Variables Typedefs Modules Pages Concepts
Loading...
Searching...
No Matches

◆ reldist

kyosu::reldist = eve::functor<reldist_t>
inlineconstexpr

Computes the relative distance between the two parameters.

Example

#include <kyosu/kyosu.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
using e_t = float;
using we_t = eve::wide<float, eve::fixed<2>>;
using wc_t = eve::wide<kyosu::complex_t<float>, eve::fixed<2>>;
using wq_t = eve::wide<kyosu::quaternion_t<float>, eve::fixed<2>>;
std::cout << "Real: "<< "\n";
e_t e0(1);
e_t e1(2);
std::cout << e0 << ", " << e1 << " -> " << reldist(e0, e1) << "\n";
we_t we0(e0);
we_t we1(e1);
std::cout << we0 << ", " << we1 << " -> " << reldist(we0, we1) << "\n";
std::cout << "Complex: "<< "\n";
c_t c0(1, 5);
c_t c1(5, 9);
std::cout << c0 << ", " << c1 << " -> " << reldist(c0, c1) << "\n";
wc_t wc0(c0);
wc_t wc1(c1);
std::cout << wc0 << ", " << wc1 << " -> " << reldist(wc0, wc1) << "\n";
std::cout << "Quaternion: "<< "\n";
q_t q0(1, 5, 2, 3);
q_t q1(5, 9, 6, 7);
std::cout << q0 << ", " << q1 << " -> " << reldist(q0, q1) << "\n";
wq_t wq0(q0);
wq_t wq1(q1);
std::cout << wq0 << ", " << wq1 << " -> " << reldist(wq0, wq1) << "\n";
std::cout << wq0 << ", " << q1 << " -> " << reldist(wq0, q1) << "\n";
std::cout << wq0 << ", " << e1 << " -> " << reldist(wq0, e1) << "\n";
return 0;
}
constexpr auto reldist
Computes the relative distance between the two parameters.
Definition: reldist.hpp:70
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

Header file

#include <kyosu/functions.hpp>

Callable Signatures

namespace kyosu
{
// regular call
constexpr auto reldist(auto z0, auto z1) noexcept; //1
// Semantic modifyiers
constexpr auto reldist[pedantic](auto z0, auto z1) noexcept; //2
constexpr auto reldist[numeric](auto z0, auto z1) noexcept; //3
}
Main KYOSU namespace.
Definition: cinf.hpp:13

Parameters

  • z0, z1: Value to process.

Return value

  1. Returns the the relative distance computed as the absolute value of the arguments difference given by dist divided by the maximum of their absolute values and 1.
  2. if the pedantic option is used the distance betwween an infinite value an anything (even a nan) is infinite.
  3. the numeric option implies pedantic and also return zero if all corresponding parts satisfy eve::is_equal[numeric].