summaryrefslogtreecommitdiff
path: root/lib/mathn.rb
diff options
context:
space:
mode:
authorser <ser@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-22 12:40:45 +0000
committerser <ser@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-22 12:40:45 +0000
commit8b53e39a2e6110cf13827c88673a3ef2667991cf (patch)
treeeb1fa37c2a675b75c295285b5c313ba05801c2b8 /lib/mathn.rb
parentf36a3f0ea57aa05a72cb58937c7a737455a98a38 (diff)
downloadruby-8b53e39a2e6110cf13827c88673a3ef2667991cf.tar.gz
Second merge from trunk.rexml_adds_tests
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/rexml_adds_tests@19455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/mathn.rb')
-rw-r--r--lib/mathn.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/mathn.rb b/lib/mathn.rb
index 2af2b83da3..e918608b0d 100644
--- a/lib/mathn.rb
+++ b/lib/mathn.rb
@@ -9,11 +9,15 @@
#
#
-require "complex.rb"
-require "rational.rb"
+require "cmath.rb"
require "matrix.rb"
require "prime.rb"
+unless defined?(Math.exp!)
+ Object.instance_eval{remove_const :Math}
+ Math = CMath
+end
+
class Fixnum
remove_method :/
alias / quo
@@ -33,7 +37,7 @@ class Rational
if other.kind_of?(Rational)
other2 = other
if self < 0
- return Complex.__send__(:new!, self, 0) ** other
+ return Complex(self, 0.0) ** other
elsif other == 0
return Rational(1,1)
elsif self == 0
@@ -95,7 +99,7 @@ module Math
remove_method(:sqrt)
def sqrt(a)
if a.kind_of?(Complex)
- abs = sqrt(a.real*a.real + a.image*a.image)
+ abs = sqrt(a.real*a.real + a.imag*a.imag)
# if not abs.kind_of?(Rational)
# return a**Rational(1,2)
# end
@@ -104,7 +108,7 @@ module Math
# if !(x.kind_of?(Rational) and y.kind_of?(Rational))
# return a**Rational(1,2)
# end
- if a.image >= 0
+ if a.imag >= 0
Complex(x, y)
else
Complex(x, -y)