[Jython-checkins] jython: erf bugfix.
frank.wierzbicki
jython-checkins at python.org
Thu Apr 19 06:32:54 CEST 2012
http://hg.python.org/jython/rev/915cdf96c757
changeset: 6610:915cdf96c757
user: Miki Tebeka <miki.tebeka at gmail.com>
date: Wed Apr 18 21:31:57 2012 -0700
summary:
erf bugfix.
files:
src/org/python/modules/math_erf.java | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/org/python/modules/math_erf.java b/src/org/python/modules/math_erf.java
--- a/src/org/python/modules/math_erf.java
+++ b/src/org/python/modules/math_erf.java
@@ -132,6 +132,7 @@
}
return erx + P/Q;
}
+
if (x >= 6) { // inf > |x| >= 6
if (sign) {
return -1;
@@ -148,8 +149,10 @@
R = rb0 + s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(rb5+s*rb6)))));
S = 1 + s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(sb5+s*(sb6+s*sb7))))));
}
+
// pseudo-single (20-bit) precision x
- double z = (double)(Double.doubleToLongBits(x) & 0xffffffff00000000L);
+ long t20 = Double.doubleToLongBits(x) & 0xffffffff00000000L;
+ double z = Double.longBitsToDouble(t20);
double r = Math.exp(-z*z-0.5625) * Math.exp((z-x)*(z+x)+R/S);
if (sign) {
return r/x - 1;
@@ -219,7 +222,8 @@
S = 1 + s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(sb5+s*(sb6+s*sb7))))));
}
// pseudo-single (20-bit) precision x
- double z = (double)(Double.doubleToLongBits(x) & 0xffffffff00000000L);
+ long t20 = Double.doubleToLongBits(x) & 0xffffffff00000000L;
+ double z = Double.longBitsToDouble(t20);
double r = Math.exp(-z*z-0.5625) * Math.exp((z-x)*(z+x)+R/S);
if (sign) {
return 2 - r/x;
--
Repository URL: http://hg.python.org/jython
More information about the Jython-checkins
mailing list