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

◆ lpnorm

eve::lpnorm = functor<lpnorm_t>
inlineconstexpr

Defined in Header

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto lpnorm(floating_value auto p, floating_value auto x,floating_value auto... xs ) noexcept; // 1
// Lanes masking
constexpr auto lpnorm[conditional_expr auto c](loating_value auto p, floating_value auto x,floating_value auto... xs) noexcept; // 2
constexpr auto lpnorm[logical_value auto m](loating_value auto p, floating_value auto x,floating_value auto... xs) noexcept; // 2
// Semantic options
constexpr auto lpnorm[pedantic](/* any of the above overloads */) noexcept; // 3
constexpr auto lpnorm[widen](/* any of the above overloads */) noexcept; // 4
constexpr auto lpnorm[kahan](/* any of the above overloads */) noexcept; // 5
}
Specifies that a type is a Conditional Expression.
Definition conditional.hpp:28
The concept floating_value<T> is satisfied if and only if T satisfies eve::value and the element type...
Definition value.hpp:116
The concept logical_value<T> is satisfied if and only if T satisfies eve::value and the element type ...
Definition value.hpp:134
constexpr auto lpnorm
strict_elementwise_callable object computing the lpnorm operation .
Definition lpnorm.hpp:90
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

Return value

  1. \( \left(\sum_{i = 0}^n |x_i|^p\right)^{\frac1p} \).
  2. The operation is performed conditionnaly
  3. returns \(\infty\) as soon as one of its parameter is infinite, regardless of possible Nan values.
  4. The summation is computed in the double sized element type (if available).
  5. Kahan like compensated algorithm is used in internal summation for better precision.

Example

// revision 1
#include <eve/module/math.hpp>
#include <iostream>
#include <iomanip>
int main()
{
eve::wide x = {eve::nan(eve::as<float>()), 1.0f, 1.0f, 1.0f};
eve::wide y = {-1.5f, 2.9f, 3.5f, -11.0f};
eve::wide z = { eve::inf(eve::as(1.0f)), -2.0f, 1.0f, 15.0f};
eve::wide p = { 3.2f, 3.0f, 2.0f, eve::inf(eve::as(1.0f))};
std::cout << std::setprecision(15) << '\n';
std::cout << "<- p = " << p << '\n';
std::cout << "<- x = " << x << '\n';
std::cout << "<- y = " << y << '\n';
std::cout << "<- z = " << z << '\n';
std::cout << "-> lpnorm(p, x, y, z) = " << eve::lpnorm(p, x, y, z) << '\n';
std::cout << "-> lpnorm[pedantic](p, x, y, z) = " << eve::lpnorm[eve::pedantic](p, x, y, z) << '\n';
std::cout << "-> lpnorm[kahan](p, x, y, z) = " << eve::lpnorm[eve::kahan](p, x, y, z) << '\n';
std::cout << "-> lpnorm[kahan][pedantic](p, x, y, z) = " << eve::lpnorm[eve::kahan][eve::pedantic](p, x, y, z) << '\n';
std::cout << "-> lpnorm[widen](p, x, y, z) = " << eve::lpnorm[eve::widen](p, x, y, z) << '\n';
std::cout << "-> lpnorm[widen][pedantic](p, x, y, z) = " << eve::lpnorm[eve::widen][eve::pedantic](p, x, y, z) << '\n';
}
constexpr auto nan
Computes the IEEE quiet NaN constant.
Definition nan.hpp:67
constexpr auto inf
Computes the infinity ieee value.
Definition inf.hpp:67
Lightweight type-wrapper.
Definition as.hpp:29
Wrapper for SIMD registers.
Definition wide.hpp:94