E.V.E
v2022.09.01

◆ pow

eve::pow = {}
inlineconstexpr

Callable object computing the pow operation \(x^y\).

Defined in Header

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
template< eve::floating_value T, eve::floating_value U >
auto pow(T x, U y) noexcept; //1
template< eve::floating_value T, eve::floating_value U > //2
auto pow(eve::as_complex_t<T> x, U y) noexcept;
template< eve::floating_value T, eve::floating_value U > //2
auto pow(T x, eve::as_complex_t<U> y) noexcept;
template< eve::floating_value T, eve::floating_value U >
auto pow(eve::as_complex_t<T> x, eve::as_complex_t<U> y) noexcept; //2
}
constexpr callable_pow_ pow
Callable object computing the pow operation .
Definition: pow.hpp:100
Definition: all_of.hpp:22

Parameters

x, y: real floating or complex arguments.

Return value

Returns elementwise \(x^y\).

  1. The result type is the common compatible type of the two parameters. In particular we have (IEC 60559):
    • pow(+0, y), where y is a negative odd integer, returns \(+\infty\)
    • pow(-0, y), where y is a negative odd integer, returns \(-\infty\)
    • pow( \(\pm0\), y), where y is negative, finite, and is an even integer or a non-integer, returns \(+\infty\)
    • pow( \(\pm0\), \(-\infty\)) returns \(+\infty\)
    • pow(+0, y), where y is a positive odd integer, returns +0
    • pow(-0, y), where y is a positive odd integer, returns -0
    • pow( \(\pm0\), y), where y is positive non-integer or a positive even integer, returns +0
    • pow(-1, \(\pm\infty\)) returns 1
    • pow(+1, y) returns 1 for any y, even when y is NaN
    • pow(x, \(\pm0\)) returns 1 for any x, even when x is NaN
    • pow(x, y) returns NaN if x is finite and less than 0 and y is finite and non-integer.
    • pow(x, \(-\infty\)) returns \(+\infty\) for any |x|<1
    • pow(x, \(-\infty\)) returns +0 for any |x|>1
    • pow(x, \(+\infty\)) returns +0 for any |x|<1
    • pow(x, \(+\infty\)) returns \(+\infty\) for any |x|>1
    • pow( \(-\infty\), y) returns -0 if y is a negative odd integer
    • pow( \(-\infty\), y) returns +0 if y is a negative non-integer or even integer
    • pow( \(-\infty\), y) returns \(-\infty\) if y is a positive odd integer
    • pow( \(-\infty\), y) returns \(+\infty\) if y is a positive non-integer or even integer
    • pow( \(+\infty\), y) returns +0 for any y less than 0
    • pow( \(+\infty\), y) returns \(+\infty\) for any y greater than 0
    • except where specified above, if any argument is NaN, NaN is returned

In the other cases the call is semantically equivalent to eve::exp(y*eve::log(x)) and return and eve::complex result.

Example

#include <eve/module/math.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_ft pf = {2.0f, 3.0f, -4.0f, 2.0f, 2.0f,
wide_ft qf = {4.0f, 1.0f, -1.0f, 0.5f, 0.0f,
-2.0f, -3.0f, 2.5f};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "<- qf = " << qf << '\n'
<< "-> pow(pf, qf) = " << eve::pow(pf, qf) << '\n'
;
float xf = 4.0f;
float yf = -1.0f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "<- yf = " << yf << '\n'
<< "-> pow(xf, yf) = " << eve::pow(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:60
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[mask](x, y) provides a masked version of eve::pow which is equivalent to if_else (mask, pow(x, y), x).

    Example

    #include <eve/module/math.hpp>
    #include <eve/wide.hpp>
    #include <iostream>
    int main()
    {
    wide_ft pf = {0.0f, -0.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[pf > 1.0](pf, qf) = " << eve::pow[pf > 1.0](pf, qf) << '\n';
    return 0;
    }