Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 3C9D8200C73 for ; Wed, 26 Apr 2017 02:18:30 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 39A49160BB6; Wed, 26 Apr 2017 00:18:30 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 8168E160BB3 for ; Wed, 26 Apr 2017 02:18:29 +0200 (CEST) Received: (qmail 39702 invoked by uid 500); 26 Apr 2017 00:18:28 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 39690 invoked by uid 99); 26 Apr 2017 00:18:28 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Apr 2017 00:18:28 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id E6540C88EC for ; Wed, 26 Apr 2017 00:18:27 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.08 X-Spam-Level: X-Spam-Status: No, score=0.08 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (1024-bit key) header.d=scarlet.be Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id oR_rF2eeVoee for ; Wed, 26 Apr 2017 00:18:25 +0000 (UTC) Received: from hel.is.scarlet.be (hel.is.scarlet.be [193.74.71.26]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 397CE5FB86 for ; Wed, 26 Apr 2017 00:18:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scarlet.be; s=scarlet; t=1493165899; bh=iqSXyUVQuo02vEdS/Q/Qy/0PyjfTkELXvtSEk+4aGOg=; h=MIME-Version:Content-Type:Content-Transfer-Encoding:Date:From:To: Subject:In-Reply-To:References:Message-ID; b=0ERjqBCPOd6PiEY19mcsVHR4z9id9NBXh8865g6aYGbPUB0H3j08piwbGRkemJ1EM iwgMzBq5RkQUo0YLCBHLdSdVaEEoAGq83zueUQdmvcNtGP3QA8/dJxwxGj24LMLGYJ MlkmTt0PR6BFQLKc3SsrfVX0yJ5PmkTnHhIfm0j0= Received: from webmail.scarlet.be (gresham.is.scarlet.be [193.74.71.215]) by hel.is.scarlet.be (8.14.9/8.14.9) with ESMTP id v3Q0IIuU009901 for ; Wed, 26 Apr 2017 02:18:19 +0200 X-Scarlet: d=1493165899 c=193.74.71.215 Received: from ip-213-49-203-23.dsl.scarlet.be ([213.49.203.23]) via ip-213-49-203-23.dsl.scarlet.be ([213.49.203.23]) by webmail.scarlet.be with HTTP (HTTP/1.1 POST); Wed, 26 Apr 2017 02:18:19 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 26 Apr 2017 02:18:19 +0200 From: Gilles To: Commons Developers List Subject: Re: commons-numbers git commit: NUMBERS-27: Replaced hand-coded hypot with Java.lang.Math hypot In-Reply-To: <38e7f63a77e84caa98ac48ae110db242@git.apache.org> References: <38e7f63a77e84caa98ac48ae110db242@git.apache.org> Message-ID: <892c9d6728f52ec8a95c0b0eaeaa62f0@scarlet.be> X-Sender: gilles@harfang.homelinux.org User-Agent: Scarlet Webmail X-DCC-scarlet.be-Metrics: hel; whitelist X-Virus-Scanned: clamav-milter 0.98.1-exp at hel X-Virus-Status: Clean archived-at: Wed, 26 Apr 2017 00:18:30 -0000 Hi Eric. In the code below, any reason why you use the "accessor" method rather than refer directly to the instance fields? Regards, Gilles On Tue, 25 Apr 2017 22:40:29 +0000 (UTC), ericbarnhill@apache.org wrote: > Repository: commons-numbers > Updated Branches: > refs/heads/hypot-change [created] b2df9248d > > > NUMBERS-27: Replaced hand-coded hypot with Java.lang.Math hypot > > > Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo > Commit: > > http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/b2df9248 > Tree: > http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/b2df9248 > Diff: > http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/b2df9248 > > Branch: refs/heads/hypot-change > Commit: b2df9248d8e2e36732a535d92b0ff629e47d1694 > Parents: 1e4947b > Author: Eric Barnhill > Authored: Wed Apr 26 00:39:28 2017 +0200 > Committer: Eric Barnhill > Committed: Wed Apr 26 00:39:28 2017 +0200 > > > ---------------------------------------------------------------------- > .../apache/commons/numbers/complex/Complex.java | 17 > ++++++++--------- > 1 file changed, 8 insertions(+), 9 deletions(-) > > ---------------------------------------------------------------------- > > > > http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/b2df9248/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java > > ---------------------------------------------------------------------- > diff --git > > a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java > > b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java > index 4e9022e..cfd7a39 100644 > --- > > a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java > +++ > > b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java > @@ -109,18 +109,17 @@ public class Complex implements Serializable { > if (isInfinite()) { > return Double.POSITIVE_INFINITY; > } > - if (Math.abs(real) < Math.abs(imaginary)) { > - if (imaginary == 0.0) { > - return Math.abs(real); > + if (Math.abs(getReal()) < Math.abs(getImaginary())) { > + if (getImaginary() == 0.0) { > + return Math.abs(getReal()); > } > - double q = real / imaginary; > - return Math.abs(imaginary) * Math.sqrt(1 + q * q); > + double q = getReal() / getImaginary(); > + return Math.abs(getImaginary()) * Math.sqrt(1 + q * q); > } else { > - if (real == 0.0) { > - return Math.abs(imaginary); > + if (getReal() == 0.0) { > + return Math.abs(getImaginary()); > } > - double q = imaginary / real; > - return Math.abs(real) * Math.sqrt(1 + q * q); > + return Math.hypot(getReal(), getImaginary()); > } > } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org