Callable object computing the mul operation.
Required header: #include <eve/function/mul.hpp>
Members Functions
Member | Effect |
operator() | the mul operation |
operator[] | Construct a conditional version of current function object |
template<
value T,
value ...Ts>
auto operator()( T x,Ts... args )
const noexcept
requires (compatiblevalues< T, Ts > && ...);
Parameters
x
, args
: values.
Return value
Return the multiplication of the values.
The result type is the common compatible type of the parameters.
The call mul(x, args, ...)
is equivalent to (x * args * ...)
if x
or one of the args
is an simd value.
- Warning
- Although the infix notation with
*
is supported for two parameters, the *
operator on standard scalar types is the original one and so can lead to automatic promotion.
auto operator[]( conditional_expression auto cond ) const noexcept;
Higher-order function generating a masked version of eve::mul
Parameters
cond
: conditional expression
Return value
A Callable object so that the expression mul[cond](x, ...)
is equivalent to if_else(cond,mul(x, ...),x)
Supported decorators
eve::saturated
Required header: #include <eve/function/saturated/mul.hpp>
The call saturated(mul)(x, args...)
computes the saturated multiplication of x
and args...
. The saturation is obtained in the common compatible type 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.
eve::diff, eve::diff_1st, eve::diff_2nd, eve::diff_3rd, eve::diff_nth
Required header: #include <eve/function/diff/mul.hpp>
The expression diff_< N >(mul)(x,args,...)
computes the partial diff of the function relative to the Nth parameter.
If the actual parameters are \(x_1, ... x_n\) the value returned is \(\prod_{i \neq N} x_i\) if \(1\le N \le n\) otherwise 0.
- Warning
- This is only available for floating point entries.
Example
See it live on Compiler Explorer
#include <eve/function/mul.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(pi, qi) = " <<
eve::mul(
pi, qi) <<
'\n'
<<
" -> pi * qi = " <<
pi * qi <<
'\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';
return 0;
}
constexpr callable_pi_ pi
Callable object computing the value.
Definition: pi.hpp:54
constexpr callable_mul_ mul
Callable object computing the mul operation.
Definition: mul.hpp:103
Wrapper for SIMD registers.
Definition: wide.hpp:65