E.V.E  0.1-beta

◆ ldexp

eve::ldexp = {}
inlineconstexpr

Callable object computing the ldexp operation: \(\textstyle x 2^n\).

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

Members Functions

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

template< floating_value T, integral_real_value U > auto operator()( T x, U n ) const noexcept
requires compatible< T, U >;

Parameters

x: floating real value.

n: integral real value.

Return value

the call ldexp(x,n) is semantically equivalent to \(\textstyle x 2^n\):


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

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

Parameters

cond : conditional expression

Return value

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


Supported decorators

no decorators are supported

Example

See it live on Compiler Explorer

#include <eve/function/ldexp.hpp>
#include <eve/wide.hpp>
#include <eve/constant/mindenormal.hpp>
#include <eve/constant/minf.hpp>
#include <eve/constant/inf.hpp>
#include <eve/constant/nan.hpp>
#include <iostream>
using iT = std::int32_t;
using wide_it = eve::wide<iT, eve::fixed<4>>;
int main()
{
wide_it qi = {12, 2, -2, 3 };
wide_ft pf = {1.0f, -1.0f, 0.0f, -2.0f};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "<- qi = " << qi << '\n'
<< "-> ldexp(pf, qi) = " << eve::ldexp(pf, qi) << '\n';
float xf = 2, mxf = -2;
iT yi = 3;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "<- mxf = " << mxf << '\n'
<< "<- yi = " << yi << '\n'
<< "-> ldexp(xf, yi) = " << eve::ldexp(xf, yi) << '\n'
<< "-> ldexp(mxf, yi) = " << eve::ldexp(mxf, yi) << '\n';
return 0;
}
constexpr callable_ldexp_ ldexp
Callable object computing the ldexp operation: .
Definition: ldexp.hpp:89
Wrapper for SIMD registers.
Definition: wide.hpp:65