You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by lu...@free.fr on 2009/06/17 23:58:45 UTC
Re: svn commit: r785552 - in /commons/proper/math/trunk/src:
java/org/apache/commons/math/complex/Complex.java site/xdoc/changes.xml
----- "Phil Steitz" <ph...@gmail.com> a écrit :
> Sorry if I am being dense here. What serialization problem do the new
> fields cause, exactly? The class is immutable and they are set by the
> constructor.
It takes more space to store. If someone uses serialization to store or send a bunch of complex this will vastly increase the load.
>
> On 6/17/09, luc.maisonobe@free.fr <lu...@free.fr> wrote:
> > 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
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: svn commit: r785552 - in /commons/proper/math/trunk/src:
java/org/apache/commons/math/complex/Complex.java site/xdoc/changes.xml
Posted by Bill Barker <bi...@verizon.net>.
----- Original Message -----
From: <lu...@free.fr>
To: "Commons Developers List" <de...@commons.apache.org>
Sent: Wednesday, June 17, 2009 2:58 PM
Subject: Re: svn commit: r785552 - in /commons/proper/math/trunk/src:
java/org/apache/commons/math/complex/Complex.java site/xdoc/changes.xml
>----- "Phil Steitz" <ph...@gmail.com> a écrit :
>
>> Sorry if I am being dense here. What serialization problem do the new
>> fields cause, exactly? The class is immutable and they are set by the
>> constructor.
>
>It takes more space to store. If someone uses serialization to store or
>send a bunch of complex >this will vastly increase the load.
The main problem is that the fields can be either transient or final, but
not both (or rather, you can't reset the value of final fields in
readObject). I have a slight preference for transient for the reason Luc
gave (a BlockFieldMatrix<ComplexField> will get large quickly), and have no
problem doing the change myself. But I can wait for other opinions.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org