astyle --recursive --indent=spaces=2 --style=kr --indent-col1-comments --break-blocks --convert-tabs --max-code-length=200
This is done for better merging branch/LG_PRE_RELEASE_0.3 into trunk (same process is applied on this branch) git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7073 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
OpenAirInterface
|
||||
OpenAirInterface
|
||||
Copyright(c) 1999 - 2014 Eurecom
|
||||
|
||||
OpenAirInterface is free software: you can redistribute it and/or modify
|
||||
@@ -14,15 +14,15 @@
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenAirInterface.The full GNU General Public License is
|
||||
included in this distribution in the file called "COPYING". If not,
|
||||
along with OpenAirInterface.The full GNU General Public License is
|
||||
included in this distribution in the file called "COPYING". If not,
|
||||
see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Contact Information
|
||||
OpenAirInterface Admin: openair_admin@eurecom.fr
|
||||
OpenAirInterface Tech : openair_tech@eurecom.fr
|
||||
OpenAirInterface Dev : openair4g-devel@eurecom.fr
|
||||
|
||||
|
||||
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
|
||||
|
||||
*******************************************************************************/
|
||||
@@ -32,12 +32,12 @@
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
static unsigned int seed, iy, ir[98];
|
||||
/*
|
||||
@defgroup _uniformdouble
|
||||
@defgroup _uniformdouble
|
||||
@ingroup numerical Uniform linear congruential random number generator.
|
||||
*/
|
||||
|
||||
@@ -50,24 +50,24 @@ static unsigned int seed, iy, ir[98];
|
||||
void randominit(unsigned seed_init)
|
||||
{
|
||||
int i;
|
||||
// this need to be integrated with the existing rng, like taus: navid
|
||||
// this need to be integrated with the existing rng, like taus: navid
|
||||
msg("Initializing random number generator, seed %x\n",seed_init);
|
||||
|
||||
if (seed_init == 0) {
|
||||
srand((unsigned)time(NULL));
|
||||
|
||||
seed = (unsigned int) rand();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
seed = seed_init;
|
||||
}
|
||||
|
||||
|
||||
if (seed % 2 == 0) seed += 1; /* seed and mod are relative prime */
|
||||
for (i=1; i<=97; i++)
|
||||
{
|
||||
seed = a*seed; /* mod 2**32 */
|
||||
ir[i]= seed; /* initialize the shuffle table */
|
||||
|
||||
for (i=1; i<=97; i++) {
|
||||
seed = a*seed; /* mod 2**32 */
|
||||
ir[i]= seed; /* initialize the shuffle table */
|
||||
}
|
||||
|
||||
iy=1;
|
||||
}
|
||||
|
||||
@@ -75,8 +75,8 @@ void randominit(unsigned seed_init)
|
||||
|
||||
double uniformrandom(void)
|
||||
{
|
||||
#define a 1664525lu
|
||||
#define mod 4294967296.0 /* is 2**32 */
|
||||
#define a 1664525lu
|
||||
#define mod 4294967296.0 /* is 2**32 */
|
||||
|
||||
int j;
|
||||
|
||||
@@ -88,8 +88,8 @@ double uniformrandom(void)
|
||||
}
|
||||
|
||||
/*
|
||||
@defgroup _gaussdouble Gaussian random number generator based on modified Box-Muller transformation.
|
||||
@ingroup numerical
|
||||
@defgroup _gaussdouble Gaussian random number generator based on modified Box-Muller transformation.
|
||||
@ingroup numerical
|
||||
*/
|
||||
|
||||
/*!\brief Gaussian random number generator based on modified Box-Muller transformation.Returns a double-precision floating-point number. */
|
||||
@@ -100,31 +100,34 @@ double gaussdouble(double mean, double variance)
|
||||
static double gset;
|
||||
double fac,r,v1,v2;
|
||||
|
||||
if (iset == 0){
|
||||
do{
|
||||
v1 = 2.0*uniformrandom()-1.0;
|
||||
v2 = 2.0*uniformrandom()-1.0;
|
||||
r = v1*v1+v2*v2;
|
||||
} while (r >= 1.0);
|
||||
fac = sqrt(-2.0*log(r)/r);
|
||||
gset= v1*fac;
|
||||
iset=1;
|
||||
return(sqrt(variance)*v2*fac + mean);
|
||||
if (iset == 0) {
|
||||
do {
|
||||
v1 = 2.0*uniformrandom()-1.0;
|
||||
v2 = 2.0*uniformrandom()-1.0;
|
||||
r = v1*v1+v2*v2;
|
||||
} while (r >= 1.0);
|
||||
|
||||
fac = sqrt(-2.0*log(r)/r);
|
||||
gset= v1*fac;
|
||||
iset=1;
|
||||
return(sqrt(variance)*v2*fac + mean);
|
||||
} else {
|
||||
iset=0;
|
||||
return(sqrt(variance)*gset + mean);
|
||||
iset=0;
|
||||
return(sqrt(variance)*gset + mean);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef MAIN
|
||||
main(int argc,char **argv) {
|
||||
main(int argc,char **argv)
|
||||
{
|
||||
|
||||
int i;
|
||||
|
||||
randominit();
|
||||
for (i=0;i<10;i++) {
|
||||
|
||||
for (i=0; i<10; i++) {
|
||||
printf("%f\n",gaussdouble(0.0,1.0));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user