You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Gilles Sadowski <gi...@harfang.homelinux.org> on 2012/08/21 16:15:37 UTC

Re: svn commit: r1375192 - in /commons/proper/math/trunk/src: changes/ main/java/org/apache/commons/math3/random/

Hi.

> [...]
> 
> Added: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/random/RandomDataGenerator.java
> URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/random/RandomDataGenerator.java?rev=1375192&view=auto
> ==============================================================================
> --- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/random/RandomDataGenerator.java (added)
> +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/random/RandomDataGenerator.java Mon Aug 20 19:53:57 2012
> [...]
> + *
> + * @version $Id$
> + */
> +public class RandomDataGenerator implements RandomData, Serializable {
> +
> +    /** Serializable version identifier */
> +    private static final long serialVersionUID = -626730818244969716L;
> +
> +    /** underlying random number generator */
> +    private RandomGenerator rand = null;
> +
> +    /** underlying secure random number generator */
> +    private SecureRandom secRand = null;

Should this class be "Serializable"?


Gilles

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


Re: svn commit: r1375192 - in /commons/proper/math/trunk/src: changes/ main/java/org/apache/commons/math3/random/

Posted by Luc Maisonobe <Lu...@free.fr>.
Le 21/08/2012 16:15, Gilles Sadowski a écrit :
> Hi.
> 
>> [...]
>>
>> Added: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/random/RandomDataGenerator.java
>> URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/random/RandomDataGenerator.java?rev=1375192&view=auto
>> ==============================================================================
>> --- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/random/RandomDataGenerator.java (added)
>> +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/random/RandomDataGenerator.java Mon Aug 20 19:53:57 2012
>> [...]
>> + *
>> + * @version $Id$
>> + */
>> +public class RandomDataGenerator implements RandomData, Serializable {
>> +
>> +    /** Serializable version identifier */
>> +    private static final long serialVersionUID = -626730818244969716L;
>> +
>> +    /** underlying random number generator */
>> +    private RandomGenerator rand = null;
>> +
>> +    /** underlying secure random number generator */
>> +    private SecureRandom secRand = null;
> 
> Should this class be "Serializable"?

Yes!
This allows to save the state of a generator and restart it at the exact
same state later on.

Luc

> 
> 
> Gilles
> 
> ---------------------------------------------------------------------
> 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: r1375192 - in /commons/proper/math/trunk/src: changes/ main/java/org/apache/commons/math3/random/

Posted by Phil Steitz <ph...@gmail.com>.



On Aug 21, 2012, at 7:15 AM, Gilles Sadowski <gi...@harfang.homelinux.org> wrote:

> Hi.
> 
>> [...]
>> 
>> Added: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/random/RandomDataGenerator.java
>> URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/random/RandomDataGenerator.java?rev=1375192&view=auto
>> ==============================================================================
>> --- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/random/RandomDataGenerator.java (added)
>> +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/random/RandomDataGenerator.java Mon Aug 20 19:53:57 2012
>> [...]
>> + *
>> + * @version $Id$
>> + */
>> +public class RandomDataGenerator implements RandomData, Serializable {
>> +
>> +    /** Serializable version identifier */
>> +    private static final long serialVersionUID = -626730818244969716L;
>> +
>> +    /** underlying random number generator */
>> +    private RandomGenerator rand = null;
>> +
>> +    /** underlying secure random number generator */
>> +    private SecureRandom secRand = null;
> 
> Should this class be "Serializable"?

I think so, yes.  It maintains state and all members are serializable.  (Need to check to make sure generators really are serializable).  Making it not serializable breaks EmpiricalDistribution.  EmpiricalDistribution instances and others that include instances of this class as members can be remoted.  I see that I forgot to generate serial version Id.  I will fix that if we agree to leave it serializable.

Phil
> 
> 
> Gilles
> 
> ---------------------------------------------------------------------
> 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