This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
Re: BUG Report for QRNG-Niederreiter-sequence
- From: Brian Gough <bjg at network-theory dot co dot uk>
- To: Wolfgang Hoermann <hormannw at boun dot edu dot tr>
- Cc: gsl-discuss at sources dot redhat dot com, bug-gsl at gnu dot org
- Date: Sat, 16 Nov 2002 19:04:42 +0000 (GMT)
- Subject: Re: BUG Report for QRNG-Niederreiter-sequence
- References: <3DD3ABCC.9E4E115D@boun.edu.tr>
Wolfgang Hoermann writes:
> This is a bug report and bug-demonstration file for gsl-1.2 For
> qrng for the Niedereiter-sequence. The below program should
> generate the same sequence 3 times and thus also print three
> identical lines, as the state of the sequence is reset by the
> "gsl_qrng_init(qmc)" - command between the for-loops.
> But the output on my computer is
> 0.171875,0.890625,0.628906,0.378906,
> 0.171875,0.890625,0.628906,0.378906,
> 0.171875,0.890625,0.519531,0.378906,
> There occur similar problems for dimension 3 and for higher
> dimensions.
Thanks for the bug report. I found an uninitialised memory access with
checkergcc which looks like to source of the problem. Here is a
patch.
Index: niederreiter-2.c
===================================================================
RCS file: /cvs/gsl/gsl/qrng/niederreiter-2.c,v
retrieving revision 1.11
diff -u -5 -r1.11 niederreiter-2.c
--- niederreiter-2.c 19 Nov 2001 22:32:08 -0000 1.11
+++ niederreiter-2.c 16 Nov 2002 19:00:57 -0000
@@ -249,10 +249,16 @@
for(k=0; k<=px_degree; k++) {
px[k] = primitive_poly[poly_index][k];
pb[k] = 0;
}
+
+ for (;k<NIED2_MAX_DEGREE+1;k++) {
+ px[k] = 0;
+ pb[k] = 0;
+ }
+
pb[0] = 1;
for(j=0; j<NIED2_NBITS; j++) {
/* If U = 0, we need to set B to the next power of PX