[#12387] reducing logical operation — "Nobuyoshi.Nakada" <nobu.nakada@...>

なかだです。

17 messages 2001/03/07
[#12388] Re: reducing logical operation — EGUCHI Osamu <eguchi@...> 2001/03/07

えぐち@エスアンドイー です。

[#12389] Re: reducing logical operation — nobu.nakada@... 2001/03/07

なかだです。

[#12391] Re: reducing logical operation — EGUCHI Osamu <eguchi@...> 2001/03/07

えぐち@エスアンドイー です。

[#12404] fork in threads — keiju@... (Keiju ISHITSUKA)

けいじゅ@日本ラショナルソフトウェアです.

14 messages 2001/03/09

[#12405] at_exit — keiju@... (Keiju ISHITSUKA)

けいじゅ@日本ラショナルソフトウェアです.

15 messages 2001/03/09
[#12409] Re: at_exit — matz@... (Yukihiro Matsumoto) 2001/03/10

まつもと ゆきひろです

[#12411] Re: at_exit — keiju@... (石塚圭樹) 2001/03/10

けいじゅ@日本ラショナルソフトウェアです.

[#12425] bignum % の結果が負数になることがある — Hisayasu Nakao <h-nakao@...>

最近、ruby-1.6.2を使い出したばかりの中尾です。

39 messages 2001/03/12
[#12427] Re: bignum % の結果が負数になることがある — WATANABE Hirofumi <eban@...> 2001/03/12

わたなべです。

[#12463] Re: bignum % の結果が負数になることがある — Takahiro Kambe <taca@...> 2001/03/13

In message <4518-Mon12Mar2001145434+0900-eban@os.rim.or.jp>

[#12464] Re: bignum % の結果が負数になることがある — matz@... (Yukihiro Matsumoto) 2001/03/13

まつもと ゆきひろです

[#12466] Re: bignum % の結果が負数になることがある — Takahiro Kambe <taca@...> 2001/03/13

In message <984469222.234203.1007.nullmailer@ev.netlab.zetabits.com>

[#12475] Re: bignum % の結果が負数になることがある — matz@... (Yukihiro Matsumoto) 2001/03/14

まつもと ゆきひろです

[#12476] Re: bignum % の結果が負数になることがある — Takahiro Kambe <taca@...> 2001/03/14

In message <984550885.417146.3670.nullmailer@ev.netlab.zetabits.com>

[#12480] Re: bignum % の結果が負数になることがある — matz@... (Yukihiro Matsumoto) 2001/03/14

まつもと ゆきひろです

[#12481] Re: bignum % の結果が負数になることがある — Takahiro Kambe <taca@...> 2001/03/14

In message <984553493.009507.3747.nullmailer@ev.netlab.zetabits.com>

[#12488] Re: bignum % の結果が負数になることがある — matz@... (Yukihiro Matsumoto) 2001/03/14

まつもと ゆきひろです

[#12493] Re: bignum % の結果が負数になることがある — Takahiro Kambe <taca@...> 2001/03/14

In message <984579430.080967.5569.nullmailer@ev.netlab.zetabits.com>

[#12578] require 'win32api' — Kazuhiro NISHIYAMA <zn@...>

require 'win32api'のエラーメッセージがわかりにくいと

21 messages 2001/03/20
[#12579] Re: require 'win32api' — nobu.nakada@... 2001/03/20

なかだです。

[#12598] Re: require 'win32api' — nobu.nakada@... 2001/03/21

なかだです。

[#12582] finalizer problem — keiju@... (Keiju ISHITSUKA)

けいじゅ@日本ラショナルソフトウェアです.

20 messages 2001/03/20
[#12583] Re: finalizer problem — matz@... (Yukihiro Matsumoto) 2001/03/20

まつもと ゆきひろです

[#12585] Re: finalizer problem — keiju@... (石塚圭樹) 2001/03/20

けいじゅ@日本ラショナルソフトウェアです.

[#12591] Re: finalizer problem — matz@... (Yukihiro Matsumoto) 2001/03/20

まつもと ゆきひろです

[#12619] Re: finalizer problem — keiju@... (石塚圭樹) 2001/03/22

けいじゅ@日本ラショナルソフトウェアです.

[#12605] extern inline (ruby.h) ruby-1.6.3 — WATANABE Tetsuya <tetsu@...>

渡辺哲也です。

17 messages 2001/03/22
[#12606] Re: extern inline (ruby.h) ruby-1.6.3 — matz@... (Yukihiro Matsumoto) 2001/03/22

まつもと ゆきひろです

[#12607] Re: extern inline (ruby.h) ruby-1.6.3 — WATANABE Tetsuya <tetsu@...> 2001/03/22

渡辺哲也です。

[#12608] Re: extern inline (ruby.h) ruby-1.6.3 — matz@... (Yukihiro Matsumoto) 2001/03/22

まつもと ゆきひろです

[#12674] Was: [rubyist:0454] Re: to_str — Kenichi Komiya <kom@...1.accsnet.ne.jp>

21 messages 2001/03/25
[#12675] Re: Was: [rubyist:0454] Re: to_str — matz@... (Yukihiro Matsumoto) 2001/03/26

まつもと ゆきひろです

[#12678] Re: Was: [rubyist:0454] Re: to_str — Kenichi Komiya <kom@...1.accsnet.ne.jp> 2001/03/26

[#12681] Re: Was: [rubyist:0454] Re: to_str — matz@... (Yukihiro Matsumoto) 2001/03/26

まつもと ゆきひろです

[#12687] Re: Was: [rubyist:0454] Re: to_str — Kenichi Komiya <kom@...1.accsnet.ne.jp> 2001/03/27

[#12688] Re: Was: [rubyist:0454] Re: to_str — matz@... (Yukihiro Matsumoto) 2001/03/28

まつもと ゆきひろです

[#12710] Re: Was: [rubyist:0454] Re: to_str — Kenichi Komiya <kom@...1.accsnet.ne.jp> 2001/03/31

[ruby-dev:12423] Re: [ruby-talk:12373] Re: Math package

From: Masahiro Tanaka <masa@...>
Date: 2001-03-11 23:37:40 UTC
List: ruby-dev #12423
>From: matz@zetabits.com (Yukihiro Matsumoto)
>Subject: [ruby-talk:12373] Re: Math package

> |BTW, I like more functions in Math module, such as
> |asin(), hypot(), etc, in the core distribution, 
> 
> I have no knowledge about availabily of those function.  If someone
> would supply survey and patch, they will be merged into the core.

ていうことなので、パッチ書きました。availabilyは私も把握してませ
んが、math.h に書いてある分類を参考にしました。

ANSI/POSIX に分類されている(sqrtとかも含む)のは標準的と思って、
次の関数を単純に加えました。
  acos, asin, atan, cosh, sinh, tanh
acos,asinの定義域のチェックは、コメントアウトしています。

hypot はない可能性がありそうですが、あると便利なので、
[ruby-talk:12404] を関数にしたものを missing に加えました。

以下パッチです。

田中昌宏

diff -Nru ../ruby/configure.in ./configure.in
--- ../ruby/configure.in	Sat Mar 10 19:15:15 2001
+++ ./configure.in	Sun Mar 11 18:13:34 2001
@@ -255,7 +255,7 @@
 AC_FUNC_MEMCMP
 AC_REPLACE_FUNCS(dup2 memmove mkdir strcasecmp strncasecmp strerror strftime\
 		 strchr strstr strtoul crypt flock vsnprintf\
-		 isinf isnan finite)
+		 isinf isnan finite hypot)
 AC_CHECK_FUNCS(fmod killpg drand48 random wait4 waitpid syscall getcwd chroot\
 	      truncate chsize times utimes fcntl lockf lstat symlink readlink\
 	      setitimer setruid seteuid setreuid setresuid \
diff -Nru ../ruby/math.c ./math.c
--- ../ruby/math.c	Sat Mar 10 19:15:15 2001
+++ ./math.c	Sun Mar 11 18:13:34 2001
@@ -57,6 +57,62 @@
 }
 
 static VALUE
+math_acos(obj, x)
+    VALUE obj, x;
+{
+    Need_Float(x);
+    /*
+    if (RFLOAT(x)->value < -1.0 || RFLOAT(x)->value > 1.0)
+	rb_raise(rb_eArgError, "Out of range (-1..1)");
+    */
+    return rb_float_new(acos(RFLOAT(x)->value));
+}
+
+static VALUE
+math_asin(obj, x)
+    VALUE obj, x;
+{
+    Need_Float(x);
+    /*
+    if (RFLOAT(x)->value < -1.0 || RFLOAT(x)->value > 1.0)
+	rb_raise(rb_eArgError, "Out of range (-1..1)");
+    */
+    return rb_float_new(asin(RFLOAT(x)->value));
+}
+
+static VALUE
+math_atan(obj, x)
+    VALUE obj, x;
+{
+    Need_Float(x);
+    return rb_float_new(atan(RFLOAT(x)->value));
+}
+
+static VALUE
+math_cosh(obj, x)
+    VALUE obj, x;
+{
+    Need_Float(x);
+    return rb_float_new(cosh(RFLOAT(x)->value));
+}
+
+static VALUE
+math_sinh(obj, x)
+    VALUE obj, x;
+{
+    Need_Float(x);
+    return rb_float_new(sinh(RFLOAT(x)->value));
+}
+
+static VALUE
+math_tanh(obj, x)
+    VALUE obj, x;
+{
+    Need_Float(x);
+    return rb_float_new(tanh(RFLOAT(x)->value));
+}
+
+static VALUE
 math_exp(obj, x)
     VALUE obj, x;
 {
@@ -118,6 +174,14 @@
     return rb_float_new(d = ldexp(RFLOAT(x)->value, NUM2INT(n)));
 }
 
+static VALUE
+math_hypot(obj, x, y)
+    VALUE obj, x, y;
+{
+    Need_Float2(x, y);
+    return rb_float_new(hypot(RFLOAT(x)->value, RFLOAT(y)->value));
+}
+
 void
 Init_Math()
 {
@@ -140,6 +204,14 @@
     rb_define_module_function(rb_mMath, "sin", math_sin, 1);
     rb_define_module_function(rb_mMath, "tan", math_tan, 1);
 
+    rb_define_module_function(rb_mMath, "acos", math_acos, 1);
+    rb_define_module_function(rb_mMath, "asin", math_asin, 1);
+    rb_define_module_function(rb_mMath, "atan", math_atan, 1);
+
+    rb_define_module_function(rb_mMath, "cosh", math_cosh, 1);
+    rb_define_module_function(rb_mMath, "sinh", math_sinh, 1);
+    rb_define_module_function(rb_mMath, "tanh", math_tanh, 1);
+
     rb_define_module_function(rb_mMath, "exp", math_exp, 1);
     rb_define_module_function(rb_mMath, "log", math_log, 1);
     rb_define_module_function(rb_mMath, "log10", math_log10, 1);
@@ -147,4 +219,6 @@
 
     rb_define_module_function(rb_mMath, "frexp", math_frexp, 1);
     rb_define_module_function(rb_mMath, "ldexp", math_ldexp, 2);
+
+    rb_define_module_function(rb_mMath, "hypot", math_hypot, 2);
 }
diff -Nru ../ruby/missing/hypot.c ./missing/hypot.c
--- ../ruby/missing/hypot.c	Wed Dec 31 19:00:00 1969
+++ ./missing/hypot.c	Sun Mar 11 18:13:34 2001
@@ -0,0 +1,16 @@
+/* public domain rewrite of hypot */
+
+#include <math.h>
+
+double hypot(x,y)
+    double x, y;
+{
+    if (x < 0) x = -x;
+    if (y < 0) y = -y;
+    if (x < y) {
+	double tmp = x;
+	x = y; y = tmp;
+    }
+    y /= x;
+    return x * sqrt(1.0+y*y);
+}

In This Thread

Prev Next