Skip to content

Commit

Permalink
Merge pull request #207 from c-bata/sobol-1000lines
Browse files Browse the repository at this point in the history
Avoid to skip 1000 lines from the top of direction numbers.
  • Loading branch information
c-bata authored Feb 9, 2021
2 parents f0ff33b + 593ac5f commit d023ea9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion _tools/codegen_sobol/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion sobol/direction_numbers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions sobol/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d023ea9

Please sign in to comment.