Пример #1
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));
        }
Пример #2
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));
        }