Permalink
Browse files

Fix floating point issue in logs

  • Loading branch information...
1 parent 4f71f9e commit d97d8a6224445c324dddfd24552f90fb972780b8 @awblocker committed Dec 3, 2011
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/lib.cpp
View
@@ -359,11 +359,11 @@ int gaussHermiteDataDirect( int n, double* x, double* w ) {
// Calculate weights w
int i;
- double log2 = log(2), logsqrtpi = 0.5*log(PI);
+ double log2 = log(2.0), logsqrtpi = 0.5*log(PI);
for (i=0; i<n; i++) {
// First, compute the log-weight
w[i] = (n-1)*log2 + lgamma(n+1) + logsqrtpi -
- 2*log(n) - 2*log(abs(hermitePoly(x[i], n-1)));
+ 2*log(n+0.0) - 2*log(abs(hermitePoly(x[i], n-1)));
w[i] = exp(w[i]);
}

0 comments on commit d97d8a6

Please sign in to comment.