diff --git a/_tools/codegen_sobol/main.go b/_tools/codegen_sobol/main.go index 12f2b9a6..dc549d16 100644 --- a/_tools/codegen_sobol/main.go +++ b/_tools/codegen_sobol/main.go @@ -103,7 +103,7 @@ func main() { fmt.Fprintf(fout, "\n") fmt.Fprintf(fout, "// The original data of direction numbers is distributed at https://web.maths.unsw.edu.au/~fkuo/sobol/ (BSD License).\n") fmt.Fprintf(fout, "\n") - fmt.Fprintf(fout, "const maxDim = 21201 - 1002 // Due to skip 1000 lines\n") + fmt.Fprintf(fout, "const maxDim = 21201 - 2\n") fmt.Fprintf(fout, "const maxDeg = 18\n") fmt.Fprintf(fout, "const maxBit = 30\n") fmt.Fprintf(fout, "\n") diff --git a/sobol/direction_numbers.go b/sobol/direction_numbers.go index 4a0ca922..c3adb1e3 100644 --- a/sobol/direction_numbers.go +++ b/sobol/direction_numbers.go @@ -4,7 +4,7 @@ package sobol // The original data of direction numbers is distributed at https://web.maths.unsw.edu.au/~fkuo/sobol/ (BSD License). -const maxDim = 21201 - 1002 // Due to skip 1000 lines +const maxDim = 21201 - 2 const maxDeg = 18 const maxBit = 30 diff --git a/sobol/engine.go b/sobol/engine.go index 4677089f..65fb8003 100644 --- a/sobol/engine.go +++ b/sobol/engine.go @@ -30,10 +30,13 @@ func initDirectionNumbers(dim uint32) [][]uint32 { v[j] = make([]uint32, maxBit+1) // Read in parameters from file - // Skip 1000 lines from the top as Joe&Kuo's C++ program do. - dn := directionNumbers[1000+j] + dn := directionNumbers[j] + m := make([]uint32, len(dn.M)+1) + for i := uint32(0); i < dn.S; i++ { + m[i+1] = dn.M[i] + } for i := uint32(1); i <= dn.S; i++ { - v[j][i] = dn.M[i-1] << (32 - i) + v[j][i] = m[i] << (32 - i) } for i := dn.S + 1; i <= maxBit; i++ { v[j][i] = v[j][i-dn.S] ^ (v[j][i-dn.S] >> dn.S)