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:
Lionel Gauthier
2015-04-09 09:29:12 +00:00
parent f0a8a0b3b5
commit 059a0a3fdc
2044 changed files with 1182666 additions and 1145123 deletions
+37 -34
View File
@@ -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,9 +32,9 @@
#include "defs.h"
unsigned int *generate_gauss_LUT(unsigned char Nbits,
unsigned char L
)
unsigned int *generate_gauss_LUT(unsigned char Nbits,
unsigned char L
)
{
unsigned int *LUT_ptr,i;
@@ -43,7 +43,7 @@ unsigned int *generate_gauss_LUT(unsigned char Nbits,
assert(LUT_ptr);
for (i=0;i<(1<<(Nbits-1));i++) {
for (i=0; i<(1<<(Nbits-1)); i++) {
LUT_ptr[i] = (unsigned int)((double)((unsigned int)(1<<31))*erf(i*L/(double)(1<<(Nbits-1))));
#ifdef LUTDEBUG
@@ -52,21 +52,22 @@ unsigned int *generate_gauss_LUT(unsigned char Nbits,
}
return(LUT_ptr);
}
}
int gauss(unsigned int *gauss_LUT,
unsigned char Nbits
) {
int gauss(unsigned int *gauss_LUT,
unsigned char Nbits
)
{
unsigned int search_pos,step_size,u,tmp,tmpm1,tmpp1,s;
// Get a 32-bit uniform random-variable
u = taus();
#ifdef DEBUG
printf("u = %u\n",u);
printf("u = %u\n",u);
#endif //DEBUG
// if it is larger than 2^31 (here negative), save the sign and rescale down to 31-bits.
@@ -75,36 +76,35 @@ int gauss(unsigned int *gauss_LUT,
u &= 0x7fffffff;
#ifdef DEBUG
printf("u = %x,s=%d\n",u,s);
#ifdef DEBUG
printf("u = %x,s=%d\n",u,s);
#endif //DEBUG
search_pos = (1<<(Nbits-2)); // starting position of the binary search
step_size = search_pos;
do {
step_size >>= 1;
tmp = gauss_LUT[search_pos];
tmpm1 = gauss_LUT[search_pos-1];
tmpp1 = gauss_LUT[search_pos+1];
#ifdef DEBUG
printf("search_pos %d, step_size %d: t %x tm %x,tp %x\n",search_pos,step_size,tmp,tmpm1,tmpp1);
#endif //DEBUG
if (u <= tmp)
if (u >tmpm1)
return s==0 ? (search_pos-1) : 1-search_pos;
if (u <= tmp)
if (u >tmpm1)
return s==0 ? (search_pos-1) : 1-search_pos;
else
search_pos -= step_size;
search_pos -= step_size;
else if (u <= tmpp1)
return s==0 ? search_pos : - search_pos;
else
if (u <= tmpp1)
return s==0 ? search_pos : - search_pos;
else
search_pos += step_size;
}
while (step_size > 0);
search_pos += step_size;
} while (step_size > 0);
// If it gets here we're beyond the positive edge so return max
return s==0 ? (1<<(Nbits-1))-1 : 1-((1<<(Nbits-1)));
@@ -116,7 +116,8 @@ int gauss(unsigned int *gauss_LUT,
#define Nhistbits 8
void main(int argc,char **argv) {
void main(int argc,char **argv)
{
unsigned int *gauss_LUT_ptr,i;
unsigned int hist[(1<<Nhistbits)];
@@ -136,14 +137,16 @@ void main(int argc,char **argv) {
// Generate Gaussian LUT 12-bit quantization over 5 standard deviations
gauss_LUT_ptr = generate_gauss_LUT(Nbits,L);
for (i=0;i<(1<<Nhistbits);i++)
for (i=0; i<(1<<Nhistbits); i++)
hist[i] = 0;
for (i=0;i<Ntrials;i++) {
for (i=0; i<Ntrials; i++) {
gvar = gauss(gauss_LUT_ptr,Nbits);
if (gvar == ((1<<(Nbits-1))-1))
maxnum++;
maxg = gvar > maxg ? gvar : maxg;
ming = gvar < ming ? gvar : ming;
meang += (double)gvar/Ntrials;
@@ -156,8 +159,8 @@ void main(int argc,char **argv) {
printf("Tail probability = %e(%x)\n",2*erfc((double)L*gauss_LUT_ptr[(1<<(Nbits-1))-1]/(unsigned int)(1<<31)),gauss_LUT_ptr[(1<<(Nbits-1))-1]);
printf("max %d, min %d, mean %f, stddev %f, Pr(maxnum)=%e(%d)\n",maxg,ming,meang,sqrt(varg),(double)maxnum/Ntrials,maxnum);
// for (i=0;i<(1<<Nhistbits);i++)
// printf("%d : %u\n",i,hist[i]);
// for (i=0;i<(1<<Nhistbits);i++)
// printf("%d : %u\n",i,hist[i]);
free(gauss_LUT_ptr);
}