diff --git a/src/main/java/org/apache/commons/math4/random/RngAdaptor.java b/src/main/java/org/apache/commons/math4/random/RngAdaptor.java index 4603f4e97..3c365af99 100644 --- a/src/main/java/org/apache/commons/math4/random/RngAdaptor.java +++ b/src/main/java/org/apache/commons/math4/random/RngAdaptor.java @@ -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; * *
  • * The new RNG implementations are not {@code Serializable}. - * Use {@link RandomSource#saveState(UniformRandomProvider)} + * Use {@link RestorableUniformRandomProvider#saveState()} * instead. *
  • *
  • @@ -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); } } diff --git a/src/main/java/org/apache/commons/math4/util/RandomPivotingStrategy.java b/src/main/java/org/apache/commons/math4/util/RandomPivotingStrategy.java index af0f5e1ea..ddcaf286b 100644 --- a/src/main/java/org/apache/commons/math4/util/RandomPivotingStrategy.java +++ b/src/main/java/org/apache/commons/math4/util/RandomPivotingStrategy.java @@ -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); } }