E.V.E
v2022.03.00

◆ exp2

eve::exp2 = {}
inlineconstexpr

Callable object computing \(2^x\).

Defined in Header

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
template< eve::floating_value T >
T exp2(T x) noexcept; //1
template< eve::floating_value T >
}
constexpr callable_exp10_ exp10
Callable object computing .
Definition: exp10.hpp:98
constexpr callable_exp2_ exp2
Callable object computing .
Definition: exp2.hpp:99
Definition: all_of.hpp:22
SIMD-compatible representation of complex numbers.
Definition: complex.hpp:40

Parameters

Return value

Returns the elementwise exponential of base 2 of the input. In particular, for floating inputs:

  • If the element is \(\pm0\), \(1\) is returned
  • If the element is \(-\infty\), \(+0\) is returned
  • If the element is \(\infty\), \(\infty\) is returned
  • If the element is a NaN, NaN is returned

Returns elementwise the exponential of base 10 of the input as if computed by eve::exp (eve::log_2(as(z))*z).

Example

#include <eve/module/math.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_ft pf = {0.0f, -0.0f, -1.0f, 33.0f, 2.0f,
wide_it pi = {0, 2, 8, 33};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "<- pi = " << pi << '\n'
<< "-> exp2(pf) = " << eve::exp2(pf) << '\n'
<< "-> exp2(pi) = " << eve::exp2(pi) << '\n'
<< "-> float32(exp2)(pi) = " << eve::float32(eve::exp2)(pi) << '\n'
<< "-> float64(exp2)(pi) = " << eve::float64(eve::exp2)(pi) << '\n'
<< "-> floating_(exp2)(pi) = " << eve::floating_(eve::exp2)(pi) << '\n'
<< "-> float32(exp2(pi)) = " << eve::float32(eve::exp2(pi)) << '\n'
<< "-> float64(exp2(pi)) = " << eve::float64(eve::exp2(pi)) << '\n'
<< "-> floating_(exp2(pi)) = " << eve::floating_(eve::exp2(pi)) << '\n';
float xf = 1.0f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> exp2(xf) = " << eve::exp2(xf) << '\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
constexpr converter_type< float > const float32
convert a eve::value to a float32 based eve::floating_value.
Definition: converter.hpp:130
constexpr converter_type< double > const float64
convert a eve::value to a double based eve::floating_value.
Definition: converter.hpp:175
constexpr floating_converter const floating_
convert a eve::value to an eve::floating_value.
Definition: converter.hpp:693
constexpr callable_pi_ pi
Callable object computing the constant .
Definition: pi.hpp:49
Lightweight type-wrapper.
Definition: as.hpp:29
Wrapper for SIMD registers.
Definition: wide.hpp:65

Semantic Modifiers

  • Masked Call

    The call eve::exp2[mask](x) provides a masked version of eve::exp2 which is equivalent to if_else (mask, exp2(x), 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, 2.0f,
    std::cout << "---- simd" << '\n'
    << "<- pf = " << pf << '\n'
    << "-> exp2[pf > 1.0](pf) = " << eve::exp2[pf > 1.0](pf) << '\n';
    return 0;
    }