Example #1
0
        public static System.Random Restore(this NativeRandomState state)
        {
            var binaryFormatter = new BinaryFormatter();

            using (var temp = new MemoryStream(state.State))
            {
                return((System.Random)binaryFormatter.Deserialize(temp));
            }
        }
Example #2
0
 /// <summary>
 ///     Set the internal state of the generator from a <see cref="NumPyRandom"/>.
 ///     for use if one has reason to manually (re-)set the internal state of the pseudo-random number generating algorithm.
 /// </summary>
 /// <param name="nativeRandomState">The state to restore onto this <see cref="NumPyRandom"/></param>
 public void set_state(NativeRandomState nativeRandomState)
 {
     randomizer = nativeRandomState.Restore();
 }
Example #3
0
 /// <summary>
 ///     Returns a new instance of <see cref="NumPyRandom"/>.
 /// </summary>
 public NumPyRandom RandomState(NativeRandomState state)
 {
     return(new NumPyRandom(state));
 }
Example #4
0
 internal NumPyRandom(NativeRandomState nativeRandomState)
 {
     set_state(nativeRandomState);
 }
 public static Randomizer Restore(this NativeRandomState state)
 {
     return(Randomizer.Deserialize(state.State));
 }