Exemple #1
0
        /// <inheritdoc cref="DisposeBase.Dispose(bool)"/>
        protected override void Dispose(bool disposing)
        {
            var statusCode = API.DestoryGenerator(GeneratorPtr);

            if (disposing)
            {
                CuRandException.ThrowIfFailed(statusCode);
            }
            GeneratorPtr = IntPtr.Zero;
        }
Exemple #2
0
 /// <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)));
     }
 }
Exemple #3
0
 /// <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)));
     }
 }
Exemple #4
0
 public unsafe void FillUniform(Span <ulong> span)
 {
     fixed(ulong *ptr = span)
     {
         CuRandException.ThrowIfFailed(
             API.GenerateULong(
                 GeneratorPtr,
                 new IntPtr(ptr),
                 new IntPtr(span.Length)));
     }
 }
Exemple #5
0
 /// <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));
     }
 }
Exemple #6
0
 /// <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));
     }
 }