Background and motivation
Fills the elements of a specified span of doubles with random numbers. Returns a random floating-point number that is greater than or equal to 0.0, and less than 1.0.
This is a cross of the existing methods: NextBytes(Span<byte>) and NextDouble().
Can be useful when sampling multiple values from continuous distributions.
API Proposal
namespace System;
public partial class Random
{
+ public virtual void NextDoubles(Span<double> buffer);
}
API Usage
Span<double> buffer = stackalloc double[4];
Random.Shared.NextDoubles(buffer);
Console.WriteLine(buffer[0]);
Alternative Designs
Ideally, I'd like to load the random values into a Vector<T> for SIMD operation, but I am not aware if such SIMD operation is available on any architecture.
Risks
No response
Background and motivation
Fills the elements of a specified span of
doubles with random numbers. Returns a random floating-point number that is greater than or equal to 0.0, and less than 1.0.This is a cross of the existing methods:
NextBytes(Span<byte>)andNextDouble().Can be useful when sampling multiple values from continuous distributions.
API Proposal
namespace System; public partial class Random { + public virtual void NextDoubles(Span<double> buffer); }API Usage
Alternative Designs
Ideally, I'd like to load the random values into a
Vector<T>for SIMD operation, but I am not aware if such SIMD operation is available on any architecture.Risks
No response