Pregunta

I have a for-loop:

for (i=0; i<N; i++) a[i] = rand()

But that's too slow, and BLAS/vDSP/vecLib/etc are at my disposal. I'm looking for a function to create an array of random numbers; it seems like it should be included.

Besides the name for this function, I would also appreciate a some good vDSP/vecLib/etc documentation. I've found some documentation, but it's not good -- just general descriptions of the functions.

¿Fue útil?

Solución

dlarnv does what you describe. It populates a double array with random (uniform or normal) values, and it is included in vecLib.

Otros consejos

Fast and well-distributed random number generators are useful for many purposes, so I'm sure you can find some great ones out there. I would start by looking at the Mersenne Twister, and in particular implementations that are optimized for SIMD, like this.

The next step in speed would come from GPU or DSP based algorithms, but I'm not aware of any in the public domain at the moment.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top