Code update (following change in "Commons RNG").
This commit is contained in:
parent
72df12fb2b
commit
7b42d43fa0
|
@ -21,7 +21,7 @@ import java.io.IOException;
|
|||
import java.io.ObjectOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RestorableUniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
|
||||
/**
|
||||
|
@ -52,7 +52,7 @@ import org.apache.commons.rng.RandomSource;
|
|||
* </li>
|
||||
* <li>
|
||||
* The new RNG implementations are not {@code Serializable}.
|
||||
* Use {@link RandomSource#saveState(UniformRandomProvider)}
|
||||
* Use {@link RestorableUniformRandomProvider#saveState()}
|
||||
* instead.
|
||||
* </li>
|
||||
* <li>
|
||||
|
@ -79,7 +79,7 @@ public final class RngAdaptor
|
|||
/** Source. */
|
||||
private final RandomSource source;
|
||||
/** Delegate. */
|
||||
private transient UniformRandomProvider delegate;
|
||||
private transient RestorableUniformRandomProvider delegate;
|
||||
/** Next gaussian. */
|
||||
private double nextGaussian = Double.NaN;
|
||||
|
||||
|
@ -206,7 +206,7 @@ public final class RngAdaptor
|
|||
out.defaultWriteObject();
|
||||
|
||||
// Save current state.
|
||||
out.writeObject(RandomSource.saveState(delegate).getState());
|
||||
out.writeObject(((RandomSource.State) delegate.saveState()).getState());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -224,6 +224,6 @@ public final class RngAdaptor
|
|||
delegate = RandomSource.create(source);
|
||||
// And restore its state.
|
||||
final RandomSource.State state = new RandomSource.State((byte[]) in.readObject());
|
||||
RandomSource.restoreState(delegate, state);
|
||||
delegate.restoreState(state);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import java.io.IOException;
|
|||
import java.io.ObjectOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import org.apache.commons.math4.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.RestorableUniformRandomProvider;
|
||||
import org.apache.commons.rng.RandomSource;
|
||||
|
||||
/**
|
||||
|
@ -35,7 +35,7 @@ public class RandomPivotingStrategy implements PivotingStrategyInterface, Serial
|
|||
/** Source of randomness. */
|
||||
private final RandomSource randomSource;
|
||||
/** Random generator to use for selecting pivot. */
|
||||
private transient UniformRandomProvider random;
|
||||
private transient RestorableUniformRandomProvider random;
|
||||
|
||||
/**
|
||||
* Simple constructor.
|
||||
|
@ -77,7 +77,7 @@ public class RandomPivotingStrategy implements PivotingStrategyInterface, Serial
|
|||
out.defaultWriteObject();
|
||||
|
||||
// Save current state.
|
||||
out.writeObject(RandomSource.saveState(random).getState());
|
||||
out.writeObject(((RandomSource.State) random.saveState()).getState());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,6 +95,6 @@ public class RandomPivotingStrategy implements PivotingStrategyInterface, Serial
|
|||
random = RandomSource.create(randomSource);
|
||||
// And restore its state.
|
||||
final RandomSource.State state = new RandomSource.State((byte[]) in.readObject());
|
||||
RandomSource.restoreState(random, state);
|
||||
random.restoreState(state);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue