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,12 +1,12 @@
|
||||
#include "../../../defs.h"
|
||||
|
||||
|
||||
/*==============================================================================
|
||||
* set_taus_seed.c
|
||||
*
|
||||
* Returns seeds which are the input to taus.c.
|
||||
*
|
||||
* example: seeds = set_taus_seed(0)
|
||||
*
|
||||
*
|
||||
* Author: Sebastian Wagner
|
||||
* Date: 23-07-2012
|
||||
*
|
||||
@@ -14,55 +14,55 @@
|
||||
|
||||
|
||||
void mexFunction( int nlhs, mxArray *plhs[],
|
||||
int nrhs, const mxArray *prhs[]
|
||||
) {
|
||||
|
||||
/* Declare */
|
||||
unsigned int seed_init;
|
||||
unsigned int s0, s1, s2, *ret;
|
||||
|
||||
if(nrhs!=1)
|
||||
mexErrMsgTxt("Single input required.");
|
||||
else if(nlhs > 1)
|
||||
mexErrMsgTxt("Too many output arguments.");
|
||||
|
||||
/* Allocate input */
|
||||
seed_init = (unsigned int) mxGetScalar(prhs[0]);
|
||||
|
||||
/* Algo */
|
||||
int nrhs, const mxArray *prhs[]
|
||||
)
|
||||
{
|
||||
|
||||
/* Declare */
|
||||
unsigned int seed_init;
|
||||
unsigned int s0, s1, s2, *ret;
|
||||
|
||||
if(nrhs!=1)
|
||||
mexErrMsgTxt("Single input required.");
|
||||
else if(nlhs > 1)
|
||||
mexErrMsgTxt("Too many output arguments.");
|
||||
|
||||
/* Allocate input */
|
||||
seed_init = (unsigned int) mxGetScalar(prhs[0]);
|
||||
|
||||
/* Algo */
|
||||
#ifdef USER_MODE
|
||||
struct drand48_data buffer;
|
||||
unsigned int result = 0;
|
||||
struct drand48_data buffer;
|
||||
unsigned int result = 0;
|
||||
#endif
|
||||
|
||||
if (seed_init == 0) {
|
||||
s0 = (unsigned int)time(NULL);
|
||||
s1 = (unsigned int)time(NULL);
|
||||
s2 = (unsigned int)time(NULL);
|
||||
}
|
||||
else {
|
||||
|
||||
if (seed_init == 0) {
|
||||
s0 = (unsigned int)time(NULL);
|
||||
s1 = (unsigned int)time(NULL);
|
||||
s2 = (unsigned int)time(NULL);
|
||||
} else {
|
||||
#ifndef USER_MODE
|
||||
s0 = (unsigned int)0x1e23d852;
|
||||
s1 = (unsigned int)0x81f38a1c;
|
||||
s2 = (unsigned int)0xfe1a133e;
|
||||
s0 = (unsigned int)0x1e23d852;
|
||||
s1 = (unsigned int)0x81f38a1c;
|
||||
s2 = (unsigned int)0xfe1a133e;
|
||||
#else
|
||||
/* Use reentrant version of rand48 to ensure that no conflicts with other generators occur */
|
||||
srand48_r((long int)seed_init, &buffer);
|
||||
mrand48_r(&buffer, (long int *)&result);
|
||||
s0 = result;
|
||||
mrand48_r(&buffer, (long int *)&result);
|
||||
s1 = result;
|
||||
mrand48_r(&buffer, (long int *)&result);
|
||||
s2 = result;
|
||||
/* Use reentrant version of rand48 to ensure that no conflicts with other generators occur */
|
||||
srand48_r((long int)seed_init, &buffer);
|
||||
mrand48_r(&buffer, (long int *)&result);
|
||||
s0 = result;
|
||||
mrand48_r(&buffer, (long int *)&result);
|
||||
s1 = result;
|
||||
mrand48_r(&buffer, (long int *)&result);
|
||||
s2 = result;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Allocate Output */
|
||||
plhs[0] = mxCreateNumericMatrix(3, 1, mxUINT32_CLASS, mxREAL);
|
||||
ret = (unsigned int*) mxGetPr(plhs[0]);
|
||||
|
||||
ret[0] = s0;
|
||||
ret[1] = s1;
|
||||
ret[2] = s2;
|
||||
|
||||
}
|
||||
|
||||
/* Allocate Output */
|
||||
plhs[0] = mxCreateNumericMatrix(3, 1, mxUINT32_CLASS, mxREAL);
|
||||
ret = (unsigned int*) mxGetPr(plhs[0]);
|
||||
|
||||
ret[0] = s0;
|
||||
ret[1] = s1;
|
||||
ret[2] = s2;
|
||||
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
#include "../../../defs.h"
|
||||
|
||||
|
||||
/*==============================================================================
|
||||
* taus.c
|
||||
*
|
||||
* Returns random unsigned chars as well as the new seeds.
|
||||
*
|
||||
* example: [rchar seeds] = taus(len, seeds)
|
||||
*
|
||||
*
|
||||
* Author: Sebastian Wagner
|
||||
* Date: 23-07-2012
|
||||
*
|
||||
@@ -14,7 +14,8 @@
|
||||
|
||||
unsigned int s0, s1, s2, b;
|
||||
|
||||
inline unsigned int mtaus() {
|
||||
inline unsigned int mtaus()
|
||||
{
|
||||
|
||||
b = (((s0 << 13) ^ s0) >> 19);
|
||||
s0 = (((s0 & 0xFFFFFFFE) << 12)^ b);
|
||||
@@ -29,40 +30,40 @@ void mexFunction( int nlhs, mxArray *plhs[],
|
||||
int nrhs, const mxArray *prhs[]
|
||||
)
|
||||
{
|
||||
|
||||
/* Declare */
|
||||
unsigned int len, *tseeds, *tseeds_out;
|
||||
unsigned char *out;
|
||||
int i;
|
||||
|
||||
if(nrhs!=2)
|
||||
mexErrMsgTxt("Two inputs required.");
|
||||
else if(nlhs > 2)
|
||||
mexErrMsgTxt("Too many output arguments.");
|
||||
|
||||
/* Allocate input */
|
||||
len = (unsigned int) mxGetScalar(prhs[0]);
|
||||
tseeds = (unsigned int*) mxGetData(prhs[1]);
|
||||
|
||||
if (mxGetM(prhs[1])!=3 && mxGetN(prhs[1])!=3)
|
||||
mexErrMsgTxt("Three seeds are required.");
|
||||
|
||||
s0 = tseeds[0];
|
||||
s1 = tseeds[1];
|
||||
s2 = tseeds[2];
|
||||
|
||||
/* Allocate Output */
|
||||
plhs[0] = mxCreateNumericMatrix(len, 1, mxUINT8_CLASS, mxREAL);
|
||||
out = (unsigned char*) mxGetPr(plhs[0]);
|
||||
|
||||
plhs[1] = mxCreateNumericMatrix(3, 1, mxUINT32_CLASS, mxREAL);
|
||||
tseeds_out = (unsigned int*) mxGetPr(plhs[1]);
|
||||
|
||||
/* Algo */
|
||||
for(i=0;i<len;i++)
|
||||
out[i] = (unsigned char)(mtaus()&0xff);
|
||||
|
||||
tseeds_out[0] = s0;
|
||||
tseeds_out[1] = s1;
|
||||
tseeds_out[2] = s2;
|
||||
|
||||
/* Declare */
|
||||
unsigned int len, *tseeds, *tseeds_out;
|
||||
unsigned char *out;
|
||||
int i;
|
||||
|
||||
if(nrhs!=2)
|
||||
mexErrMsgTxt("Two inputs required.");
|
||||
else if(nlhs > 2)
|
||||
mexErrMsgTxt("Too many output arguments.");
|
||||
|
||||
/* Allocate input */
|
||||
len = (unsigned int) mxGetScalar(prhs[0]);
|
||||
tseeds = (unsigned int*) mxGetData(prhs[1]);
|
||||
|
||||
if (mxGetM(prhs[1])!=3 && mxGetN(prhs[1])!=3)
|
||||
mexErrMsgTxt("Three seeds are required.");
|
||||
|
||||
s0 = tseeds[0];
|
||||
s1 = tseeds[1];
|
||||
s2 = tseeds[2];
|
||||
|
||||
/* Allocate Output */
|
||||
plhs[0] = mxCreateNumericMatrix(len, 1, mxUINT8_CLASS, mxREAL);
|
||||
out = (unsigned char*) mxGetPr(plhs[0]);
|
||||
|
||||
plhs[1] = mxCreateNumericMatrix(3, 1, mxUINT32_CLASS, mxREAL);
|
||||
tseeds_out = (unsigned int*) mxGetPr(plhs[1]);
|
||||
|
||||
/* Algo */
|
||||
for(i=0; i<len; i++)
|
||||
out[i] = (unsigned char)(mtaus()&0xff);
|
||||
|
||||
tseeds_out[0] = s0;
|
||||
tseeds_out[1] = s1;
|
||||
tseeds_out[2] = s2;
|
||||
}
|
||||
Reference in New Issue
Block a user