The Complex class is still Serializable and should remain so. This change adds 
two fields that seem not good candidate to serialization. Would'nt it be better 
to mark these fields as transient and reset them at deserialization time in a 
new readObject method ?

Luc

----- pste...@apache.org a écrit :

> 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" >

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to