ruby-changes:12213
From: tadf <ko1@a...>
Date: Tue, 30 Jun 2009 01:20:48 +0900 (JST)
Subject: [ruby-changes:12213] Ruby:r23898 (trunk): * complex.c (nucomp_expt): do not use rb_fexpt.
tadf 2009-06-30 01:20:32 +0900 (Tue, 30 Jun 2009) New Revision: 23898 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23898 Log: * complex.c (nucomp_expt): do not use rb_fexpt. Modified files: trunk/ChangeLog trunk/complex.c trunk/lib/cmath.rb Index: complex.c =================================================================== --- complex.c (revision 23897) +++ complex.c (revision 23898) @@ -825,14 +825,6 @@ other = dat->real; /* c14n */ } - { - get_dat1(self); - - if (k_exact_p(dat->imag) && f_zero_p(dat->imag) && f_real_p(other)) - return f_complex_new1(CLASS_OF(self), - rb_fexpt(dat->real, other)); /* c14n */ - } - if (k_complex_p(other)) { VALUE r, theta, nr, ntheta; @@ -883,7 +875,8 @@ r = f_abs(self); theta = f_arg(self); - return f_complex_polar(CLASS_OF(self), rb_fexpt(r, other), + + return f_complex_polar(CLASS_OF(self), f_expt(r, other), f_mul(theta, other)); } return rb_num_coerce_bin(self, other, id_expt); Index: ChangeLog =================================================================== --- ChangeLog (revision 23897) +++ ChangeLog (revision 23898) @@ -1,3 +1,7 @@ +Tue Jun 30 01:19:53 2009 Tadayoshi Funaba <tadf@d...> + + * complex.c (nucomp_expt): do not use rb_fexpt. + Mon Jun 29 22:50:10 2009 Yuki Sonoda (Yugui) <yugui@y...> * Doxyfile.in: removed. merged into template/Doxyfile.template Index: lib/cmath.rb =================================================================== --- lib/cmath.rb (revision 23897) +++ lib/cmath.rb (revision 23898) @@ -4,8 +4,10 @@ alias exp! exp alias log! log + alias log2! log2 alias log10! log10 alias sqrt! sqrt + alias cbrt! cbrt alias sin! sin alias cos! cos @@ -47,6 +49,14 @@ end end + def log2(z) + if z.real? and z >= 0 + log2!(z) + else + log(z) / log!(2) + end + end + def log10(z) if z.real? and z >= 0 log10!(z) @@ -74,6 +84,15 @@ end end + def cbrt(z) + if z.real? and z >= 0 + cbrt!(z) + else +# exp(log(z) * (1.0/3)) + Complex(z) ** (1.0/3) + end + end + def sin(z) if z.real? sin!(z) @@ -186,10 +205,14 @@ module_function :exp module_function :log! module_function :log + module_function :log2! + module_function :log2 module_function :log10! module_function :log10 module_function :sqrt! module_function :sqrt + module_function :cbrt! + module_function :cbrt module_function :sin! module_function :sin @@ -221,8 +244,6 @@ module_function :atanh! module_function :atanh - module_function :log2 - module_function :cbrt module_function :frexp module_function :ldexp module_function :hypot -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/