Ejemplo n.º 1
0
        /// <summary>
        /// Get an array of direction vectors that can be used for quasirandom number generation.
        /// <para/>
        /// The array contains vectors for many dimensions. Each dimension
        /// has 64 vectors. Each individual vector is an unsigned long long.
        /// <para/>
        /// Legal values for set are:
        /// - <see cref="DirectionVectorSet.JoeKuo6_64"/> (20,000 dimensions)
        /// - <see cref="DirectionVectorSet.ScrambledJoeKuo6_64"/> (20,000 dimensions)
        /// </summary>
        /// <param name="set"></param>
        /// <returns></returns>
        public static DirectionVectors64[] GetDirectionVectors64(DirectionVectorSet set)
        {
            IntPtr       ptr;
            CurandStatus status = CudaRandNativeMethods.curandGetDirectionVectors64(out ptr, set);

            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "curandGetDirectionVectors64", status));
            if (status != CurandStatus.Success)
            {
                throw new CudaRandException(status);
            }

            DirectionVectors64[] vec = new DirectionVectors64[MaxDimensions];

            for (int i = 0; i < MaxDimensions; i++)
            {
                vec[i] = (DirectionVectors64)Marshal.PtrToStructure(new IntPtr(ptr.ToInt64() + i * 64 * Marshal.SizeOf(typeof(ulong))), typeof(DirectionVectors64));
            }

            return(vec);
        }
Ejemplo n.º 2
0
		/// <summary>
		/// Get an array of direction vectors that can be used for quasirandom number generation.
		/// <para/>
		/// The array contains vectors for many dimensions. Each dimension
		/// has 64 vectors. Each individual vector is an unsigned long long.
		/// <para/>
		/// Legal values for set are:
		/// - <see cref="DirectionVectorSet.JoeKuo6_64"/> (20,000 dimensions)
		/// - <see cref="DirectionVectorSet.ScrambledJoeKuo6_64"/> (20,000 dimensions)
		/// </summary>
		/// <param name="set"></param>
		/// <returns></returns>
		public static DirectionVectors64[] GetDirectionVectors64(DirectionVectorSet set)
		{
			IntPtr ptr;
			CurandStatus status = CudaRandNativeMethods.curandGetDirectionVectors64(out ptr, set);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "curandGetDirectionVectors64", status));
			if (status != CurandStatus.Success) throw new CudaRandException(status);

			DirectionVectors64[] vec = new DirectionVectors64[MaxDimensions];

			for (int i = 0; i < MaxDimensions; i++)
			{
				vec[i] = (DirectionVectors64)Marshal.PtrToStructure(new IntPtr(ptr.ToInt64() + i * 64 * Marshal.SizeOf(typeof(ulong))), typeof(DirectionVectors64));
			}

			return vec;
		}