summaryrefslogtreecommitdiff
path: root/math.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-03-13 05:45:13 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-03-13 05:45:13 +0000
commite502549be1bea41406ccef0e819b0e9cb8cdb069 (patch)
tree78a2fe9e8986665213222c60304e5682e0431303 /math.c
parent8fc5876485fb84bf9c93b569ff0cb57cf2b21f7d (diff)
downloadruby-e502549be1bea41406ccef0e819b0e9cb8cdb069.tar.gz
* io.c (argf_seek_m): wrong calling sequence of rb_io_seek().
* parse.y (cond0): no special treatment of string literal in condition. * math.c: add acos, asin, atan, conh, sinh, tanh and hypot to Math. * configure.in: check hypot availablility. * missing/hypot.c: public domain rewrite of hypot. * parse.y (warn_unless_e_option): warning condition was wrong. * parse.y (warning_unless_e_option): ditto. * enum.c (enum_all): new method 'all?', which returns true if block returns true for all elements. * enum.c (enum_any): new method 'any?', which returns true if block retruns true for any of elements. * marshal.c (marshal_load): do not give warning unless explicitly set to verbose. * eval.c (rb_exit): give string value "exit" to SystemExit. * ruby.c (proc_options): -v should not print version if proc_options called via moreswitches(). * parse.y (stmt): while/until modifier must work for empty body. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1241 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'math.c')
-rw-r--r--math.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/math.c b/math.c
index b2d61f609c..4af3cef96e 100644
--- a/math.c
+++ b/math.c
@@ -57,6 +57,62 @@ math_tan(obj, x)
}
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 @@ math_ldexp(obj, x, n)
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 @@ Init_Math()
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 @@ Init_Math()
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);
}