Beispiel #1
0
        /// <summary>
        /// Seed Xoroshiro128+ with 128 bit seed. If there are less than 128 bits in the source array, it will be padded. Any extra will be ignored.
        /// </summary>
        /// <param name="bits">Bits for seed.</param>
        /// <param name="startindex">Start index of the array.</param>
        public Xoroshiro128PlusRNG(byte[] bits, int startindex)
        {
            if (startindex >= bits.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(bits));
            }
            byte[] nw = new byte[bits.Length - startindex];

            Array.Copy(bits, startindex, nw, 0, nw.Length);
            if (nw.Length < 16)
            {
                var ob = nw;
                bits = new byte[16];
                Array.Copy(ob, bits, bits.Length);
            }
            else
            {
                bits = nw;
            }

            var s0 = BitConverter.ToUInt64(bits, 0);
            var s1 = BitConverter.ToUInt64(bits, sizeof(ulong));

            xoroshiro = new Xoroshiro128Plus(s0, s1);
        }
Beispiel #2
0
        /// <summary>
        /// Seed Xoroshiro128+ with 128 bit seed. If there are less than 128 bits in the source array, it will be padded. Any extra will be ignored.
        /// </summary>
        /// <param name="bits">Bits for seed.</param>
        public Xoroshiro128PlusRNG(byte[] bits)
        {
            if (bits.Length < 16)
            {
                var ob = bits;
                bits = new byte[16];
                Array.Copy(ob, bits, bits.Length);
            }
            var s0 = BitConverter.ToUInt64(bits, 0);
            var s1 = BitConverter.ToUInt64(bits, sizeof(ulong));

            xoroshiro = new Xoroshiro128Plus(s0, s1);
        }
Beispiel #3
0
 /// <summary>
 /// Seed Xoroshiro128+ with 128 bit seed from decimal.
 /// </summary>
 /// <param name="bits">Seed bits</param>
 public Xoroshiro128PlusRNG(decimal bits)
 {
     xoroshiro = new Xoroshiro128Plus(bits);
 }
Beispiel #4
0
 /// <summary>
 /// Seed Xoroshiro128+ with 128 bit seed.
 /// </summary>
 /// <param name="state0">First 64 bits</param>
 /// <param name="state1">Second 64 bits</param>
 public Xoroshiro128PlusRNG(ulong state0, ulong state1)
 {
     xoroshiro = new Xoroshiro128Plus(state0, state1);
 }
Beispiel #5
0
 /// <summary>
 /// Seed Xoroshiro128+ with system time.
 /// </summary>
 public Xoroshiro128PlusRNG()
 {
     xoroshiro = new Xoroshiro128Plus();
 }
Beispiel #6
0
 /// <summary>
 /// Seed Xoroshiro128+ with 128 bits from System.Random
 /// </summary>
 /// <param name="r"></param>
 public Xoroshiro128PlusRNG(Random r)
 {
     xoroshiro = new Xoroshiro128Plus(r);
 }
Beispiel #7
0
 /// <summary>
 /// Seed Xoroshiro128+ with 64 bit integer using splitmix64.
 /// </summary>
 public Xoroshiro128PlusRNG(ulong seed)
 {
     xoroshiro = new Xoroshiro128Plus(seed);
 }
Beispiel #8
0
 /// <summary>
 /// Initialise xoroshiro128+ from the state of another.
 /// </summary>
 /// <param name="other">Other instance to copy state.</param>
 public Xoroshiro128Plus(Xoroshiro128Plus other)
 {
     Seed(other.state0, other.state1);
 }
Beispiel #9
0
 /// <summary>
 /// Seed Xoroshiro128+ from other Xoroshiro128PlusRNG instance
 /// </summary>
 public Xoroshiro128PlusRNG(Xoroshiro128PlusRNG other)
 {
     xoroshiro = new Xoroshiro128Plus(other.xoroshiro);
 }