randArray - multiple declarations

Function randArray

Convenience function to allow one-statement creation of arrays of random numbers.

auto auto randArray(alias randFun, Args...) (
  size_t N,
  auto ref Args args
);

Examples

// Create an array of 10 random numbers distributed Normal(0, 1).
auto normals = randArray!rNormal(10, 0, 1);

Function randArray

Allows the creation of an array of random numbers with an explicitly specified type. Useful, for example, when single-precision floats are all you need.

R[] randArray(R, alias randFun, Args...) (
  size_t N,
  auto ref Args args
);

Examples

// Create an array of 10 million floats distributed Normal(0, 1).
float[] normals = randArray!(float, rNormal)(10, 0, 1);