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]

Patch for histogram/stat2d.c


Hi Brian and all the others!

I saw that you have annonuced gsl-1.1 on the homepage.
While installing it at my workplace, I found an error, that did not occure
before (I don't know why :-( ). It depends on a division by zero that
results in NaN. Please regard in this patch.

Index: stat2d.c
===================================================================
RCS file: /cvs/gsl/gsl/histogram/stat2d.c,v
retrieving revision 1.2
diff -r1.2 stat2d.c
87,88c87,90
<       W += wi;
<       wmean += (xi - wmean) * (wi / W);
---
>       if (wi>0) {
>       W += wi;
>       wmean += (xi - wmean) * (wi / W);
>       }
125,127c127,130
<       W += wj;
<       wmean += (yj - wmean) * (wj / W);
< 
---
>       if (wj>0) {
>       W += wj;
>       wmean += (yj - wmean) * (wj / W);
>       }
164,165c167,170
<       W += wi;
<       wvariance += ((xi * xi) - wvariance) * (wi / W);
---
>       if (wi>0) {
>       W += wi;
>       wvariance += ((xi * xi) - wvariance) * (wi / W);
>       }
204,206c209,212
< 
<       W += wj;
<       wvariance += ((yj * yj) - wvariance) * (wj / W);
---
>       if (wj>0) {
>       W += wj;
>       wvariance += ((yj * yj) - wvariance) * (wj / W);
>       }


Achim Gaedke, ZPR
Weyertal 80, 50931 Köln
Tel: +49 221 470 6021


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