E.V.E  0.1-beta

◆ pow

eve::pow = {}
inlineconstexpr

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

Required header: #include <eve/function/pow.hpp>

Members Functions

Member Effect
operator() the pow operation
operator[] Construct a conditional version of current function object

template< value T, value U > auto operator()( T x, U y ) const noexcept requires compatible< T, U >;

Parameters

x, y: values.

Return value

Returns elementwise \(x^y\).

The result type is the common compatible type of the two parameters. In paticular 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

auto operator[]( conditional_expression auto cond ) const noexcept;

Higher-order function generating a masked version of eve::pow

Parameters

cond : conditional expression

Return value

A Callable object so that the expression pow[cond](x, ...) is equivalent to if_else(cond,pow(x, ...),x)


Supported decorators

  • eve::diff, eve::diff_1st, eve::diff_2nd, eve::diff_nth

    Required header: #include <eve/function/diff/pow.hpp>

    The expression diff_1st(pow)(x,y) and diff_2nd(pow)(x,y) computes the partial derivatives of \(f\), where \(f\) is the function \((x,y) \rightarrow \ x^y\).

Example

See it live on Compiler Explorer

#include <eve/function/pow.hpp>
#include <eve/wide.hpp>
#include <eve/constant/inf.hpp>
#include <eve/constant/minf.hpp>
#include <eve/constant/nan.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
Callable object computing the nan value.
Definition: nan.hpp:52
constexpr callable_minf_ minf
Callable object computing the negative infinity value.
Definition: minf.hpp:55
constexpr callable_inf_ inf
Callable object computing the infinity ieee value.
Definition: inf.hpp:54
constexpr callable_pow_ pow
Callable object computing the pow operation .
Definition: pow.hpp:103
Lightweight type-wrapper.
Definition: as.hpp:29
Wrapper for SIMD registers.
Definition: wide.hpp:65