diff --git a/src/frontend/parse.c b/src/frontend/parse.c index a8dd2e113..913e4814a 100644 --- a/src/frontend/parse.c +++ b/src/frontend/parse.c @@ -140,7 +140,7 @@ typedef void* cx_function_t(void*,short int,int,int*,short int*); struct func ft_funcs[] = { { "mag", cx_mag } , - { "magnitude", cx_mag } , + { "magnitude", cx_mag } , { "ph", cx_ph } , { "phase", cx_ph } , { "j", cx_j } , @@ -161,13 +161,14 @@ struct func ft_funcs[] = { { "atan", cx_atan } , { "norm", cx_norm } , { "rnd", cx_rnd } , + { "sunif", cx_sunif } , { "sgauss", cx_sgauss } , { "pos", cx_pos } , { "mean", cx_mean } , - { "avg", cx_avg } , /* A.Roldan 03/06/05 incremental average new function */ - { "group_delay", (cx_function_t*) cx_group_delay } , /* A.Roldan 10/06/05 group delay new function */ + { "avg", cx_avg } , /* A.Roldan 03/06/05 incremental average new function */ + { "group_delay", (cx_function_t*) cx_group_delay } , /* A.Roldan 10/06/05 group delay new function */ { "vector", cx_vector } , - { "unitvec", cx_unitvec } , + { "unitvec", cx_unitvec } , { "length", cx_length } , { "vecmin", cx_min } , { "vecmax", cx_max } , diff --git a/src/include/fteext.h b/src/include/fteext.h index bc06d39a7..59b50778c 100644 --- a/src/include/fteext.h +++ b/src/include/fteext.h @@ -95,6 +95,7 @@ extern void *cx_atan(void *, short int , int , int *, short int *); extern void *cx_norm(void *, short int , int , int *, short int *); extern void *cx_uminus(void *, short int , int , int *, short int *); extern void *cx_rnd(void *, short int , int , int *, short int *); +extern void *cx_sunif(void *, short int , int , int *, short int *); extern void *cx_sgauss(void *, short int , int , int *, short int *); extern void *cx_mean(void *, short int , int , int *, short int *); extern void *cx_avg(void *, short int , int , int *, short int *); diff --git a/src/maths/cmaths/cmath2.c b/src/maths/cmaths/cmath2.c index 5102b4a90..3104747fd 100644 --- a/src/maths/cmaths/cmath2.c +++ b/src/maths/cmaths/cmath2.c @@ -31,6 +31,7 @@ extern void srandom (unsigned int seed); #endif extern void checkseed(void); /* seed random or set by 'set rndseed=value'*/ +extern double drand(void); /* from randnumb.c */ extern double gauss(void); /* from randnumb.c */ static double * @@ -245,6 +246,35 @@ cx_rnd(void *data, short int type, int length, int *newlength, short int *newtyp } } +void * +cx_sunif(void *data, short int type, int length, int *newlength, short int *newtype) +{ + *newlength = length; + checkseed(); + if (type == VF_COMPLEX) { + complex *c; + int i; + + c = alloc_c(length); + *newtype = VF_COMPLEX; + for (i = 0; i < length; i++) { + realpart(&c[i]) = drand(); + imagpart(&c[i]) = drand(); + } + return ((void *) c); + } else { + double *d; + int i; + + d = alloc_d(length); + *newtype = VF_REAL; + for (i = 0; i < length; i++) { + d[i] = drand(); + } + return ((void *) d); + } +} + void * cx_sgauss(void *data, short int type, int length, int *newlength, short int *newtype) { @@ -252,7 +282,6 @@ cx_sgauss(void *data, short int type, int length, int *newlength, short int *new checkseed(); if (type == VF_COMPLEX) { complex *c; - complex *cc = (complex *) data; int i; c = alloc_c(length); @@ -264,7 +293,6 @@ cx_sgauss(void *data, short int type, int length, int *newlength, short int *new return ((void *) c); } else { double *d; - double *dd = (double *) data; int i; d = alloc_d(length); @@ -276,7 +304,6 @@ cx_sgauss(void *data, short int type, int length, int *newlength, short int *new } } - /* Compute the avg of a vector. Created by A.M.Roldan 2005-05-21 */ diff --git a/src/maths/cmaths/cmath2.h b/src/maths/cmaths/cmath2.h index f2462b63f..3ce8f54f7 100644 --- a/src/maths/cmaths/cmath2.h +++ b/src/maths/cmaths/cmath2.h @@ -12,6 +12,7 @@ void * cx_atan(void *data, short int type, int length, int *newlength, short int void * cx_norm(void *data, short int type, int length, int *newlength, short int *newtype); void * cx_uminus(void *data, short int type, int length, int *newlength, short int *newtype); void * cx_rnd(void *data, short int type, int length, int *newlength, short int *newtype); +void * cx_sunif(void *data, short int type, int length, int *newlength, short int *newtype); void * cx_sgauss(void *data, short int type, int length, int *newlength, short int *newtype); void * cx_mean(void *data, short int type, int length, int *newlength, short int *newtype); void * cx_length(void *data, short int type, int length, int *newlength, short int *newtype);