title: implementing random generator in cuda
body: <p>i want to implement this function in cuda as device/global function so as to obtain random numbers which are in gaussian distribution.</p>
  
  <pre><code>double gasdev2() {
  double ran3n(long *seed);
  //  double genrand64_real3();
  static int iset=0;
  static double gcos;
  double tmp1,tmp2;
  
  if (iset==0) { 
   tmp1=sqrt(-2*log(ran3n(&amp;seed)));
   tmp2=pi2*ran3n(&amp;seed);
  //    tmp1=sqrt(-2*log(genrand64_real3()));
  //    tmp2=pi2*genrand64_real3();
    gcos=tmp1*cos(tmp2);
   iset=1;
   return tmp1*sin(tmp2);
  //return 1;
  }else{
    iset=0;
    return gcos;
   //return 1;
  }
  }
  </code></pre>
  
  <p>this function will be basically used in these function calls and in serial code these are like this</p>
  
  <pre><code>  for(int i=0;i&lt;NTO;i++){
    Frdx[j]=gasdev2()*ranm[j]*tconst;
    Frdy[j]=gasdev2()*ranm[j]*tconst;
    Frdz[j]=gasdev2()*ranm[j]*tconst;
    }
  </code></pre>