Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2B8187A89 for ; Thu, 14 Jul 2011 06:08:47 +0000 (UTC) Received: (qmail 73186 invoked by uid 500); 14 Jul 2011 06:08:45 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 72819 invoked by uid 500); 14 Jul 2011 06:08:33 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 72796 invoked by uid 99); 14 Jul 2011 06:08:32 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Jul 2011 06:08:32 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Jul 2011 06:08:27 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 1C3DD23888CE for ; Thu, 14 Jul 2011 06:08:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r1146573 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/complex/Complex.java site/xdoc/changes.xml test/java/org/apache/commons/math/complex/ComplexTest.java Date: Thu, 14 Jul 2011 06:08:06 -0000 To: commits@commons.apache.org From: psteitz@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110714060806.1C3DD23888CE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: psteitz Date: Thu Jul 14 06:08:05 2011 New Revision: 1146573 URL: http://svn.apache.org/viewvc?rev=1146573&view=rev Log: Fixed add method to match javadoc contract when one or both addends has NaN parts. JIRA: MATH-618 Reported by Arne Plose Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/complex/Complex.java commons/proper/math/trunk/src/site/xdoc/changes.xml commons/proper/math/trunk/src/test/java/org/apache/commons/math/complex/ComplexTest.java Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/complex/Complex.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/complex/Complex.java?rev=1146573&r1=1146572&r2=1146573&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/complex/Complex.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/complex/Complex.java Thu Jul 14 06:08:05 2011 @@ -150,6 +150,9 @@ public class Complex implements FieldEle public Complex add(Complex rhs) throws NullArgumentException { MathUtils.checkNotNull(rhs); + if (isNaN || rhs.isNaN) { + return NaN; + } return createComplex(real + rhs.getReal(), imaginary + rhs.getImaginary()); } Modified: commons/proper/math/trunk/src/site/xdoc/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/site/xdoc/changes.xml?rev=1146573&r1=1146572&r2=1146573&view=diff ============================================================================== --- commons/proper/math/trunk/src/site/xdoc/changes.xml (original) +++ commons/proper/math/trunk/src/site/xdoc/changes.xml Thu Jul 14 06:08:05 2011 @@ -52,6 +52,11 @@ The type attribute can be add,u If the output is not quite correct, check for invisible trailing spaces! --> + + Complex add javadoc says that if either addend has NaN parts, the result + should be Complex.NaN. Prior to the fix for this issue, NaNs were propagated + only in real and imaginary parts individually. + Framework for iterative linear solvers. Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/complex/ComplexTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/complex/ComplexTest.java?rev=1146573&r1=1146572&r2=1146573&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math/complex/ComplexTest.java (original) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/complex/ComplexTest.java Thu Jul 14 06:08:05 2011 @@ -113,7 +113,7 @@ public class ComplexTest { Assert.assertTrue(z.isNaN()); z = new Complex(1, nan); Complex w = x.add(z); - Assert.assertEquals(w.getReal(), 4.0, 0); + Assert.assertTrue(Double.isNaN(w.getReal())); Assert.assertTrue(Double.isNaN(w.getImaginary())); }