E.V.E
v2022.03.00

◆ pow_abs

eve::pow_abs = {}
inlineconstexpr

Callable object computing the pow_abs function \(|x|^y\).

Defined in Header

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
template< eve::floating_value T, eve::floating_value U >
T pow_abs(T x, U y) noexcept;
}
constexpr callable_pow_abs_ pow_abs
Callable object computing the pow_abs function .
Definition: pow_abs.hpp:84
Definition: all_of.hpp:22

Parameters

x: value.

y: real value.

Return value

Returns elementwise \(|x|^y\).

The result type is the common compatible type of the two parameters. In particular we have (IEC 60559):

  • pow_abs( \(\pm0\), y), where y is a negative odd integer, returns \(+\infty\).
  • pow_abs( \(\pm0\), y), where y is negative, finite, and is an even integer or a non-integer, returns \(+\infty\).
  • pow_abs( \(\pm0\), \(-\infty\)) returns \(+\infty\).
  • pow_abs( \(\pm0\), y), where y is a positive odd integer, returns \(+0\).
  • pow_abs( \(\pm0\), y), where y is positive non-integer or a positive even integer, returns \(+0\).
  • pow_abs(-1, \(\pm\infty\)) returns 1.
  • pow_abs( \(\pm1\), y) returns 1 for any y, even when y is NaN.
  • pow_abs(x, \(\pm0\)) returns 1 for any x, even when x is NaN.
  • pow_abs(x, \(-\infty\)) returns \(+\infty\) for any |x| < 1.
  • pow_abs(x, \(-\infty\)) returns \(+0\) for any |x| > 1.
  • pow_abs(x, \(+\infty\)) returns \(+0\) for any |x| < 1.
  • pow_abs(x, \(+\infty\)) returns \(+\infty\) for any |x| > 1.
  • pow_abs( \(+\infty\), y) returns \(+0\) for any negative y.
  • pow_abs( \(+\infty\), y) returns \(+\infty\) for any positive y.
  • except where specified above, if any argument is NaN, NaN is returned.

Example

#include <eve/module/math.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_ft pf = {0.0f, 1.0f, -1.0f, -2.0f, 2.0f,
wide_ft qf = {4.0f, 1.0f, -1.0f, 0.0f, -0.0f,
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "<- qf = " << qf << '\n'
<< "-> pow_abs(pf, qf) = " << eve::pow_abs(pf, qf) << '\n'
;
float xf = 4.0f;
float yf = -1.0f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "<- yf = " << yf << '\n'
<< "-> pow_abs(xf, yf) = " << eve::pow_abs(xf, yf) << '\n';
return 0;
}
constexpr callable_nan_ nan
Computes the IEEE NaN constant.
Definition: nan.hpp:53
constexpr callable_minf_ minf
Computes the -infinity ieee value.
Definition: minf.hpp:95
constexpr callable_inf_ inf
Computes the infinity ieee value.
Definition: inf.hpp:58
Lightweight type-wrapper.
Definition: as.hpp:29
Wrapper for SIMD registers.
Definition: wide.hpp:65

Semantic Modifiers

  • Masked Call

    The call eve::pow_abs[mask](x, y) provides a masked version of eve::pow_abs which is equivalent to if_else (mask, pow_abs(x, y), x).

    Example

    #include <eve/module/math.hpp>
    #include <eve/wide.hpp>
    #include <iostream>
    int main()
    {
    wide_ft pf = {-4.0f, -3.0f, -1.0f, 1.0f},
    qf = { 20.0f, -5.0f, 8.0f, 1.0f};
    std::cout << "---- simd" << '\n'
    << "<- pf = " << pf << '\n'
    << "<- qf = " << qf << '\n'
    << "-> pow_abs[pf > -3.5](pf, qf) = " << eve::pow_abs[pf > -3.5](pf, qf) << '\n';
    return 0;
    }