E.V.E  0.1-beta

◆ copysign

eve::copysign = {}
inlineconstexpr

Callable object performing the sign copying operation.

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

Members Functions

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

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

Parameters

x, y: floating real value

Return value

Returns the elementwise composition of a value with the magnitude of x and the bit of sign of y.


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

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

Parameters

cond : conditional expression

Return value

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


Supported decorators

no decorators are supported

Example

See it live on Compiler Explorer

#include <eve/function/copysign.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 = {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'
<< "-> copysign(pf, qf) = " << eve::copysign(pf, qf) << '\n';
float xf = 4.0f;
float yf = -1.0f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "<- yf = " << yf << '\n'
<< "-> copysign(xf, yf) = " << eve::copysign(xf, yf) << '\n';
return 0;
}
constexpr callable_copysign_ copysign
Callable object performing the sign copying operation.
Definition: copysign.hpp:74
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
Lightweight type-wrapper.
Definition: as.hpp:29
Wrapper for SIMD registers.
Definition: wide.hpp:65