E.V.E
v2023.02.15
Loading...
Searching...
No Matches

◆ div

auto eve::div = functor<div_t>
inlineconstexpr

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto div(value auto x, value auto ... xs) noexcept; // 1
constexpr auto div(eve::non_empty_product_type auto const& tup) noexcept; // 2
// Lanes masking
constexpr auto div[conditional_expr auto c](/*any of the above overloads*/) noexcept; // 3
constexpr auto div[logical_value auto m](/*any of the above overloads*/) noexcept; // 3
// Semantic exclusive options
constexpr auto div[upward](/*any of the above overloads*/) noexcept; // 4
constexpr auto div[downward](/*any of the above overloads*/) noexcept; // 4
constexpr auto div[toward_zero](/*any of the above overloads*/) noexcept; // 4
constexpr auto div[to_nearest](/*any of the above overloads*/) noexcept; // 4
constexpr auto div[lower](/*any of the above overloads*/) noexcept; // 5
constexpr auto div[upper](/*any of the above overloads*/) noexcept; // 6
constexpr auto div[lower][srict](/*any of the above overloads*/) noexcept; // 5
constexpr auto div[upper][srict](/*any of the above overloads*/) noexcept; // 6
// Semantic options
constexpr auto div[right](/*any of the above overloads*/) noexcept; // 1
constexpr auto div[saturated](integral_value auto x, integral_value auto y)) noexcept; // 7
constexpr auto div[left](/*any of the above overloads*/) noexcept; // 8
constexpr auto div[mod = p](/*any of the above overloads*/) noexcept; // 9
}
Specifies that a type is a Conditional Expression.
Definition conditional.hpp:28
The concept integral_value<T> is satisfied if and only if T satisfies eve::value and the element type...
Definition value.hpp:51
The concept logical_value<T> is satisfied if and only if T satisfies eve::value and the element type ...
Definition value.hpp:134
The concept value<T> is satisfied if and only if T satisfies either eve::scalar_value or eve::simd_va...
Definition value.hpp:34
constexpr auto div
elementwise_callable object computing the division of multiple values.
Definition div.hpp:147
constexpr auto lower
Guarantees a result no greater than the exact mathematical one.
Definition core.hpp:103
constexpr auto upper
Guarantees a result no smaller than the exact mathematical one.
Definition core.hpp:102
constexpr auto downward
Rounds toward .
Definition core.hpp:80
constexpr auto to_nearest
Rounds to the nearest integer, ties going to the even one.
Definition core.hpp:99
constexpr auto saturated
Keeps the result inside the range of its type instead of wrapping or overflowing.
Definition core.hpp:104
constexpr auto right
Applies the operation in the order the operands are written.
Definition core.hpp:96
constexpr auto toward_zero
Rounds toward zero.
Definition core.hpp:100
constexpr auto upward
Rounds toward .
Definition core.hpp:101
constexpr auto left
Swaps the two operands before applying the operation.
Definition core.hpp:87
EVE Main Namespace.
Definition abi.hpp:19

Parameters

Return value

  1. If the arguments are \((x_i)_{0\le i\le n}\) The value of \(x/\prod_1^n x_i\) is returned.
  2. equivalent to the call on the elements of the tuple.
  3. The operation is performed conditionally
  4. If z denotes the prduct of the xs, the call div[o](x, xs...) produces:
  5. The floating division is computed in a rounding mode such that the result is guaranteed to be less or equal to the exact one (except for Nans).Combined with strict the option ensures generally faster computation, but strict inequality.
  6. The floating division is computed in a rounding mode such that the result is guaranteed to be greater or equal to the exact one (except for Nans). Combined with strict the option ensures generally faster computation, but strict inequality.
  7. computes the saturated division of x by y. The result is always defined even if the denominator is 0.
  8. div[left](a, b) is semantically equivalent to div(b, a)

    The relevant cases are just in fact the division by 0 for integral types in which case the result is eve::valmin(as(x)) or [valmax(as(x))](ref eve::valmax) according to the dividend sign, and the division of valmin(as(x)) by -1 that produces valmax(as(x)).

  9. compute the result in modular arithmetic. the parameters must be positive flint and less than the modulus. The modulus itself must be less than maxflint.
Note
  • With two parameters, the call div(x, y) is equivalent to x / y if x or y is an simd value.
  • 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.

Example

// revision 1
#include <eve/module/core.hpp>
#include <iostream>
#include <iomanip>
int main()
{
wf_t pf = {3.2, 1.6, 3, 32700}, qf = {4.1, 2.345, 1, 100};
std::cout << "---- simd" << std::setprecision(10) << '\n'
<< " <- pf = " << pf << '\n'
<< " <- qf = " << qf << '\n'
<< " -> div(pf, qf) = " << eve::div(pf, qf) << '\n'
<< " -> pf / qf = " << pf / qf << '\n'
<< " -> div[left](pf, qf) = " << eve::div[eve::left](pf, qf) << "\n"
<< " -> div[upper](pf, qf) = " << eve::div[eve::upper](pf, qf) << '\n'
<< " -> div[lower](pf, qf) = " << eve::div[eve::lower](pf, qf) << '\n'
<< " -> div[pf> qf](pf, qf) = " << eve::div[pf>qf](pf, qf) << '\n';
wf_t rf = {3034, 200, 333, 32700}, sf = {4, 7, 13, 100};
std::cout << "---- simd" << '\n'
<< " <- rf = " << rf << '\n'
<< " <- sf = " << sf << '\n'
<< " -> div[toward_zero](rf, sf) = " << eve::div[eve::toward_zero](rf, sf) << '\n'
<< " -> div[lower](rf, sf) = " << eve::div[eve::lower](rf, sf) << '\n'
<< " -> div[upper](rf, sf) = " << eve::div[eve::upper](rf, sf) << '\n'
<< " -> div[to_nearest](rf, sf) = " << eve::div[eve::to_nearest](rf, sf) << '\n';
auto k = kumi::tuple{pf, pf, pf, 1};
std::cout << "---- multi parameters" << '\n'
<< " -> div(k) = " << eve::div(k) << '\n'
<< " -> div(kumi::tuple{pf, pf}) = " << eve::div( kumi::tuple{pf, pf}) << '\n'
<< " -> div(kumi::tuple{pf, 1.0f) = " << eve::div( kumi::tuple{pf, 1.0f}) << '\n'
<< " -> div(kumi::tuple{1.0f, pf) = " << eve::div( kumi::tuple{1.0f, pf}) << '\n';
}
Wrapper for SIMD registers.
Definition wide.hpp:94