예제 #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));
            }
        }
예제 #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();
 }
예제 #3
0
 /// <summary>
 ///     Returns a new instance of <see cref="NumPyRandom"/>.
 /// </summary>
 public NumPyRandom RandomState(NativeRandomState state)
 {
     return(new NumPyRandom(state));
 }
예제 #4
0
 internal NumPyRandom(NativeRandomState nativeRandomState)
 {
     set_state(nativeRandomState);
 }
예제 #5
0
 public static Randomizer Restore(this NativeRandomState state)
 {
     return(Randomizer.Deserialize(state.State));
 }