[前][次][番号順一覧][スレッド一覧]

ruby-changes:12215

From: tadf <ko1@a...>
Date: Tue, 30 Jun 2009 01:25:26 +0900 (JST)
Subject: [ruby-changes:12215] Ruby:r23900 (trunk): * lib/cmath.rb (log2, cbrt): added. [experimental]

tadf	2009-06-30 01:25:11 +0900 (Tue, 30 Jun 2009)

  New Revision: 23900

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23900

  Log:
    * lib/cmath.rb (log2, cbrt): added.  [experimental]

  Modified files:
    trunk/ChangeLog
    trunk/lib/cmath.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 23899)
+++ ChangeLog	(revision 23900)
@@ -1,3 +1,7 @@
+Tue Jun 30 01:24:10 2009  Tadayoshi Funaba  <tadf@d...>
+
+	* lib/cmath.rb (log2, cbrt): added.  [experimental]
+
 Tue Jun 30 01:19:53 2009  Tadayoshi Funaba  <tadf@d...>
 
 	* complex.c (nucomp_expt): do not use rb_fexpt.
Index: lib/cmath.rb
===================================================================
--- lib/cmath.rb	(revision 23899)
+++ lib/cmath.rb	(revision 23900)
@@ -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,14 @@
     end
   end
 
+  def cbrt(z)
+    if z.real? and z >= 0
+      cbrt!(z)
+    else
+      Complex(z) ** (1.0/3)
+    end
+  end
+
   def sin(z)
     if z.real?
       sin!(z)
@@ -186,10 +204,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 +243,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/

[前][次][番号順一覧][スレッド一覧]