11 #ifndef __UT_SobolSequence__
12 #define __UT_SobolSequence__
22 #include <type_traits>
26 template <
class itype, u
int DIM, u
int BITS = sizeof(itype)*8>
40 itype
x(
exint dim)
const {
return myX[dim]; }
49 fval.
uval = 0x3f800000 | (
uint)(
x(dim) << BITS_FROM_23);
51 fval.
uval = 0x3f800000 | (
uint)(
x(dim) >> BITS_FROM_23);
63 return ((SYSfastRandomInt(seed) % (val >> 1)) << 1) | 1;
65 static constexpr itype
69 for (
uint i = 0; i < BITS; i++)
70 mask |= itype(1) << i;
75 static constexpr
uint LEN_IV = DIM * (BITS + 1);
76 static constexpr
uint LEN_X = DIM;
77 static constexpr
uint MAXDIM = 6;
78 static constexpr itype MASK = computeMask();
79 static constexpr
uint BITS_FROM_23 = (BITS<23) ? (23-BITS) : (BITS-23);
110 template <
class itype, u
int DIM, u
int BITS>
112 : myIV(LEN_IV, LEN_IV)
116 constexpr
uint mdeg[MAXDIM] = {1,2,3,3,4,4};
117 constexpr
uint ip[MAXDIM] = {0,1,1,2,1,4};
124 itype **iu = (itype **)
UTstackAlloc((BITS+1)*
sizeof(itype *));
125 for (
uint i = 0; i < BITS+1; i++)
126 iu[i] = &myIV[i*DIM];
131 for (
uint i = 0; i < mdeg[
j]; i++)
132 iu[i][
j] = orand(1 << (i+1), seed);
134 for (
uint k = 0; k < DIM; k++)
137 for (
uint j = 0;
j < mdeg[k];
j++)
138 iu[
j][k] <<= (BITS-
j-1);
141 for (
uint j = mdeg[k];
j < BITS+1;
j++)
146 itype tmp = iu[
j-mdeg[k]][k];
147 tmp ^= (tmp >> mdeg[k]);
150 for (
uint l = mdeg[k]-1; l >= 1; l--)
165 template <
class itype, u
int DIM, u
int BITS>
173 itype
n = myN & MASK;
174 for (i = 0; i < BITS; i++)
183 for (i = 0; i < DIM; i++)
195 template <
class itype, u
int DIM, u
int BITS>
201 for (
uint i = 0; i < DIM; i++)
209 for (
uint i = 0; i < DIM; i++)
210 myX[i] ^= myIV[off+i];
217 #endif // __UT_SobolSequence__
#define SYS_STATIC_ASSERT(expr)
GLsizei const GLfloat * value
UT_Vector3T< float > UT_Vector3
UT_VectorSequence()=default
#define UTstackAlloc(size)
fpreal32 xf(exint dim) const
constexpr uint bits() const
void rewind(itype n=0)
Reset the sequence.
itype x(exint dim) const
Return the sequence value for dimension dim.
constexpr uint dimension() const