E.V.E
v2023.02.15
Loading...
Searching...
No Matches
◆
lpnorm
eve::lpnorm = functor<lpnorm_t>
inline
constexpr
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
}
eve::conditional_expr
Specifies that a type is a Conditional Expression.
Definition
conditional.hpp:28
eve::floating_value
The concept floating_value<T> is satisfied if and only if T satisfies eve::value and the element type...
Definition
value.hpp:116
eve::logical_value
The concept logical_value<T> is satisfied if and only if T satisfies eve::value and the element type ...
Definition
value.hpp:134
eve::lpnorm
constexpr auto lpnorm
strict_elementwise_callable object computing the lpnorm operation .
Definition
lpnorm.hpp:90
eve::translate_t
typename decltype(detail::as_translated_type(as< T >{}))::type translate_t
Returns the final translated type of T.
Definition
translation.hpp:107
eve
EVE Main Namespace.
Definition
abi.hpp:19
Parameters
p
:
floating value
x
,
... xs
:
floating values
c
:
Conditional expression
masking the operation.
m
:
Logical value
masking the operation.
Return value
\( \left(\sum_{i = 0}^n |x_i|^p\right)^{\frac1p} \).
The operation is performed conditionnaly
returns \(\infty\) as soon as one of its parameter is infinite, regardless of possible
Nan
values.
The summation is computed in the double sized element type (if available).
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'
;
}
eve::nan
constexpr auto nan
Computes the IEEE quiet NaN constant.
Definition
nan.hpp:67
eve::inf
constexpr auto inf
Computes the infinity ieee value.
Definition
inf.hpp:67
eve::as
Lightweight type-wrapper.
Definition
as.hpp:29
eve::wide
Wrapper for SIMD registers.
Definition
wide.hpp:94
eve