E.V.E
v2023.02.15

◆ mul

eve::mul = {}
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_value_t<Ts ...> mul(Ts ... x) noexcept;
}
Definition: value.hpp:31
constexpr callable_mul_ mul
Computes the sum of its arguments.
Definition: mul.hpp:83
Definition: abi.hpp:18
typename eve::detail::common_value_impl< void, Ts... >::type common_value_t
Computes the SIMD-compatible common type between all Ts.
Definition: common_value.hpp:50

Parameters

Return value

The value of the product of the arguments is returned.

Note
Take care that for floating entries, the multiplication is only 'almost' associative. This call performs multiplications in reverse incoming order.

Example

#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
w_t pi = {3, 2, 3, 32700}, qi = {4, 1, -1, 100};
wf_t pf = {3.5, 2, 3, 32700}, qf = {4, -1.3, 1, 100};
std::cout << "---- simd" << '\n'
<< " <- pi = " << pi << '\n'
<< " <- qi = " << qi << '\n'
<< " -> mul(pi, qi) = " << eve::mul(pi, qi) << '\n'
<< " -> pi * qi = " << pi * qi << '\n'
<< " -> saturated(mul)((pi, qi) = " << eve::saturated(eve::mul)(pi, qi) << '\n'
<< " <- pf = " << pf << '\n'
<< " <- qf = " << qf << '\n'
<< " -> mul(pf, qf) = " << eve::mul(pf, qf) << '\n'
<< " -> pf * qf = " << pf * qf << '\n';
std::int16_t xi = 100, yi = 32700;
std::cout << "---- scalar" << '\n'
<< " xi = " << xi << '\n'
<< " yi = " << yi << '\n'
<< " -> mul(xi, yi) = " << eve::mul(xi, yi) << '\n'
<< " -> xi * yi = " << xi * yi << '\n'; // C++ promotion
auto k = kumi::tuple{pf, pf, pf, 1};
std::cout << "---- multi parameters" << '\n'
<< " -> mul(pi,pi,pi,1) = " << eve::mul(pi, pi, pi, 1) << '\n'
<< " -> mul(k) = " << eve::mul(k) << '\n'
<< " -> mul(kumi::tuple{pf, pf}) = " << eve::mul( kumi::tuple{pf, pf}) << '\n'
<< " -> mul(kumi::tuple{pf, 1.0f) = " << eve::mul( kumi::tuple{pf, 1.0f}) << '\n'
<< " -> mul(kumi::tuple{1.0f, pf) = " << eve::mul( kumi::tuple{1.0f, pf}) << '\n'
<< " -> saturated(mul)(pi,12,pi,pi) = " << eve::saturated(eve::mul)(pi, 12, pi,pi) << '\n';
return 0;
}
constexpr saturated_type const saturated
Higher-order Callable Object imbuing saturation semantic onto other Callable Objects.
Definition: saturated.hpp:68
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::mul[mask](x, ...) provides a masked version of mul which is equivalent to if_else(mask, mul(x, ...), x)

    Example

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

    The call saturated(mul)(args...) computes the saturated multiplication `of the arguments. The saturation is obtained in the common value of the N parameters. The computation is done as if all arguments were converted to this type and the saturated multiplication applied recursively on all parameters. No overflow occurs.

    Example

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

    The call pedantic(mul)(zargs...) computes the pedantic multiplication of the arguments. This may only differ of the regular call for complex inputs.