Add a control language function cvector, to create a complex vector.
Let vec1 = cvector(50) will generate a complex vector, with the real part values increasing from 0 to 49, the imaginary values are set to 0. Useful in ac loops to store result data.
This commit is contained in:
parent
01e8b4da84
commit
0ee5e3f32a
|
|
@ -360,6 +360,7 @@ struct func ft_funcs[] = {
|
|||
{ "avg", cx_avg }, /* A.Roldan 03/06/05 incremental average new function */
|
||||
{ "group_delay", (cx_function_t*)(void *) cx_group_delay }, /* A.Roldan 10/06/05 group delay new function */
|
||||
{ "vector", cx_vector },
|
||||
{ "cvector", cx_cvector },
|
||||
{ "unitvec", cx_unitvec },
|
||||
{ "length", cx_length },
|
||||
{ "vecmin", cx_min },
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ extern void *cx_mean(void *, short int , int , int *, short int *);
|
|||
extern void *cx_stddev(void *, short int , int , int *, short int *);
|
||||
extern void *cx_length(void *, short int , int , int *, short int *);
|
||||
extern void *cx_vector(void *, short int , int , int *, short int *);
|
||||
extern void *cx_cvector(void *, short int , int , int *, short int *);
|
||||
extern void *cx_unitvec(void *, short int , int , int *, short int *);
|
||||
extern void *cx_plus(void *, void *, short int , short int , int );
|
||||
extern void *cx_minus(void *, void *, short int , short int , int );
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
|
|||
**********/
|
||||
|
||||
/** \file cmath2.c
|
||||
\brief functions for the control language parser: norm, uminus, rnd, sunif, sgauss, poisson, exponential, mean, stddev, length, vector, unitvec, plus, minus, times, mod, max, min, d, avg, floor, ceil, nint
|
||||
\brief functions for the control language parser: norm, uminus, rnd, sunif, sgauss, poisson, exponential, mean, stddev, length, vector, cvector, unitvec, plus, minus, times, mod, max, min, d, avg, floor, ceil, nint
|
||||
|
||||
Routines to do complex mathematical functions. These routines require
|
||||
the -lm libraries. We sacrifice a lot of space to be able
|
||||
|
|
@ -479,7 +479,7 @@ cx_length(void *data, short int type, int length, int *newlength, short int *new
|
|||
|
||||
|
||||
/* Return a vector from 0 to the magnitude of the argument. Length of the
|
||||
* argument is irrelevent.
|
||||
* argument is irrelevant.
|
||||
*/
|
||||
|
||||
void *
|
||||
|
|
@ -506,6 +506,38 @@ cx_vector(void *data, short int type, int length, int *newlength, short int *new
|
|||
return ((void *) d);
|
||||
}
|
||||
|
||||
/* Return a complex vector. Argument sets the length of the vector.
|
||||
The real part ranges from 0 to the magnitude of the argument. The imaginary
|
||||
part is set to 0.
|
||||
*/
|
||||
|
||||
void*
|
||||
cx_cvector(void* data, short int type, int length, int* newlength, short int* newtype)
|
||||
{
|
||||
ngcomplex_t* cc = (ngcomplex_t*)data;
|
||||
double* dd = (double*)data;
|
||||
int i, len;
|
||||
ngcomplex_t* d;
|
||||
|
||||
NG_IGNORE(length);
|
||||
|
||||
if (type == VF_REAL)
|
||||
len = (int)fabs(*dd);
|
||||
else
|
||||
len = (int)cmag(*cc);
|
||||
if (len == 0)
|
||||
len = 1;
|
||||
d = alloc_c(len);
|
||||
*newlength = len;
|
||||
*newtype = VF_COMPLEX;
|
||||
for (i = 0; i < len; i++) {
|
||||
realpart(d[i]) = i;
|
||||
imagpart(d[i]) = 0;
|
||||
}
|
||||
return ((void*)d);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Create a vector of the given length composed of all ones. */
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue