12#ifndef EIGENRAND_RAND_UTILS_SSE_H
13#define EIGENRAND_RAND_UTILS_SSE_H
21 template<
typename Rng,
typename RngResult>
22 struct RawbitsMaker<Packet4i, Rng, RngResult, Rand::RandomEngineType::scalar_fullbit>
24 EIGEN_STRONG_INLINE Packet4i rawbits(Rng& rng)
26 if (
sizeof(RngResult) == 8)
28 return _mm_set_epi64x(rng(), rng());
32 return _mm_set_epi32(rng(), rng(), rng(), rng());
36 EIGEN_STRONG_INLINE Packet4i rawbits_34(Rng& rng)
38 if (
sizeof(RngResult) == 8)
40 return _mm_set_epi64x(rng(), rng());
44#ifdef EIGEN_VECTORIZE_SSSE3
45 Packet4i p = _mm_setr_epi32(rng(), rng(), rng(), 0);
46 return _mm_shuffle_epi8(p, _mm_setr_epi8(
52 return _mm_set_epi32(rng(), rng(), rng(), rng());
57 EIGEN_STRONG_INLINE Packet4i rawbits_half(Rng& rng)
59 if (
sizeof(
decltype(rng())) == 8)
61 return _mm_set_epi64x(0, rng());
65 return _mm_setr_epi32(rng(), rng(), 0, 0);
70 template<
typename Rng>
71 struct RawbitsMaker<Packet4i, Rng, Packet4i, Rand::RandomEngineType::packet>
73 EIGEN_STRONG_INLINE Packet4i rawbits(Rng& rng)
78 EIGEN_STRONG_INLINE Packet4i rawbits_34(Rng& rng)
83 EIGEN_STRONG_INLINE Packet4i rawbits_half(Rng& rng)
89 template<
typename Rng>
90 struct UniformRealUtils<Packet4f, Rng> :
public RawbitsMaker<Packet4i, Rng>
92 EIGEN_STRONG_INLINE Packet4f zero_to_one(Rng& rng)
94 return pdiv((Packet4f)_mm_cvtepi32_ps(pand(this->rawbits(rng), pset1<Packet4i>(0x7FFFFFFF))),
95 pset1<Packet4f>(0x7FFFFFFF));
98 EIGEN_STRONG_INLINE Packet4f uniform_real(Rng& rng)
100 return bit_to_ur_float(this->rawbits_34(rng));
104 template<
typename Rng>
105 struct UniformRealUtils<Packet2d, Rng> :
public RawbitsMaker<Packet4i, Rng>
107 EIGEN_STRONG_INLINE Packet2d zero_to_one(Rng& rng)
109 return pdiv((Packet2d)_mm_cvtepi32_pd(pand(this->rawbits_half(rng), pset1<Packet4i>(0x7FFFFFFF))),
110 pset1<Packet2d>(0x7FFFFFFF));
113 EIGEN_STRONG_INLINE Packet2d uniform_real(Rng& rng)
115 return bit_to_ur_double(this->rawbits(rng));