You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ps...@apache.org on 2009/06/17 13:00:41 UTC
svn commit: r785552 - in /commons/proper/math/trunk/src:
java/org/apache/commons/math/complex/Complex.java site/xdoc/changes.xml
Author: psteitz
Date: Wed Jun 17 11:00:40 2009
New Revision: 785552
URL: http://svn.apache.org/viewvc?rev=785552&view=rev
Log:
Optimized isNaN, isInfinite. Jira: MATH-2276. Contributed by Mark Anderson.
Modified:
commons/proper/math/trunk/src/java/org/apache/commons/math/complex/Complex.java
commons/proper/math/trunk/src/site/xdoc/changes.xml
Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/complex/Complex.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/complex/Complex.java?rev=785552&r1=785551&r2=785552&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/complex/Complex.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/complex/Complex.java Wed Jun 17 11:00:40 2009
@@ -76,6 +76,16 @@
private final double real;
/**
+ * Record whether this complex number is equal to NaN
+ */
+ private final boolean isNaN;
+
+ /**
+ * Record whether this complex number is infinite
+ */
+ private final boolean isInfinite;
+
+ /**
* Create a complex number given the real and imaginary parts.
*
* @param real the real part
@@ -85,6 +95,10 @@
super();
this.real = real;
this.imaginary = imaginary;
+
+ isNaN = Double.isNaN(real) || Double.isNaN(imaginary);
+ isInfinite = !isNaN &&
+ (Double.isInfinite(real) || Double.isInfinite(imaginary));
}
/**
@@ -318,7 +332,7 @@
* false otherwise
*/
public boolean isNaN() {
- return Double.isNaN(real) || Double.isNaN(imaginary);
+ return isNaN;
}
/**
@@ -331,8 +345,7 @@
* and neither part is <code>NaN</code>
*/
public boolean isInfinite() {
- return !isNaN() &&
- (Double.isInfinite(real) || Double.isInfinite(imaginary));
+ return isInfinite;
}
/**
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=785552&r1=785551&r2=785552&view=diff
==============================================================================
--- commons/proper/math/trunk/src/site/xdoc/changes.xml (original)
+++ commons/proper/math/trunk/src/site/xdoc/changes.xml Wed Jun 17 11:00:40 2009
@@ -39,7 +39,10 @@
</properties>
<body>
<release version="2.0" date="TBD" description="TBD">
- <action dev="luc" type="fix" issue="MATH-207" due-to="David Stefka">
+ <action dev="psteitz" type="update" issue="MATH-276" due-to="Mark Anderson">
+ Optimized Complex isNaN(), isInfinite() by moving computation to constructor.
+ </action>
+ <action dev="psteitz" type="fix" issue="MATH-207" due-to="David Stefka">
Added Genetic Algorithm implementation.
</action>
<action dev="luc" type="fix" issue="MATH-274" >