From 44f240f433e4a58d7004e7091b8b3e538d56a9c3 Mon Sep 17 00:00:00 2001 From: skandhas Date: Mon, 19 Nov 2012 17:45:29 +0800 Subject: fix lost const variable in class BasicObject --- src/class.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/class.c b/src/class.c index d95a05789..fe2baa4f2 100644 --- a/src/class.c +++ b/src/class.c @@ -1400,6 +1400,7 @@ mrb_init_class(mrb_state *mrb) make_metaclass(mrb, cls); /* name basic classes */ + mrb_define_const(mrb, bob, "BasicObject", mrb_obj_value(bob)); mrb_define_const(mrb, obj, "BasicObject", mrb_obj_value(bob)); mrb_define_const(mrb, obj, "Object", mrb_obj_value(obj)); mrb_define_const(mrb, obj, "Module", mrb_obj_value(mod)); -- cgit v1.2.3 From f7dd27a92827af91aa52c78bfbf96d5f7e73c4bd Mon Sep 17 00:00:00 2001 From: Xuejie Xiao Date: Mon, 19 Nov 2012 15:13:18 -0500 Subject: Fix provided implementation of erf and erfc functions. --- src/math.c | 5 +++-- test/t/math.rb | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/math.c b/src/math.c index 9aae87acd..3e4550946 100644 --- a/src/math.c +++ b/src/math.c @@ -51,7 +51,7 @@ erf(double x) term *= xsqr/j; sum += term/(2*j+1); ++j; - } while (fabs(term)/sum > MATH_TOLERANCE); + } while (fabs(term/sum) > MATH_TOLERANCE); return two_sqrtpi*sum; } @@ -64,7 +64,8 @@ erfc(double x) double b = x; double c = x; double d = x*x+0.5; - double q1, q2; + double q1; + double q2 = b/d; double n = 1.0; double t; if (fabs(x) < 2.2) { diff --git a/test/t/math.rb b/test/t/math.rb index d71e44fc9..e582c0166 100644 --- a/test/t/math.rb +++ b/test/t/math.rb @@ -110,8 +110,12 @@ if Object.const_defined?(:Math) check_float(Math.erf(1), 0.842700792949715) end - assert('Math.erfc 1') do - check_float(Math.erfc(1), 0.157299207050285) + assert('Math.erf -1') do + check_float(Math.erf(-1), -0.8427007929497148) + end + + assert('Math.erfc -1') do + check_float(Math.erfc(-1), 1.8427007929497148) end end -- cgit v1.2.3 From 358f0cb5d8cb822644e29bad520b44d63c0d5666 Mon Sep 17 00:00:00 2001 From: Xuejie Xiao Date: Mon, 19 Nov 2012 15:19:52 -0500 Subject: Restore accidentally deleted erfc(1) test --- test/t/math.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/t/math.rb b/test/t/math.rb index e582c0166..780b805d2 100644 --- a/test/t/math.rb +++ b/test/t/math.rb @@ -110,6 +110,10 @@ if Object.const_defined?(:Math) check_float(Math.erf(1), 0.842700792949715) end + assert('Math.erfc 1') do + check_float(Math.erfc(1), 0.157299207050285) + end + assert('Math.erf -1') do check_float(Math.erf(-1), -0.8427007929497148) end -- cgit v1.2.3