예제 #1
0
        /// <summary>Creates a new random number stream.
        /// </summary>
        /// <param name="n">The number of initial conditions contained in <paramref name="initialConditions"/>.</param>
        /// <param name="initialConditions">Initial conditions. <see cref="IRandomNumberGenerator.InitialConditions"/> contains a description of the usage of additional parameters.</param>
        /// <returns>The random number stream in its <see cref="IRandomNumberStream"/> representation.</returns>
        /// <exception cref="ArgumentException">Thrown if at least one parameter is not suitable for the Random Number Generator represented by the current instance.</exception>
        public IRandomNumberStream Create(int n, uint[] initialConditions)
        {
            IntPtr streamHandle = IntPtr.Zero;
            int    errorCode    = MklRandomNumberLibrary.vslNewStreamEx(ref streamHandle, m_GeneratorID, n, initialConditions);

            if (errorCode != 0) // execution is not successful
            {
                throw new InvalidOperationException("MKL: Return value " + errorCode + " in vslNewStreamEx.");
            }
            return(new MklRandomNumberStream(streamHandle, this));
        }
예제 #2
0
        /// <summary>Creates a new random number stream.
        /// </summary>
        /// <param name="n">The number of initial conditions contained in <paramref name="initialConditions"/>.</param>
        /// <param name="initialConditions">Initial conditions. <see cref="IRandomNumberGenerator.InitialConditions"/> contains a description of the usage of additional parameters.</param>
        /// <param name="subGeneratorID">A sub-generator ID if a set of similar Random Number Generator is represented by the current instance.</param>
        /// <returns>The random number stream in its <see cref="IRandomNumberStream"/> representation.</returns>
        /// <exception cref="ArgumentException">Thrown if at least one parameter is not suitable for the Random Number Generator represented by the current instance.</exception>
        public IRandomNumberStream Create(int n, uint[] initialConditions, int subGeneratorID)
        {
            if ((subGeneratorID < 0) || (subGeneratorID > m_SubGeneratorIDs.Last()))
            {
                throw new ArgumentException("subGeneratorID");
            }
            IntPtr streamHandle = IntPtr.Zero;
            int    errorCode    = MklRandomNumberLibrary.vslNewStreamEx(ref streamHandle, m_GeneratorID + subGeneratorID, n, initialConditions);

            if (errorCode != 0) // execution is not successful
            {
                throw new InvalidOperationException("MKL: Return value " + errorCode + " in vslNewStreamEx.");
            }
            return(new MklRandomNumberStream(streamHandle, this, subGeneratorID: subGeneratorID));
        }
예제 #3
0
        /// <summary>Creates a new random number stream.
        /// </summary>
        /// <param name="seed">The seed.</param>
        /// <returns>The random number stream in its <see cref="IRandomNumberStream"/> representation.</returns>
        /// <exception cref="ArgumentException">Thrown if <paramref name="seed"/> is invalid for the Random Number Generator represented by the current instance.</exception>
        /// <exception cref="InvalidOperationException">Thrown, if additional parameters are required.</exception>
        public IRandomNumberStream Create(long seed)
        {
            if ((seed < 0) || (seed > MaxSeed))
            {
                throw new ArgumentException("seed");
            }
            IntPtr streamHandle = IntPtr.Zero;
            int    errorCode    = MklRandomNumberLibrary.vslNewStream(ref streamHandle, m_GeneratorID, (uint)seed);

            if (errorCode != 0) // execution is not successful
            {
                throw new InvalidOperationException("MKL: Return value " + errorCode + " in vslNewStream.");
            }
            return(new MklRandomNumberStream(streamHandle, this));
        }
예제 #4
0
        /// <summary>Creates a new random number stream.
        /// </summary>
        /// <param name="dimension">The dimension.</param>
        /// <returns>The random number stream in its <see cref="IRandomNumberStream"/> representation.
        /// </returns>
        /// <exception cref="InvalidOperationException">Thrown, if additional parameters are required.</exception>
        public IRandomNumberStream Create(long dimension)
        {
            if (dimension > UInt32.MaxValue)
            {
                throw new ArgumentException("dimension");
            }
            IntPtr streamHandle = IntPtr.Zero;
            int    errorCode    = MklRandomNumberLibrary.vslNewStream(ref streamHandle, m_GeneratorID, (uint)dimension);

            if (errorCode != 0) // execution is not successful
            {
                throw new InvalidOperationException("MKL: Return value " + errorCode + " in vslNewStream.");
            }
            return(new MklRandomNumberStream(streamHandle, this, (uint)dimension));
        }
예제 #5
0
        /// <summary>Gets the <see cref="IRandomNumberStream" /> object under test.
        /// </summary>
        /// <returns>The <see cref="IRandomNumberStream" /> object to test.</returns>
        protected override IRandomNumberStream GetRandomStream()
        {
            MklRandomNumberLibrary library = new MklRandomNumberLibrary();

            return(library.MT2203.Create(1234));
        }
예제 #6
0
        /// <summary>Gets the <see cref="IRandomNumberStream" /> object under test.
        /// </summary>
        /// <returns>The <see cref="IRandomNumberStream" /> object to test.</returns>
        protected override IRandomNumberStream GetRandomStream()
        {
            MklRandomNumberLibrary library = new MklRandomNumberLibrary();

            return(library.WichmannHill.Create(45));
        }
예제 #7
0
        /// <summary>Gets the <see cref="IRandomNumberStream" /> object under test.
        /// </summary>
        /// <returns>The <see cref="IRandomNumberStream" /> object to test.</returns>
        protected override IRandomNumberStream GetRandomStream()
        {
            MklRandomNumberLibrary library = new MklRandomNumberLibrary();

            return(library.Sobol.Create(2));
        }