I generate an array of random floats using the code shown below. However, I would like to do this with Double
instead of Float
. Are there any BNNS random number generators for double values, something like BNNSRandomFillUniformDouble
? If not, is there a way I can convert BNNSNDArrayDescriptor
from float to double?
import Accelerate
let n = 100_000_000
let result = Array<Float>(unsafeUninitializedCapacity: n) { buffer, initCount in
var descriptor = BNNSNDArrayDescriptor(data: buffer, shape: .vector(n))!
let randomGenerator = BNNSCreateRandomGenerator(BNNSRandomGeneratorMethodAES_CTR, nil)
BNNSRandomFillUniformFloat(randomGenerator, &descriptor, 0, 1)
initCount = n
}