Skip to content

Commit d023ea9

Browse files
authored
Merge pull request #207 from c-bata/sobol-1000lines
Avoid to skip 1000 lines from the top of direction numbers.
2 parents f0ff33b + 593ac5f commit d023ea9

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

_tools/codegen_sobol/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func main() {
103103
fmt.Fprintf(fout, "\n")
104104
fmt.Fprintf(fout, "// The original data of direction numbers is distributed at https://web.maths.unsw.edu.au/~fkuo/sobol/ (BSD License).\n")
105105
fmt.Fprintf(fout, "\n")
106-
fmt.Fprintf(fout, "const maxDim = 21201 - 1002 // Due to skip 1000 lines\n")
106+
fmt.Fprintf(fout, "const maxDim = 21201 - 2\n")
107107
fmt.Fprintf(fout, "const maxDeg = 18\n")
108108
fmt.Fprintf(fout, "const maxBit = 30\n")
109109
fmt.Fprintf(fout, "\n")

sobol/direction_numbers.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sobol/engine.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,13 @@ func initDirectionNumbers(dim uint32) [][]uint32 {
3030
v[j] = make([]uint32, maxBit+1)
3131

3232
// Read in parameters from file
33-
// Skip 1000 lines from the top as Joe&Kuo's C++ program do.
34-
dn := directionNumbers[1000+j]
33+
dn := directionNumbers[j]
34+
m := make([]uint32, len(dn.M)+1)
35+
for i := uint32(0); i < dn.S; i++ {
36+
m[i+1] = dn.M[i]
37+
}
3538
for i := uint32(1); i <= dn.S; i++ {
36-
v[j][i] = dn.M[i-1] << (32 - i)
39+
v[j][i] = m[i] << (32 - i)
3740
}
3841
for i := dn.S + 1; i <= maxBit; i++ {
3942
v[j][i] = v[j][i-dn.S] ^ (v[j][i-dn.S] >> dn.S)

0 commit comments

Comments
 (0)