From 745a2aac690ef026ffd8a3c1ca82ddc61d6babe6 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 12 Jul 2016 14:13:46 +0000 Subject: math.c: Complex sqrt * math.c (rb_math_sqrt): [EXPERIMENTAL] move Complex sqrt support from mathn.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/mathn.rb | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'lib/mathn.rb') diff --git a/lib/mathn.rb b/lib/mathn.rb index d6f2da0210..9cb9401e37 100644 --- a/lib/mathn.rb +++ b/lib/mathn.rb @@ -103,14 +103,7 @@ module Math def sqrt(a) if a.kind_of?(Complex) - abs = sqrt(a.real*a.real + a.imag*a.imag) - x = sqrt((a.real + abs)/Rational(2)) - y = sqrt((-a.real + abs)/Rational(2)) - if a.imag >= 0 - Complex(x, y) - else - Complex(x, -y) - end + sqrt!(a) elsif a.respond_to?(:nan?) and a.nan? a elsif a >= 0 -- cgit v1.2.3