new function sunif()
This commit is contained in:
parent
5c5bbe987d
commit
03d91ab8b0
|
|
@ -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 } ,
|
||||
|
|
|
|||
|
|
@ -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 *);
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue