/// <inheritdoc cref="DisposeBase.Dispose(bool)"/> protected override void Dispose(bool disposing) { var statusCode = API.DestoryGenerator(GeneratorPtr); if (disposing) { CuRandException.ThrowIfFailed(statusCode); } GeneratorPtr = IntPtr.Zero; }
/// <summary> /// Fills the given span with uniformly distributed normals in [0.0, ..., 1.0). /// </summary> /// <param name="span">The span to fill.</param> public unsafe void FillUniform(Span <double> span) { fixed(double *ptr = span) { CuRandException.ThrowIfFailed( API.GenerateUniformDouble( GeneratorPtr, new IntPtr(ptr), new IntPtr(span.Length))); } }
/// <summary> /// Fills the given span with uniformly distributed floats in [0.0, ..., 1.0). /// </summary> /// <param name="span">The span to fill.</param> public unsafe void FillUniform(Span <float> span) { fixed(float *ptr = span) { CuRandException.ThrowIfFailed( API.GenerateUniformFloat( GeneratorPtr, new IntPtr(ptr), new IntPtr(span.Length))); } }
public unsafe void FillUniform(Span <ulong> span) { fixed(ulong *ptr = span) { CuRandException.ThrowIfFailed( API.GenerateULong( GeneratorPtr, new IntPtr(ptr), new IntPtr(span.Length))); } }
/// <summary> /// Fills the given span with normally distributed doubles in [0.0, ..., 1.0). /// </summary> /// <param name="span">The span to fill.</param> /// <param name="mean">The normal distribution mean.</param> /// <param name="stddev">The normal distribution standard deviation.</param> public unsafe void FillNormal(Span <double> span, double mean, double stddev) { fixed(double *ptr = span) { CuRandException.ThrowIfFailed( API.GenerateNormalDouble( GeneratorPtr, new IntPtr(ptr), new IntPtr(span.Length), mean, stddev)); } }
/// <summary> /// Fills the given span with normally distributed floats in [0.0, ..., 1.0). /// </summary> /// <param name="span">The span to fill.</param> /// <param name="mean">The normal distribution mean.</param> /// <param name="stddev">The normal distribution standard deviation.</param> public unsafe void FillNormal(Span <float> span, float mean, float stddev) { fixed(float *ptr = span) { CuRandException.ThrowIfFailed( API.GenerateNormalFloat( GeneratorPtr, new IntPtr(ptr), new IntPtr(span.Length), mean, stddev)); } }