How to create one array in a method with user given length? I would like to fill in a vector with user given length with random numbers.
double* Random::quasiRandomUnif(float a, float b, int NN)
{
int i, errcode;
N_=NN; // here initialize the member N_
float r[N_];
VSLStreamStatePtr stream;
int i, errcode;
errcode = vslNewStream( &stream, BRNG, SEED );
errcode = vsRngUniform( METHOD, stream, N_, r, a, b );
double* rd = new double[m_N];
for(int i=0;i<m_N;i++)
rd[i]=(double)r[i];
errcode = vslDeleteStream( &stream );
return rd;
}
I thought of N_ a member for the class Random, to be initialized in this function's body, with some user given value -- not possible, since space allocated in array should be a constant. How to deal with?
Kind regards.
deleteinstead ofdelete []. std::vector is the way forward here