/// <summary> /// Sets the initial seed Ig of stream g to the vector seed. This vector must satisfy the same /// conditions as the SetPackageSeed method. The stream is then reset to this initial seed. The /// states and seeds of the other streams are not modified. As a result, after calling this method, /// the initial seeds of the streams are no longer spaced Z values apart. We discourage the use of /// this method. Returns false for invalid seeds, true otherwise. StreamID is set to -1 after this /// method is called. /// </summary> /// <param name="seed">The seed values to set.</param> /// <returns>True if the seed values are successfully set, false otherwise.</returns> public virtual bool setSeed(long[] seed) { int i; if (RngStream.CheckSeed(seed) != 0) { return(false); // FAILURE } for (i = 0; i < 6; ++i) { Cg[i] = Bg[i] = Ig[i] = seed[i]; } streamID = -1; return(true); // SUCCESS }
/// <summary> /// Sets the initial seed of the first stream to the six longs in the passed vector seed. This will /// be the seed (initial state) of the first stream. If one of the setPackageSeed methods is not called, the /// default initial seed is (12345, 12345, 12345, 12345, 12345, 12345). If it is called, the first 3 /// values of the seed must all be less than m1 = 4294967087, and not all 0; and the last 3 values must /// all be less than m2 = 4294944443, and not all 0. NOTE: if this method is called, the originalSeed value /// is set to -1. /// </summary> /// <param name="seed">The list of seeds to set.</param> /// <returns>True if the seeds are successfully set, false otherwise.</returns> public static bool setPackageSeed(long[] seed) { lock (seedLocker) { originalSeed = -1; // Must use long because there is no unsigned int type. if (RngStream.CheckSeed(seed) != 0) { return(false); // FAILURE } for (int i = 0; i < 6; ++i) { nextSeed[i] = seed[i]; packageSeed[i] = seed[i]; } nextStreamID = 0; return(true); // SUCCESS } }