コード例 #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));
        }