E.V.E
v2023.02.15
 
Loading...
Searching...
No Matches

◆ kolmmean

eve::kolmmean = functor<kolmmean_t>
inlineconstexpr

Header file

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto kolmmean(floating_value auto ... xs) noexcept; // 1
constexpr auto kolmmean(kumi::non_empty_product_type auto const& tup) noexcept; // 2
// Semantic options
constexpr auto kolmmean[kahan](/*any of the above overloads*/) noexcept; // 4
}
The concept floating_value<T> is satisfied if and only if T satisfies eve::value and the element type...
Definition value.hpp:116
constexpr auto kolmmean
Callable object computing the 'Kolmogorov-Nagumo-de Finetti' mean of the inputs: .
Definition kolmmean.hpp:91
typename decltype(detail::as_translated_type(as< T >{}))::type translate_t
Returns the final translated type of T.
Definition translation.hpp:107
EVE Main Namespace.
Definition abi.hpp:19

Parameters

  • f, g: two functions that will be used to compute the mean.
  • xs: real arguments.
  • tup: non empty tuple of arguments.
  • c: Conditional expression masking the operation.
  • m: Logical value masking the operation.

Return value

  1. The kolmogorov mean of the inputs is returned
  2. equivalent to the call on the elements of the tuple.
  3. The operation is performed conditionnaly
  4. uses kahan like compensated algorithm for better accuracy.
Note
For the result to be a proper kolmogorov mean, f must be mathematically continuous and injective and g be its inverse. and EVE need them to be defined for a floating_value input, and returning the same type. However \( \mathbf{g}(\sum \mathbf{f}(x_s)) \) is returned if computable.

External references

// revision 1
#include <eve/module/math.hpp>
#include <iostream>
int main()
{
eve::wide pf = {3.0, -1.0, -3.0, 10.0};
eve::wide qf = {4.0, 1.0, 1.0, 15.0};
eve::wide rf = {-1.0, 2.0, 3.0, 1.5};
kumi::tuple wt{pf, qf, rf};
auto f0 = eve::abs; //l1 mean
auto rf0 = f0;
auto f1 = eve::rec[eve::pedantic]; //harmonic
auto rf1 = f1;
auto f2 = [](auto x){ return eve::sqr(x); }; // quadratic
auto rf2 = [](auto x){ return eve::sqrt(x); };
std::cout << "<- pf = " << pf << "\n";
std::cout << "<- qf = " << qf << "\n";
std::cout << "<- rf = " << rf << "\n";
std::cout << "<- wt = " << wt << "\n";
std::cout << "-> kolmmean(f0, rf0, pf, qf, rf) = " << eve::kolmmean(f0, rf0, pf, qf, rf) << " //l1 mean\n";
std::cout << "-> kolmmean(f0, rf0, wt) = " << eve::kolmmean(f0, rf0, wt) << "\n";
std::cout << "-> kolmmean(f1, rf1, pf, qf, rf) = " << eve::kolmmean(f1, rf1, pf, qf, rf) << " //harmonic mean\n";
std::cout << "-> kolmmean(f1, rf1, wt) = " << eve::kolmmean(f1, rf1, wt) << "\n";
std::cout << "-> kolmmean(f2, rf2, pf, qf, rf) = " << eve::kolmmean(f2, rf2, pf, qf, rf) << " // quadratic mean\n";
std::cout << "-> kolmmean(f2, rf2, wt) = " << eve::kolmmean(f2, rf2, wt) << "\n\n";
}
constexpr auto sqrt
Computes the elementwise square root of the parameter.
Definition sqrt.hpp:81
constexpr auto rec
Computes the inverse of the parameter.
Definition rec.hpp:91
constexpr auto sqr
Computes the square of the parameter.
Definition sqr.hpp:97
constexpr auto abs
elementwise_callable object computing the absolute value of the parameter.
Definition abs.hpp:85
Wrapper for SIMD registers.
Definition wide.hpp:94