Library/ManagedCuda/CudaRand/CudaRandDevice.cs
/// <summary>
/// Get scramble constants that can be used for quasirandom number generation.
/// <para/>
/// The array contains constants for many dimensions. Each dimension
/// has a single ulong constant. 
/// </summary>
/// <returns></returns>
Get scramble constants that can be used for quasirandom number generation.

The array contains constants for many dimensions. Each dimension
has a single ulong constant.
Get scramble constants that can be used for quasirandom number generation . The array contains constants for many dimensions . Each dimension has a single ulong constant .
public static ulong[] GetScrambleConstants64()
		{
			IntPtr ptr;
			CurandStatus status = CudaRandNativeMethods.curandGetScrambleConstants64(out ptr);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "curandGetScrambleConstants64", status));
			if (status != CurandStatus.Success) throw new CudaRandException(status);
			long[] consts_long = new long[MaxDimensions];
			ulong[] consts_ulong = new ulong[MaxDimensions];
			Marshal.Copy(ptr, consts_long, 0, MaxDimensions);
			GCHandle handle = GCHandle.Alloc(consts_ulong, GCHandleType.Pinned);
			Marshal.Copy(consts_long, 0, handle.AddrOfPinnedObject(), MaxDimensions);
			handle.Free();
			return consts_ulong;
		}
public static ulong [ ] GetScrambleConstants64 ( ) { IntPtr ptr ; CurandStatus status = CudaRandNativeMethods . curandGetScrambleConstants64 ( out ptr ) ; Debug . WriteLine ( String . Format ( " " , DateTime . Now , " " , status ) ) ; if ( status != CurandStatus . Success ) throw new CudaRandException ( status ) ; long [ ] consts_long = new long [ MaxDimensions ] ; ulong [ ] consts_ulong = new ulong [ MaxDimensions ] ; Marshal . Copy ( ptr , consts_long , 0 , MaxDimensions ) ; GCHandle handle = GCHandle . Alloc ( consts_ulong , GCHandleType . Pinned ) ; Marshal . Copy ( consts_long , 0 , handle . AddrOfPinnedObject ( ) , MaxDimensions ) ; handle . Free ( ) ; return consts_ulong ; }
Get scramble constants that can be used for quasirandom number generation.
Get scramble constants that can be used for quasirandom number generation .
//Marshall.Copy cannot directly copy to an ulong[] array. //So first copy to long[] and then to ulong[]...  //Copy unmanaged array (ptr) to managed array of long[]: //Pin ulong[] array to get IntPtr and copy data again.
None