diff --git a/sgi2018/src/tools/matlab.h b/sgi2018/src/tools/matlab.h index bd34c3f8acb3a447d979d81faa90cb92b2dbe914..d7b937c56cd9274a6996c7c3385bb07edf4ab3b2 100644 --- a/sgi2018/src/tools/matlab.h +++ b/sgi2018/src/tools/matlab.h @@ -144,12 +144,9 @@ long uniform() { // generate an uniformaly distributed random number sampled from [-1;1] inline number randu() { - printf("randu 1 "); - //on le veut entre -1 et 1 / pour l'instant on l'a entre 0 et 1 //number result = uniform()/2147483647.0; //(double)0x7FFFFFFF; - number result = (uniform()-1073741823.5)/1073741823.5; - // number result = (uniform() - (number)3xFFFFFFF.8)/(number)3xFFFFFFF.8); - printf("result : %f \n",result); + number result = (uniform()-1073741823.5)/1073741823.5; + return result; // throw std::logic_error("Function not yet implemented."); } @@ -158,7 +155,7 @@ inline number randu() // their real and imaginary parts are uniformaly distributed random number sampled from [-1;1] ComplexVector randu(int size) { - printf("randu 2 "); + ComplexVector complexVector(size); std::complex<number> mycomplex; for(int i = 0; i < size; i++) @@ -166,7 +163,7 @@ ComplexVector randu(int size) std::complex<number> mycomplex(randu(), randu()); complexVector(i) = mycomplex; } - printf("randu 2 return "); + return complexVector; //throw std::logic_error("Function not yet implemented."); @@ -176,16 +173,11 @@ ComplexVector randu(int size) // sampled from a distribution with mean 0 and std 1 inline number randn() { - // printf("randn 1 "); - number res=0; - printf(" randn 1 : %f ",res); number U0 = uniform()/2147483647.0;//(double)0x7FFFFFFF; number U1 = uniform()/2147483647.0;//(double)0x7FFFFFFF; - printf("u0: %f ---- ",U0); - printf("u1 : %f ----- ",U1); res = sqrt(-2 * log(U0)) * cos(2 * M_PI * U1); - printf("result randn 1 : %f \n",res); + return res; // throw std::logic_error("Function not yet implemented."); @@ -195,7 +187,6 @@ inline number randn() // their real and imaginary parts are sampled from a normal distribution with mean 0 and std 1 ComplexVector randn(int size) { - printf("randn 2 "); // NOTE: this can be built on the previous function ComplexVector complexVector(size); std::complex<number> mycomplex; @@ -204,7 +195,7 @@ ComplexVector randn(int size) std::complex<number> mycomplex(randn(), randn()); complexVector(i) = mycomplex; } - printf("randn 2 return \n"); + return complexVector; //throw std::logic_error("Function not yet implemented."); }