introduce unwrap, minimum and maximum function
This commit is contained in:
parent
20c375bcc2
commit
4635a19ba9
|
|
@ -140,6 +140,7 @@ struct func ft_funcs[] = {
|
|||
{ "magnitude", cx_mag },
|
||||
{ "cph", cx_cph }, /* SJdV */
|
||||
{ "cphase", cx_cph }, /* SJdV Continious phase*/
|
||||
{ "unwrap", cx_unwrap },
|
||||
{ "ph", cx_ph },
|
||||
{ "phase", cx_ph },
|
||||
{ "j", cx_j },
|
||||
|
|
@ -177,7 +178,9 @@ struct func ft_funcs[] = {
|
|||
{ "unitvec", cx_unitvec },
|
||||
{ "length", cx_length },
|
||||
{ "vecmin", cx_min },
|
||||
{ "minimum", cx_min },
|
||||
{ "vecmax", cx_max },
|
||||
{ "maximum", cx_max },
|
||||
{ "vecd", cx_d },
|
||||
{ "interpolate", (cx_function_t*) cx_interpolate },
|
||||
{ "deriv", (cx_function_t*) cx_deriv },
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ extern bool cx_degrees;
|
|||
extern void *cx_mag(void *, short int , int , int *, short int *);
|
||||
extern void *cx_ph(void *, short int , int , int *, short int *);
|
||||
extern void *cx_cph(void *, short int , int , int *, short int *);
|
||||
extern void *cx_unwrap(void *, short int , int , int *, short int *);
|
||||
extern void *cx_j(void *, short int , int , int *, short int *);
|
||||
extern void *cx_real(void *, short int , int , int *, short int *);
|
||||
extern void *cx_imag(void *, short int , int , int *, short int *);
|
||||
|
|
|
|||
|
|
@ -93,6 +93,29 @@ cx_cph(void *data, short int type, int length, int *newlength, short int *newtyp
|
|||
return ((void *) d);
|
||||
}
|
||||
|
||||
/* Modified from above but with real phase vector in degrees as input */
|
||||
void *
|
||||
cx_unwrap(void *data, short int type, int length, int *newlength, short int *newtype)
|
||||
{
|
||||
double *d = alloc_d(length);
|
||||
double *dd = (double *) data;
|
||||
int i;
|
||||
|
||||
*newlength = length;
|
||||
*newtype = VF_REAL;
|
||||
if (type == VF_REAL) {
|
||||
double last_ph = degtorad(dd[0]);
|
||||
d[0] = last_ph;
|
||||
for (i = 1; i < length; i++) {
|
||||
double ph = degtorad(dd[i]);
|
||||
last_ph = ph - (2*M_PI) * floor((ph - last_ph)/(2*M_PI) + 0.5);
|
||||
d[i] = radtodeg(last_ph);
|
||||
}
|
||||
}
|
||||
/* Otherwise it is 0, but tmalloc zeros the stuff already. */
|
||||
return ((void *) d);
|
||||
}
|
||||
|
||||
/* If this is pure imaginary we might get real, but never mind... */
|
||||
|
||||
void *
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
void * cx_mag(void *data, short int type, int length, int *newlength, short int *newtype);
|
||||
void * cx_ph(void *data, short int type, int length, int *newlength, short int *newtype);
|
||||
void * cx_cph(void *data, short int type, int length, int *newlength, short int *newtype);
|
||||
void * cx_unwrap(void *data, short int type, int length, int *newlength, short int *newtype);
|
||||
void * cx_j(void *data, short int type, int length, int *newlength, short int *newtype);
|
||||
void * cx_real(void *data, short int type, int length, int *newlength, short int *newtype);
|
||||
void * cx_imag(void *data, short int type, int length, int *newlength, short int *newtype);
|
||||
|
|
|
|||
Loading…
Reference in New Issue