E.V.E
v2022.09.01

◆ sub

eve::sub = {}
inlineconstexpr

Computes the sum of its arguments.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< eve::value... Ts>
eve::common_compatible_t<Ts ...> sub(Ts ... xs) noexcept;
}
Definition: value.hpp:31
constexpr callable_sub_ sub
Computes the sum of its arguments.
Definition: sub.hpp:76
Definition: all_of.hpp:22

Parameters

Return value

If the arguments are \((x_i)_{0\le i\le n}\) The value of \(x_0-\sum_1^n x_i\) is returned.

Example

#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
w_t pi = {3, 2, -32700, 32700}, qi = {4, 1, 100, -100};
wf_t pf = {3, 2.5, -32.7, 1327.43}, qf = {-4.2, -1.5, 100.834, -10.02};
std::cout << "---- simd" << '\n'
<< " <- pi = " << pi << '\n'
<< " <- qi = " << qi << '\n'
<< " -> sub(pi, qi) = " << eve::sub(pi, qi) << '\n'
<< " -> pi - qi = " << pi - qi << '\n'
<< " -> pf - qf = " << pf - qf << '\n';
std::int16_t xi = 100, yi = 32700;
std::cout << "---- scalar" << '\n'
<< " <- xi = " << xi << '\n'
<< " <- yi = " << yi << '\n'
<< " -> sub(xi, yi) = " << eve::sub(xi, yi) << '\n'
<< " -> xi - yi = " << xi - yi << '\n'; // C++ promotion to int
return 0;
}
constexpr callable_pi_ pi
Callable object computing the constant .
Definition: pi.hpp:49
Wrapper for SIMD registers.
Definition: wide.hpp:65

Semantic Modifiers

  • Masked Call

    The call eve::sub[mask](x, ...) provides a masked version of sub which is equivalent to if_else(mask, sub(x, ...), x)

    Example

    #include <eve/module/core.hpp>
    #include <eve/wide.hpp>
    #include <iostream>
    int main()
    {
    w_t pi = {3, 2, -32700, 32700}, qi = {4, 1, 100, -100};
    std::cout << "---- simd" << '\n'
    << " -> sub[pi > qi](pi, qi) = " << eve::sub[pi > qi](pi, qi) << '\n';
    return 0;
    }
  • eve::saturated

    The call eve::saturated(eve::sub)(...) computes a saturated version of eve::sub.

    Take care that for signed integral entries this kind of operation is highly order dependant. We do not advise to use it for more than 2 parameters.

    Example

    #include <eve/module/core.hpp>
    #include <eve/wide.hpp>
    #include <iostream>
    int main()
    {
    w_t pi = {3, 2, -32700, 32700}, qi = {4, 1, 100, -100};
    std::cout << "---- simd" << '\n'
    << " <- pi = " << pi << '\n'
    << " <- qi = " << qi << '\n'
    << " -> saturated(sub)(pi, qi) = " << eve::saturated(eve::sub)(pi, qi) << '\n';
    return 0;
    }
    constexpr saturated_type const saturated
    Higher-order Callable Object imbuing saturation semantic onto other Callable Objects.
    Definition: saturated.hpp:68