From 1d9a079b1c3b54da5935201c796c7cdb423ed4c8 Mon Sep 17 00:00:00 2001 From: tadf Date: Sun, 31 Aug 2008 11:51:04 +0000 Subject: * complex.c (numeric_abs2): new. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- complex.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'complex.c') diff --git a/complex.c b/complex.c index 39e8ad2f85..34255df9fd 100644 --- a/complex.c +++ b/complex.c @@ -1291,6 +1291,12 @@ numeric_image(VALUE self) return INT2FIX(0); } +static VALUE +numeric_abs2(VALUE self) +{ + return f_mul(self, self); +} + #define id_PI rb_intern("PI") static VALUE @@ -1473,6 +1479,7 @@ Init_Complex(void) rb_define_method(rb_cNumeric, "real", numeric_real, 0); rb_define_method(rb_cNumeric, "image", numeric_image, 0); rb_define_method(rb_cNumeric, "imag", numeric_image, 0); + rb_define_method(rb_cNumeric, "abs2", numeric_abs2, 0); rb_define_method(rb_cNumeric, "arg", numeric_arg, 0); rb_define_method(rb_cNumeric, "angle", numeric_arg, 0); rb_define_method(rb_cNumeric, "phase", numeric_arg, 0); -- cgit v1.2.3