Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

Draw Random Numbers into vector

Tan__Elad
初学者
2,152 次查看
Hello,
Is there a way to call the random number generator with a STL's vector instead of a pointer to an array?
It seems kind of wasteful to copy every time from an array into the vector.
Cheers,
Elad
0 项奖励
1 解答
Andrey_N_Intel
2,152 次查看
Hello Elad, 
I wonder if this approach (with caution) would work for you

vector v(1000);
...
vdRngGaussian( VSL_RNG_METHOD_GAUSSIAN_ICDF, stream, v.size(), (double*)&v[0], 0.0, 1.0 );

Thanks,
Andrey

在原帖中查看解决方案

0 项奖励
2 回复数
Andrey_N_Intel
2,153 次查看
Hello Elad, 
I wonder if this approach (with caution) would work for you

vector v(1000);
...
vdRngGaussian( VSL_RNG_METHOD_GAUSSIAN_ICDF, stream, v.size(), (double*)&v[0], 0.0, 1.0 );

Thanks,
Andrey
0 项奖励
Tan__Elad
初学者
2,152 次查看
Worked great!! Thank you!!
0 项奖励
回复