ruby-changes:56466
From: Nobuyoshi <ko1@a...>
Date: Sun, 14 Jul 2019 16:57:02 +0900 (JST)
Subject: [ruby-changes:56466] Nobuyoshi Nakada: 10de5f149a (master): Calculate float complex division per each part
https://git.ruby-lang.org/ruby.git/commit/?id=10de5f149a From 10de5f149acc620e12be5943e4e29f4f555b7551 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sun, 14 Jul 2019 16:31:36 +0900 Subject: Calculate float complex division per each part Arguments to f_complex_new2 should not be Complex, or violate the assertion. diff --git a/complex.c b/complex.c index 42b32d4..313e564 100644 --- a/complex.c +++ b/complex.c @@ -817,25 +817,19 @@ f_divide(VALUE self, VALUE other, https://github.com/ruby/ruby/blob/trunk/complex.c#L817 if (f_gt_p(f_abs(bdat->real), f_abs(bdat->imag))) { r = (*func)(bdat->imag, bdat->real); n = f_mul(bdat->real, f_add(ONE, f_mul(r, r))); - if (flo) - return f_complex_new2(CLASS_OF(self), - (*func)(self, n), - (*func)(f_negate(f_mul(self, r)), n)); x = (*func)(f_add(adat->real, f_mul(adat->imag, r)), n); y = (*func)(f_sub(adat->imag, f_mul(adat->real, r)), n); } else { r = (*func)(bdat->real, bdat->imag); n = f_mul(bdat->imag, f_add(ONE, f_mul(r, r))); - if (flo) - return f_complex_new2(CLASS_OF(self), - (*func)(f_mul(self, r), n), - (*func)(f_negate(self), n)); x = (*func)(f_add(f_mul(adat->real, r), adat->imag), n); y = (*func)(f_sub(f_mul(adat->imag, r), adat->real), n); } - x = rb_rational_canonicalize(x); - y = rb_rational_canonicalize(y); + if (!flo) { + x = rb_rational_canonicalize(x); + y = rb_rational_canonicalize(y); + } return f_complex_new2(CLASS_OF(self), x, y); } if (k_numeric_p(other) && f_real_p(other)) { -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/