## ◆ two_split()

 std::pair boost::simd::two_split ( Value const & x )

This function object computes two reals r0 and r1 (in an std::pair) such that:

x == r0+r1

and where r0 and r1 bit pattern don't overlap.

Example:
#include <boost/simd/arithmetic.hpp>
#include <boost/simd/pack.hpp>
#include <boost/simd/constant/eps.hpp>
#include <boost/simd/constant/pi.hpp>
#include <iostream>
namespace bs = boost::simd;
using pack_ft = bs::pack <float, 4>;
int main()
{
pack_ft pf = { 1.0f, -2.0f, 3.0f, -4.0 };
pf *= bs::Pi<float>();
pack_ft s, e;
std::tie(s, e) = bs::two_split(pf);
std::cout
<< "---- simd" << '\n'
<< " <- pf = " << pf << '\n'
<< " std::tie(s, e) = bs::two_split(pf) " << '\n'
<< " -> s = " << s << '\n'
<< " -> e = " << e << '\n';
float xf = 3.0f*bs::Pi<float>();
float ss, se;
std::tie(ss, se) = bs::two_split(xf);
std::cout
<< "---- scalar" << '\n'
<< " xf = " << xf << '\n'
<< " std::tie(ss, se) = bs::two_split(xf) " << '\n'
<< " -> ss = " << ss << '\n'
<< " -> se = " << se << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (3.14159, -6.28319, 9.42478, -12.5664)
std::tie(s, e) = bs::two_split(pf)
-> s = (3.14062, -6.28125, 9.42188, -12.5625)
-> e = (0.000967741, -0.00193548, 0.00290298, -0.00387096)
---- scalar
xf = 9.42478
std::tie(ss, se) = bs::two_split(xf)
-> ss = 9.42188
-> se = 0.00290298