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]

error in gsl discrete rng


Hi Andrew,
  Thanks again for your bug report which was a model
of clarity.  The example code instantly exhibited the
problem, which was quite severe.
  The fix that you suggested would indeed fix the problem,
and in my view, would be algorithmically correct as well.
I will suggest a somewhat more parsimonious fix, which is
basically to change a 'break' to a 'continue'.  The suggested
patch appears below; it also takes out a comment which I
now realize is incorrect, and adds a sanity check which *should*
be unnecessary (but then that could be said of most sanity
checks, I suppose).
  I'm off to go watch the superbowl, but when I come back
I will add your example to the test suite.

jt

diff -C 3 discrete-gsl1.3.c discrete.c
*** discrete-gsl1.3.c   Sun Jan 26 14:42:31 2003
--- discrete.c  Sun Jan 26 14:45:55 2003
***************
*** 277,286 ****
      while (size_stack(Smalls) > 0) {
          s = pop_stack(Smalls);
          if (size_stack(Bigs) == 0) {
-             /* Then we are on our last value */
              (g->A)[s]=s;
              (g->F)[s]=1.0;
!             break;
          }
          b = pop_stack(Bigs);
          (g->A)[s]=b;
--- 277,285 ----
      while (size_stack(Smalls) > 0) {
          s = pop_stack(Smalls);
          if (size_stack(Bigs) == 0) {
              (g->A)[s]=s;
              (g->F)[s]=1.0;
!             continue;
          }
          b = pop_stack(Bigs);
          (g->A)[s]=b;
***************
*** 310,315 ****
--- 309,318 ----
      }
      /* Stacks have been emptied, and A and F have been filled */

+     if ( size_stack(Smalls) != 0) {
+       GSL_ERROR_VAL ("Smalls stack has not been emptied",
+                      GSL_ESANITY, 0 );
+     }

  #if 0
      /* if 1, then artificially set all F[k]'s to unity.  This will




---------------------------------------------
James Theiler                     jt@lanl.gov
MS-D436, NIS-2, LANL        tel: 505/665-5682
Los Alamos, NM 87545        fax: 505/665-4414
----- Space and Remote Sensing Sciences -----



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