This is the mail archive of the gsl-discuss@sources.redhat.com mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: BUG Report for QRNG-Niederreiter-sequence


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]