commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From luc.maison...@free.fr
Subject Re: svn commit: r785552 - in /commons/proper/math/trunk/src: java/org/apache/commons/math/complex/Complex.java site/xdoc/changes.xml
Date Wed, 17 Jun 2009 19:22:16 GMT
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

----- psteitz@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-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message