◆ div()

Value boost::simd::div ( Option const &  ,
Value const &  x,
Value const &  y 
)

This function object computes the quotient of the two parameters of the same type with or without option.

Header <boost/simd/function/div.hpp>
Notes

For any value x and y of same type div({option, }x, y) returns the quotient of x by y respecting to the option specified.

With no option this function is equivalent to divides(x, y) (See divides.)

Options may be ceil, floor, fix, round, nearbyint (in the namespace booost::simd) and provides the same result as if the function object whose option is the name was applied to the floating division of the parameters.

See also
divides, rec
Example:
#include <boost/simd/arithmetic.hpp>
#include <boost/simd/pack.hpp>
#include <iostream>
namespace bs = boost::simd;
using pack_ft = bs::pack <float, 4>;
int main()
{
pack_ft pf = { 5.0f, -5.0f, 3.0f, 5.0f };
pack_ft qf = { 2.0f, 2.0f, 3.0f, -2.0f };
std::cout
<< "---- simd" << '\n'
<< " <- pf = " << pf << '\n'
<< " <- qf = " << qf << '\n'
<< " -> bs::div(pf, qf) = " << bs::div(pf, qf) << '\n'
<< " -> bs::div(bs::fix, pf, qf) = " << bs::div(bs::fix, pf, qf) << '\n'
<< " -> bs::div(bs::ceil, pf, qf) = " << bs::div(bs::ceil, pf, qf) << '\n'
<< " -> bs::div(bs::floor, pf, qf) = " << bs::div(bs::floor, pf, qf) << '\n'
<< " -> bs::div(bs::round, pf, qf) = " << bs::div(bs::round, pf, qf) << '\n'
<< " -> bs::div(bs::nearbyint, pf, qf) = " << bs::div(bs::nearbyint, pf, qf) << '\n';
float xf = 5.0, yf = 2.0f;
std::cout
<< "---- scalar" << '\n'
<< " <- xf = " << xf << '\n'
<< " <- yf = " << yf << '\n'
<< " -> bs::div( xf, yf) = " << bs::div(xf, yf) << '\n'
<< " -> bs::div(bs::fix, xf, yf) = " << bs::div(bs::fix, xf, yf) << '\n'
<< " -> bs::div(bs::ceil, xf, yf) = " << bs::div(bs::ceil, xf, yf) << '\n'
<< " -> bs::div(bs::floor, xf, yf) = " << bs::div(bs::floor, xf, yf) << '\n'
<< " -> bs::div(bs::round, xf, yf) = " << bs::div(bs::round, xf, yf) << '\n'
<< " -> bs::div(bs::nearbyint, xf, yf) = " << bs::div(bs::nearbyint, xf, yf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (5, -5, 3, 5)
<- qf = (2, 2, 3, -2)
-> bs::div(pf, qf) = (2.5, -2.5, 1, -2.5)
-> bs::div(bs::fix, pf, qf) = (2, -2, 1, -2)
-> bs::div(bs::ceil, pf, qf) = (3, -2, 1, -2)
-> bs::div(bs::floor, pf, qf) = (2, -3, 1, -3)
-> bs::div(bs::round, pf, qf) = (3, -3, 1, -3)
-> bs::div(bs::nearbyint, pf, qf) = (2, -2, 1, -2)
---- scalar
<- xf = 5
<- yf = 2
-> bs::div( xf, yf) = 2.5
-> bs::div(bs::fix, xf, yf) = 2
-> bs::div(bs::ceil, xf, yf) = 3
-> bs::div(bs::floor, xf, yf) = 2
-> bs::div(bs::round, xf, yf) = 3
-> bs::div(bs::nearbyint, xf, yf) = 2