E.V.E
v2023.02.15
Loading...
Searching...
No Matches
◆
harmmean
eve::harmmean = functor<harmmean_t>
inline
constexpr
Header file
#include <eve/module/math.hpp>
Callable Signatures
namespace
eve
{
// Regular overloads
constexpr
auto
harmmean
(
floating_value
auto
...
xs
)
noexcept
;
// 1
constexpr
auto
harmmean
(kumi::non_empty_product_type
auto
const
&
tup
)
noexcept
;
// 2
// Lanes masking
constexpr
auto
harmmean
[
conditional_expr
auto
c
](
/*any of the above overloads*/
)
noexcept
;
// 3
constexpr
auto
harmmean
[
logical_value
auto
m
](
/*any of the above overloads*/
)
noexcept
;
// 3
// Semantic options
constexpr
auto
harmmean
[kahan](
/*any of the above overloads*/
)
noexcept
;
// 4
}
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::harmmean
constexpr auto harmmean
Callable object computing the harmonic mean of the inputs. .
Definition
harmmean.hpp:91
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
xs
:
real
arguments.
tup
: non empty tuple of arguments.
c
:
Conditional expression
masking the operation.
m
:
Logical value
masking the operation.
Return value
The harmonic mean of the inputs is returned
equivalent to the call on the elements of the tuple.
The operation is performed conditionnaly
uses kahan like compensated algorithm for better accuracy.
External references
wikipedia Geometric mean
Example
// 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
};
std::cout <<
"<- pf = "
<<
pf
<<
"\n"
;
std::cout <<
"<- qf = "
<<
qf
<<
"\n"
;
std::cout <<
"<- rf = "
<<
rf
<<
"\n"
;
std::cout <<
"<- wt = "
<<
wt
<<
"\n"
;
std::cout <<
"-> harmmean(pf, qf) = "
<<
eve::harmmean
(
pf
,
qf
) <<
"\n"
;
std::cout <<
"-> harmmean(wt) = "
<<
eve::harmmean
(
wt
) <<
"\n"
;
std::cout <<
"-> harmmean[ignore_last(2)](pf, qf)= "
<<
eve::harmmean
[
eve::ignore_last
(2)](
pf
,
qf
) <<
"\n"
;
std::cout <<
"-> harmmean[pf > 0.0](pf, qf) = "
<<
eve::harmmean
[
pf
> 0.0](
pf
,
qf
) <<
"\n"
;
std::cout <<
"-> harmmean[pf > 0.0](pf, qf, rf) = "
<<
eve::harmmean
(
pf
,
qf
,
rf
) <<
"\n"
;
auto
tup
= kumi::tuple{
pf
,
qf
,
rf
};
std::cout <<
"<- tup = "
<<
tup
<<
"\n"
;
std::cout <<
"-> harmmean[kahan](tup) = "
<<
eve::harmmean
[eve::kahan](
tup
) <<
"\n"
;
}
eve::ignore_last
Conditional expression ignoring the k last lanes from a eve::simd_value.
Definition
conditional.hpp:320
eve::wide
Wrapper for SIMD registers.
Definition
wide.hpp:94
eve