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

◆ kolmmean

auto kyosu::kolmmean = eve::functor<kolmmean_t>
inlineconstexpr

Callable object computing the 'Kolmogorov-Nagumo-de Finetti' mean of the inputs: \( \mathbf{g}(\mathbf{average}\mathbf{f}(x_s)) \).

Header file

#include <kyosu/functions.hpp>

Callable Signatures

namespace kyosu
{
// Regular overloads
constexpr auto kolmmean(auto ... xs) noexcept; // 1
constexpr auto kolmmean(eve::non_empty_product_type auto const& tup) noexcept; // 2
constexpr auto kolmmean[pedantic](/*any of the above overloads*/) noexcept; // 3
constexpr auto kolmmean[kahan] (/*any of the above overloads*/) noexcept; // 4
}
constexpr auto kolmmean
Callable object computing the 'Kolmogorov-Nagumo-de Finetti' mean of the inputs: .
Definition kolmmean.hpp:89
Main KYOSU namespace.
Definition cinf.hpp:13

Parameters

  • xs...: Values to process. Can be a mix of cayley_dickson_like values.
  • tup: kumi tuple of arguments.

Return value

  1. The value of the quasi arithmetic mean of the arguments is returned.
  2. The value of the guasi arithmetic mean of the tuple elements is returned.
  3. avoid spurious overflows on average.
  4. kahan algorithm is used to enhance accuracy.
Note
For the result to be a proper kolmogorov mean, f must be mathematically continuous and injective and g be its inverse. and KYOSU need them to be defined for a cayley_dickson_like input, and returning the same type. However \( \mathbf{g}(\sum \mathbf{f}(x_s)) \) is returned if computable. However for one parameter only, the call always returns the parameter itself.

Example

#include <eve/wide.hpp>
#include <iostream>
#include <kyosu/kyosu.hpp>
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>>;
// quadratic mean
auto f = [](auto x) { return kyosu::sqr(x); };
auto g = [](auto x) { return kyosu::sqrt(x); };
auto gr = [](auto x) { return eve::sqrt(x); };
std::cout << "Real: " << "\n";
e_t e0(1);
e_t e1(2);
std::cout << e0 << ", " << e1 << " -> " << kolmmean(f, gr, e0, e1) << "\n";
std::cout << e0 << ", " << e0 << " -> " << kolmmean(f, gr, e0, e0) << "\n";
we_t we0(e0);
we_t we1(e1);
std::cout << we0 << ", " << we1 << " -> " << kolmmean(f, gr, we0, we1) << "\n";
std::cout << "Complex: " << "\n";
c_t c0(1, 5);
c_t c1(5, 9);
std::cout << c0 << ", " << c1 << " -> " << kolmmean(f, g, c0, c1) << "\n";
std::cout << c0 << ", " << c0 << " -> " << kolmmean(f, g, c0, c0) << "\n";
wc_t wc0(c0, c1);
wc_t wc1(c1, c1);
std::cout << wc0 << ", " << wc1 << " -> " << kolmmean(f, g, 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 << " -> " << kolmmean(f, g, q0, q1) << "\n";
std::cout << q0 << ", " << q0 << " -> " << kolmmean(f, g, q0, q0) << "\n";
wq_t wq0(q0, q1);
wq_t wq1(q1, q1);
std::cout << wq0 << ", " << wq1 << " -> " << kolmmean(f, g, wq0, wq1) << "\n";
std::cout << "Mixed: " << "\n";
std::cout << kyosu::kolmmean(f, g, c0, q1, e0) << std::endl;
std::cout << kyosu::kolmmean(f, g, e0, q1, c1) << std::endl;
std::cout << kyosu::kolmmean(f, g, c0, wq1) << std::endl;
std::cout << kyosu::kolmmean(f, g, we0, q1) << std::endl;
return 0;
}
constexpr auto sqrt
Computes a square root value.
Definition sqrt.hpp:103
constexpr auto sqr
Computes the square value.
Definition sqr.hpp:56
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