ruby-changes:40388
From: gogotanaka <ko1@a...>
Date: Sat, 7 Nov 2015 00:11:56 +0900 (JST)
Subject: [ruby-changes:40388] gogotanaka:r52469 (trunk): * lib/cmath.rb: methods which has suffix '!' are now deprecated.
gogotanaka 2015-11-07 00:11:39 +0900 (Sat, 07 Nov 2015) New Revision: 52469 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52469 Log: * lib/cmath.rb: methods which has suffix '!' are now deprecated. Modified files: trunk/ChangeLog trunk/NEWS trunk/lib/cmath.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 52468) +++ ChangeLog (revision 52469) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Nov 7 00:03:50 2015 Kazuki Tanaka <gogotanaka@r...> + + * lib/cmath.rb: methods which has suffix '!' are now deprecated. + [ruby-core:68528] [Feature #10974] + Fri Nov 6 23:13:53 2015 Kazuki Tanaka <gogotanaka@r...> * array.c: clarifies Array#reject! documentation. Index: lib/cmath.rb =================================================================== --- lib/cmath.rb (revision 52468) +++ lib/cmath.rb (revision 52469) @@ -23,29 +23,32 @@ module CMath https://github.com/ruby/ruby/blob/trunk/lib/cmath.rb#L23 include Math - alias exp! exp - alias log! log - alias log2! log2 - alias log10! log10 - alias sqrt! sqrt - alias cbrt! cbrt - - alias sin! sin - alias cos! cos - alias tan! tan - - alias sinh! sinh - alias cosh! cosh - alias tanh! tanh - - alias asin! asin - alias acos! acos - alias atan! atan - alias atan2! atan2 - - alias asinh! asinh - alias acosh! acosh - alias atanh! atanh + %w[ + exp + log + log2 + log10 + sqrt + cbrt + sin + cos + tan + sinh + cosh + tanh + asin + acos + atan + atan2 + asinh + acosh + atanh + ].each do |meth| + define_method(meth + '!') do |*args, &block| + warn("CMath##{meth}! is deprecated; use CMath##{meth} or Math##{meth}") if $VERBOSE + Math.send(meth, *args, &block) + end + end ## # Math::E raised to the +z+ power @@ -54,11 +57,11 @@ module CMath https://github.com/ruby/ruby/blob/trunk/lib/cmath.rb#L57 def exp(z) begin if z.real? - exp!(z) + Math.exp(z) else - ere = exp!(z.real) - Complex(ere * cos!(z.imag), - ere * sin!(z.imag)) + ere = Math.exp(z.real) + Complex(ere * Math.cos(z.imag), + ere * Math.sin(z.imag)) end rescue NoMethodError handle_no_method_error @@ -74,9 +77,9 @@ module CMath https://github.com/ruby/ruby/blob/trunk/lib/cmath.rb#L77 def log(z, b=::Math::E) begin if z.real? && z >= 0 && b >= 0 - log!(z, b) + Math.log(z, b) else - Complex(log!(z.abs), z.arg) / log(b) + Complex(Math.log(z.abs), z.arg) / log(b) end rescue NoMethodError handle_no_method_error @@ -90,9 +93,9 @@ module CMath https://github.com/ruby/ruby/blob/trunk/lib/cmath.rb#L93 def log2(z) begin if z.real? and z >= 0 - log2!(z) + Math.log2(z) else - log(z) / log!(2) + log(z) / Math.log(2) end rescue NoMethodError handle_no_method_error @@ -106,9 +109,9 @@ module CMath https://github.com/ruby/ruby/blob/trunk/lib/cmath.rb#L109 def log10(z) begin if z.real? and z >= 0 - log10!(z) + Math.log10(z) else - log(z) / log!(10) + log(z) / Math.log(10) end rescue NoMethodError handle_no_method_error @@ -123,9 +126,9 @@ module CMath https://github.com/ruby/ruby/blob/trunk/lib/cmath.rb#L126 begin if z.real? if z < 0 - Complex(0, sqrt!(-z)) + Complex(0, Math.sqrt(-z)) else - sqrt!(z) + Math.sqrt(z) end else if z.imag < 0 || @@ -134,7 +137,7 @@ module CMath https://github.com/ruby/ruby/blob/trunk/lib/cmath.rb#L137 else r = z.abs x = z.real - Complex(sqrt!((r + x) / 2.0), sqrt!((r - x) / 2.0)) + Complex(Math.sqrt((r + x) / 2.0), Math.sqrt((r - x) / 2.0)) end end rescue NoMethodError @@ -157,10 +160,10 @@ module CMath https://github.com/ruby/ruby/blob/trunk/lib/cmath.rb#L160 def sin(z) begin if z.real? - sin!(z) + Math.sin(z) else - Complex(sin!(z.real) * cosh!(z.imag), - cos!(z.real) * sinh!(z.imag)) + Complex(Math.sin(z.real) * Math.cosh(z.imag), + Math.cos(z.real) * Math.sinh(z.imag)) end rescue NoMethodError handle_no_method_error @@ -174,10 +177,10 @@ module CMath https://github.com/ruby/ruby/blob/trunk/lib/cmath.rb#L177 def cos(z) begin if z.real? - cos!(z) + Math.cos(z) else - Complex(cos!(z.real) * cosh!(z.imag), - -sin!(z.real) * sinh!(z.imag)) + Complex(Math.cos(z.real) * Math.cosh(z.imag), + -Math.sin(z.real) * Math.sinh(z.imag)) end rescue NoMethodError handle_no_method_error @@ -191,7 +194,7 @@ module CMath https://github.com/ruby/ruby/blob/trunk/lib/cmath.rb#L194 def tan(z) begin if z.real? - tan!(z) + Math.tan(z) else sin(z) / cos(z) end @@ -207,10 +210,10 @@ module CMath https://github.com/ruby/ruby/blob/trunk/lib/cmath.rb#L210 def sinh(z) begin if z.real? - sinh!(z) + Math.sinh(z) else - Complex(sinh!(z.real) * cos!(z.imag), - cosh!(z.real) * sin!(z.imag)) + Complex(Math.sinh(z.real) * Math.cos(z.imag), + Math.cosh(z.real) * Math.sin(z.imag)) end rescue NoMethodError handle_no_method_error @@ -224,10 +227,10 @@ module CMath https://github.com/ruby/ruby/blob/trunk/lib/cmath.rb#L227 def cosh(z) begin if z.real? - cosh!(z) + Math.cosh(z) else - Complex(cosh!(z.real) * cos!(z.imag), - sinh!(z.real) * sin!(z.imag)) + Complex(Math.cosh(z.real) * Math.cos(z.imag), + Math.sinh(z.real) * Math.sin(z.imag)) end rescue NoMethodError handle_no_method_error @@ -241,7 +244,7 @@ module CMath https://github.com/ruby/ruby/blob/trunk/lib/cmath.rb#L244 def tanh(z) begin if z.real? - tanh!(z) + Math.tanh(z) else sinh(z) / cosh(z) end @@ -257,7 +260,7 @@ module CMath https://github.com/ruby/ruby/blob/trunk/lib/cmath.rb#L260 def asin(z) begin if z.real? and z >= -1 and z <= 1 - asin!(z) + Math.asin(z) else (-1.0).i * log(1.0.i * z + sqrt(1.0 - z * z)) end @@ -273,7 +276,7 @@ module CMath https://github.com/ruby/ruby/blob/trunk/lib/cmath.rb#L276 def acos(z) begin if z.real? and z >= -1 and z <= 1 - acos!(z) + Math.acos(z) else (-1.0).i * log(z + 1.0.i * sqrt(1.0 - z * z)) end @@ -289,7 +292,7 @@ module CMath https://github.com/ruby/ruby/blob/trunk/lib/cmath.rb#L292 def atan(z) begin if z.real? - atan!(z) + Math.atan(z) else 1.0.i * log((1.0.i + z) / (1.0.i - z)) / 2.0 end @@ -306,7 +309,7 @@ module CMath https://github.com/ruby/ruby/blob/trunk/lib/cmath.rb#L309 def atan2(y,x) begin if y.real? and x.real? - atan2!(y,x) + Math.atan2(y,x) else (-1.0).i * log((x + 1.0.i * y) / sqrt(x * x + y * y)) end @@ -322,7 +325,7 @@ module CMath https://github.com/ruby/ruby/blob/trunk/lib/cmath.rb#L325 def asinh(z) begin if z.real? - asinh!(z) + Math.asinh(z) else log(z + sqrt(1.0 + z * z)) end @@ -338,7 +341,7 @@ module CMath https://github.com/ruby/ruby/blob/trunk/lib/cmath.rb#L341 def acosh(z) begin if z.real? and z >= 1 - acosh!(z) + Math.acosh(z) else log(z + sqrt(z * z - 1.0)) end @@ -354,7 +357,7 @@ module CMath https://github.com/ruby/ruby/blob/trunk/lib/cmath.rb#L357 def atanh(z) begin if z.real? and z >= -1 and z <= 1 - atanh!(z) + Math.atanh(z) else log((1.0 + z) / (1.0 - z)) / 2.0 end Index: NEWS =================================================================== --- NEWS (revision 52468) +++ NEWS (revision 52469) @@ -181,6 +181,9 @@ with all sufficient information, see the https://github.com/ruby/ruby/blob/trunk/NEWS#L181 * lib/matrix.rb * Add Vector#round. https://github.com/ruby/ruby/pull/802 +* lib/cmath.rb + * methods which has suffix '!' are now deprecated. + * ext/coverage/coverage.c * Coverage.peek_result: new method to allow coverage to be captured without stopping the coverage tool. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/