diff options
| author | Paolo Bosetti <[email protected]> | 2012-05-15 23:48:49 -0700 |
|---|---|---|
| committer | Paolo Bosetti <[email protected]> | 2012-05-15 23:48:49 -0700 |
| commit | 4bc4807297a1bf7099deb3c92a63f747eaf46492 (patch) | |
| tree | 567d4b821b81243a67121dd0021559b17a0edf82 | |
| parent | 6971b0e9ab025ddf0e5cfa16ab79ef0acc14acad (diff) | |
| parent | 36aaaafae4437dda5664c99b3497976fecb642fa (diff) | |
| download | mruby-4bc4807297a1bf7099deb3c92a63f747eaf46492.tar.gz mruby-4bc4807297a1bf7099deb3c92a63f747eaf46492.zip | |
Merge pull request #1 from nkshigeru/mathmsvc
Math MSVC
| -rw-r--r-- | src/math.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/math.c b/src/math.c index c6f412055..a4451ea9d 100644 --- a/src/math.c +++ b/src/math.c @@ -17,6 +17,10 @@ #define atanh(x) (log(1+x) - log(1-x))/2.0 #define cbrt(x) pow(x,1.0/3.0) +/* Declaration of complementary Error function */ +double +erfc(double x); + /* ** Implementations of error functions ** credits to http://www.digitalmars.com/archives/cplusplus/3634.html @@ -27,11 +31,11 @@ double erf(double x) { static const double two_sqrtpi= 1.128379167095512574; + double sum= x, term= x, xsqr= x*x; + int j= 1; if (fabs(x) > 2.2) { return 1.0 - erfc(x); } - double sum= x, term= x, xsqr= x*x; - int j= 1; do { term*= xsqr/j; sum-= term/(2*j+1); @@ -48,16 +52,16 @@ double erfc(double x) { static const double one_sqrtpi= 0.564189583547756287; + double a=1, b=x; + double c=x, d=x*x+0.5; + double q1,q2; + double n= 1.0, t; if (fabs(x) < 2.2) { return 1.0 - erf(x); } - if (signbit(x)) { + if (x < 0.0) { /*signbit(x)*/ return 2.0 - erfc(-x); } - double a=1, b=x; - double c=x, d=x*x+0.5; - double q1,q2; - double n= 1.0, t; do { t= a*n+b*x; a= b; |
