#2/4 switch cph() and cmag() args from ngcomplex* to ngcomplex
This commit is contained in:
parent
50aea0be0c
commit
94e3abd847
|
|
@ -1,3 +1,12 @@
|
|||
2012-02-07 Robert Larice
|
||||
* src/frontend/diff.c ,
|
||||
* src/include/ngspice/complex.h ,
|
||||
* src/maths/cmaths/cmath1.c ,
|
||||
* src/maths/cmaths/cmath2.c ,
|
||||
* src/maths/cmaths/cmath3.c ,
|
||||
* src/maths/cmaths/cmath4.c :
|
||||
#2/4 switch cph() and cmag() args from ngcomplex* to ngcomplex
|
||||
|
||||
2012-02-07 Robert Larice
|
||||
* src/include/ngspice/complex.h :
|
||||
#1/4 drop cast (enable compiler type check)
|
||||
|
|
|
|||
|
|
@ -243,11 +243,11 @@ com_diff(wordlist *wl)
|
|||
realpart(&c3) = realpart(&c1) - realpart(&c2);
|
||||
imagpart(&c3) = imagpart(&c1) - imagpart(&c2);
|
||||
/* Stupid evil PC compilers */
|
||||
cm1 = cmag(&c1);
|
||||
cm2 = cmag(&c2);
|
||||
cm1 = cmag(c1);
|
||||
cm2 = cmag(c2);
|
||||
cmax = MAX(cm1, cm2);
|
||||
if (cmax * reltol +
|
||||
tol < cmag(&c3)) {
|
||||
tol < cmag(c3)) {
|
||||
|
||||
printnum(numbuf, realpart(&c1));
|
||||
printnum(numbuf2, imagpart(&c1));
|
||||
|
|
|
|||
|
|
@ -70,8 +70,8 @@ typedef struct {
|
|||
|
||||
/* Some defines used mainly in cmath.c. */
|
||||
#define FTEcabs(d) (((d) < 0.0) ? - (d) : (d))
|
||||
#define cph(c) (atan2(imagpart(c), (realpart(c))))
|
||||
#define cmag(c) (sqrt(imagpart(c) * imagpart(c) + realpart(c) * realpart(c)))
|
||||
#define cph(c) (atan2(imagpart(&(c)), (realpart(&(c)))))
|
||||
#define cmag(c) (sqrt(imagpart(&(c)) * imagpart(&(c)) + realpart(&(c)) * realpart(&(c))))
|
||||
#define radtodeg(c) (cx_degrees ? ((c) / 3.14159265358979323846 * 180) : (c))
|
||||
#define degtorad(c) (cx_degrees ? ((c) * 3.14159265358979323846 / 180) : (c))
|
||||
#define rcheck(cond, name) if (!(cond)) { \
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ cx_mag(void *data, short int type, int length, int *newlength, short int *newtyp
|
|||
d[i] = FTEcabs(dd[i]);
|
||||
else
|
||||
for (i = 0; i < length; i++)
|
||||
d[i] = cmag(&cc[i]);
|
||||
d[i] = cmag(cc[i]);
|
||||
return ((void *) d);
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ cx_ph(void *data, short int type, int length, int *newlength, short int *newtype
|
|||
*newtype = VF_REAL;
|
||||
if (type == VF_COMPLEX)
|
||||
for (i = 0; i < length; i++) {
|
||||
d[i] = radtodeg(cph(&cc[i]));
|
||||
d[i] = radtodeg(cph(cc[i]));
|
||||
}
|
||||
/* Otherwise it is 0, but tmalloc zeros the stuff already. */
|
||||
return ((void *) d);
|
||||
|
|
@ -81,10 +81,10 @@ cx_cph(void *data, short int type, int length, int *newlength, short int *newtyp
|
|||
*newlength = length;
|
||||
*newtype = VF_REAL;
|
||||
if (type == VF_COMPLEX) {
|
||||
double last_ph = cph(&cc[0]);
|
||||
double last_ph = cph(cc[0]);
|
||||
d[0] = radtodeg(last_ph);
|
||||
for (i = 1; i < length; i++) {
|
||||
double ph = cph(&cc[i]);
|
||||
double ph = cph(cc[i]);
|
||||
last_ph = ph - (2*M_PI) * floor((ph - last_ph)/(2*M_PI) + 0.5);
|
||||
d[i] = radtodeg(last_ph);
|
||||
}
|
||||
|
|
@ -190,7 +190,7 @@ cx_db(void *data, short int type, int length, int *newlength, short int *newtype
|
|||
*newtype = VF_REAL;
|
||||
if (type == VF_COMPLEX)
|
||||
for (i = 0; i < length; i++) {
|
||||
tt = cmag(&cc[i]);
|
||||
tt = cmag(cc[i]);
|
||||
rcheck(tt > 0, "db");
|
||||
/*
|
||||
if (tt == 0.0)
|
||||
|
|
@ -226,7 +226,7 @@ cx_log(void *data, short int type, int length, int *newlength, short int *newtyp
|
|||
for (i = 0; i < length; i++) {
|
||||
double td;
|
||||
|
||||
td = cmag(&cc[i]);
|
||||
td = cmag(cc[i]);
|
||||
/* Perhaps we should trap when td = 0.0, but Ken wants
|
||||
* this to be possible...
|
||||
*/
|
||||
|
|
@ -273,7 +273,7 @@ cx_ln(void *data, short int type, int length, int *newlength, short int *newtype
|
|||
for (i = 0; i < length; i++) {
|
||||
double td;
|
||||
|
||||
td = cmag(&cc[i]);
|
||||
td = cmag(cc[i]);
|
||||
rcheck(td >= 0, "ln");
|
||||
if (td == 0.0) {
|
||||
realpart(&c[i]) = - log(HUGE);
|
||||
|
|
@ -378,10 +378,10 @@ cx_sqrt(void *data, short int type, int length, int *newlength, short int *newty
|
|||
imagpart(&c[i]) = 0.0;
|
||||
} else if (imagpart(&cc[i]) < 0.0) {
|
||||
realpart(&c[i]) = -sqrt(0.5 *
|
||||
(cmag(&cc[i]) + realpart(&cc[i])));
|
||||
(cmag(cc[i]) + realpart(&cc[i])));
|
||||
} else {
|
||||
realpart(&c[i]) = sqrt(0.5 *
|
||||
(cmag(&cc[i]) + realpart(&cc[i])));
|
||||
(cmag(cc[i]) + realpart(&cc[i])));
|
||||
}
|
||||
imagpart(&c[i]) = imagpart(&cc[i]) / (2.0 *
|
||||
realpart(&c[i]));
|
||||
|
|
@ -393,11 +393,11 @@ cx_sqrt(void *data, short int type, int length, int *newlength, short int *newty
|
|||
} else {
|
||||
if (imagpart(&cc[i]) < 0.0)
|
||||
imagpart(&c[i]) = - sqrt(0.5 *
|
||||
(cmag(&cc[i]) -
|
||||
(cmag(cc[i]) -
|
||||
realpart(&cc[i])));
|
||||
else
|
||||
imagpart(&c[i]) = sqrt(0.5 *
|
||||
(cmag(&cc[i]) -
|
||||
(cmag(cc[i]) -
|
||||
realpart(&cc[i])));
|
||||
realpart(&c[i]) = imagpart(&cc[i]) /
|
||||
(2.0 * imagpart(&c[i]));
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ cx_max_local(void *data, short int type, int length)
|
|||
int i;
|
||||
|
||||
for (i = 0; i < length; i++)
|
||||
if (cmag(&cc[i]) > largest)
|
||||
largest = cmag(&cc[i]);
|
||||
if (cmag(cc[i]) > largest)
|
||||
largest = cmag(cc[i]);
|
||||
} else {
|
||||
double *dd = (double *) data;
|
||||
int i;
|
||||
|
|
@ -434,7 +434,7 @@ cx_vector(void *data, short int type, int length, int *newlength, short int *new
|
|||
if (type == VF_REAL)
|
||||
len = (int)FTEcabs(*dd);
|
||||
else
|
||||
len = (int)cmag(cc);
|
||||
len = (int)cmag(*cc);
|
||||
if (len == 0)
|
||||
len = 1;
|
||||
d = alloc_d(len);
|
||||
|
|
@ -461,7 +461,7 @@ cx_unitvec(void *data, short int type, int length, int *newlength, short int *ne
|
|||
if (type == VF_REAL)
|
||||
len = (int)FTEcabs(*dd);
|
||||
else
|
||||
len = (int)cmag(cc);
|
||||
len = (int)cmag(*cc);
|
||||
if (len == 0)
|
||||
len = 1;
|
||||
d = alloc_d(len);
|
||||
|
|
|
|||
|
|
@ -187,8 +187,8 @@ cln(ngcomplex_t *c)
|
|||
{
|
||||
static ngcomplex_t r;
|
||||
|
||||
rcheck(cmag(c) != 0, "ln");
|
||||
realpart(&r) = log(cmag(c));
|
||||
rcheck(cmag(*c) != 0, "ln");
|
||||
realpart(&r) = log(cmag(*c));
|
||||
if (imagpart(c) != 0.0)
|
||||
imagpart(&r) = atan2(imagpart(c), realpart(c));
|
||||
else
|
||||
|
|
|
|||
|
|
@ -441,7 +441,7 @@ cx_group_delay(void *data, short int type, int length, int *newlength, short int
|
|||
if (type == VF_COMPLEX)
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
v_phase[i] = radtodeg(cph(&cc[i]));
|
||||
v_phase[i] = radtodeg(cph(cc[i]));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue