ruby-changes:8473
From: tadf <ko1@a...>
Date: Wed, 29 Oct 2008 00:11:23 +0900 (JST)
Subject: [ruby-changes:8473] Ruby:r20005 (trunk): * math.c (rb_math_{atan2,cos,cosh,hypot,log,sin,sinh,sqrt}): added.
tadf 2008-10-29 00:10:40 +0900 (Wed, 29 Oct 2008) New Revision: 20005 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20005 Log: * math.c (rb_math_{atan2,cos,cosh,hypot,log,sin,sinh,sqrt}): added. * complex.c: follows the above change. Modified files: trunk/ChangeLog trunk/complex.c trunk/math.c Index: complex.c =================================================================== --- complex.c (revision 20004) +++ complex.c (revision 20005) @@ -426,31 +426,31 @@ return rb_funcall2(rb_cComplex, id_convert, argc, argv); } -extern VALUE math_atan2(VALUE obj, VALUE x, VALUE y); -extern VALUE math_cos(VALUE obj, VALUE x); -extern VALUE math_cosh(VALUE obj, VALUE x); -extern VALUE math_exp(VALUE obj, VALUE x); -extern VALUE math_hypot(VALUE obj, VALUE x, VALUE y); -extern VALUE math_log(int argc, VALUE *argv); -extern VALUE math_sin(VALUE obj, VALUE x); -extern VALUE math_sinh(VALUE obj, VALUE x); -extern VALUE math_sqrt(VALUE obj, VALUE x); +extern VALUE rb_math_atan2(VALUE x, VALUE y); +extern VALUE rb_math_cos(VALUE x); +extern VALUE rb_math_cosh(VALUE x); +extern VALUE rb_math_exp(VALUE x); +extern VALUE rb_math_hypot(VALUE x, VALUE y); +extern VALUE rb_math_log(int argc, VALUE *argv); +extern VALUE rb_math_sin(VALUE x); +extern VALUE rb_math_sinh(VALUE x); +extern VALUE rb_math_sqrt(VALUE x); -#define m_atan2_bang(x,y) math_atan2(Qnil,x,y) -#define m_cos_bang(x) math_cos(Qnil,x) -#define m_cosh_bang(x) math_cosh(Qnil,x) -#define m_exp_bang(x) math_exp(Qnil,x) -#define m_hypot(x,y) math_hypot(Qnil,x,y) +#define m_atan2_bang(x,y) rb_math_atan2(x,y) +#define m_cos_bang(x) rb_math_cos(x) +#define m_cosh_bang(x) rb_math_cosh(x) +#define m_exp_bang(x) rb_math_exp(x) +#define m_hypot(x,y) rb_math_hypot(x,y) static VALUE m_log_bang(VALUE x) { - return math_log(1, &x); + return rb_math_log(1, &x); } -#define m_sin_bang(x) math_sin(Qnil,x) -#define m_sinh_bang(x) math_sinh(Qnil,x) -#define m_sqrt_bang(x) math_sqrt(Qnil,x) +#define m_sin_bang(x) rb_math_sin(x) +#define m_sinh_bang(x) rb_math_sinh(x) +#define m_sqrt_bang(x) rb_math_sqrt(x) static VALUE m_cos(VALUE x) Index: math.c =================================================================== --- math.c (revision 20004) +++ math.c (revision 20005) @@ -81,7 +81,7 @@ * */ -VALUE +static VALUE math_atan2(VALUE obj, VALUE y, VALUE x) { Need_Float2(y, x); @@ -97,7 +97,7 @@ * -1..1. */ -VALUE +static VALUE math_cos(VALUE obj, VALUE x) { Need_Float(x); @@ -112,7 +112,7 @@ * -1..1. */ -VALUE +static VALUE math_sin(VALUE obj, VALUE x) { Need_Float(x); @@ -203,7 +203,7 @@ * Computes the hyperbolic cosine of <i>x</i> (expressed in radians). */ -VALUE +static VALUE math_cosh(VALUE obj, VALUE x) { Need_Float(x); @@ -227,7 +227,7 @@ * radians). */ -VALUE +static VALUE math_sinh(VALUE obj, VALUE x) { Need_Float(x); @@ -317,7 +317,7 @@ * Returns e**x. */ -VALUE +static VALUE math_exp(VALUE obj, VALUE x) { Need_Float(x); @@ -343,7 +343,7 @@ * of logarithm. */ -VALUE +static VALUE math_log(int argc, VALUE *argv) { VALUE x, base; @@ -438,7 +438,7 @@ * */ -VALUE +static VALUE math_sqrt(VALUE obj, VALUE x) { double d; @@ -540,7 +540,7 @@ * Math.hypot(3, 4) #=> 5.0 */ -VALUE +static VALUE math_hypot(VALUE obj, VALUE x, VALUE y) { Need_Float2(x, y); @@ -653,6 +653,37 @@ return rb_assoc_new(v, INT2FIX(sign)); } + +#define exp1(n) \ +VALUE \ +rb_math_##n(VALUE x)\ +{\ + return math_##n(rb_mMath, x);\ +} + +#define exp2(n) \ +VALUE \ +rb_math_##n(VALUE x, VALUE y)\ +{\ + return math_##n(rb_mMath, x, y);\ +} + +exp2(atan2) +exp1(cos) +exp1(cosh) +exp1(exp) +exp2(hypot) + +VALUE rb_math_log(int argc, VALUE *argv) +{ + return math_log(argc, argv); +} + +exp1(sin) +exp1(sinh) +exp1(sqrt) + + /* * The <code>Math</code> module contains module functions for basic * trigonometric and transcendental functions. See class Index: ChangeLog =================================================================== --- ChangeLog (revision 20004) +++ ChangeLog (revision 20005) @@ -1,3 +1,9 @@ +Wed Oct 29 00:08:05 2008 Tadayoshi Funaba <tadf@d...> + + * math.c (rb_math_{atan2,cos,cosh,hypot,log,sin,sinh,sqrt}): added. + + * complex.c: follows the above change. + Tue Oct 28 23:29:06 2008 NARUSE, Yui <naruse@r...> * ext/nkf/nkf-utf8/nkf.c (kanji_convert): output unicode chars. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/