This is inside other loops and is the most time consuming part of my code (much longer than assembly and solve). For example, generate 15000x100 numbers takes about 2 seconds, while the randn(15000,100) command in MATLAB takes 0.02. I look through gsl docs and find no way to generate a random vector/matrix without using loops. Importing data from MATLAB will not help because the I/O will become the new bottleneck.
Thanks a lot! It is quite interesting that the efficiency gain is lost if the statement
dWi = gslrangaussian(ffrng, 1.0);
is enclosed in a {}. What’s special about the syntax for [i,dWi: dW[]]?
A related question is how to fix the seed for the gsl random number generator? I want the results reproducible at different runs and in different machines by other researchers. The randinit function has no effect.