43 using namespace qucs::eqn;
46 #define C(con) ((constant *) (con))
47 #define A(con) ((application *) (con))
48 #define R(con) ((reference *) (con))
49 #define D(con) (C(con)->d)
51 #define isConst(n) ((n)->getTag()==CONSTANT && C(n)->getType()==TAG_DOUBLE)
52 #define isRef(r,v) ((r)->getTag()==REFERENCE && !strcmp(R(r)->n,v))
53 #define isZero(n) (isConst(n) && D(n) == 0.0)
54 #define isOne(n) (isConst(n) && D(n) == 1.0)
55 #define isNeg(n) (isConst(n) && D(n) == -1.0)
56 #define isEuler(n) ((isConst(n) && D(n) == M_E) || isRef(n,"e"))
57 #define isval(n,v) (isConst(n) && D(n) == v)
59 #define isVar(v) ((v)->getTag()==REFERENCE)
60 #define isApp(v) ((v)->getTag()==APPLICATION)
61 #define isMul(v) (isApp(v) && !strcmp(A(v)->n,"*"))
62 #define isSqr(v) (isApp(v) && !strcmp(A(v)->n,"sqr"))
65 constant * res = new constant (TAG_DOUBLE); res->d = val; return res;
66 #define defCon(def,val) \
67 constant * def = new constant (TAG_DOUBLE); def->d = val;
68 #define defRef(def,var) \
69 reference * def = new reference (); def->n = strdup (var);
70 #define retApp1(op,f0) \
71 application * res = new application (); res->n = strdup (op); \
72 res->nargs = 1; res->args = f0; res->args->setNext (NULL); return res;
73 #define defApp1(def,op,f0) \
74 application * def = new application (); def->n = strdup (op); \
75 def->nargs = 1; def->args = f0; def->args->setNext (NULL);
76 #define defApp2(def,op,f0,f1) \
77 application * def = new application (); def->n = strdup (op); \
78 def->nargs = 2; def->args = f0; def->args->append (f1);
79 #define retApp2(op,f0,f1) \
80 application * res = new application (); res->n = strdup (op); \
81 res->nargs = 2; res->args = f0; res->args->append (f1); return res;
82 #define retApp3(op,f0,f1,f2) \
83 application * res = new application (); res->n = strdup (op); \
84 res->nargs = 3; res->args = f0; res->args->append (f1); \
85 res->args->append (f2); return res;
86 #define defApp3(def,op,f0,f1,f2) \
87 application * def = new application (); def->n = strdup (op); \
88 def->nargs = 3; def->args = f0; def->args->append (f1); \
89 def->args->append (f2);
91 #define _A(idx) app->args->get(idx)
95 #define _D0 _A(0)->differentiate (derivative)
96 #define _D1 _A(1)->differentiate (derivative)
97 #define _D2 _A(2)->differentiate (derivative)
99 #define _AF0(var) node * var = _A0;
100 #define _AF1(var) node * var = _A1;
101 #define _AF2(var) node * var = _A2;
102 #define _AD0(var) node * var = _D0;
103 #define _AD1(var) node * var = _D1;
104 #define _AD2(var) node * var = _D2;
106 #define _AA(a,idx) A(a)->args->get(idx)
107 #define _AA0(a) _AA(a,0)
108 #define _AA1(a) _AA(a,1)
110 #define _AAF0(a,var) node * var = _AA0(a);
111 #define _AAF1(a,var) node * var = _AA1(a);
129 delete f0;
delete f1;
138 nr_double_t
t =
D(f0) +
D(f1);
139 delete f0;
delete f1;
165 nr_double_t
t = -
D(f0);
174 delete f0;
delete f1;
183 nr_double_t
t =
D(f0) -
D(f1);
184 delete f0;
delete f1;
206 delete f0;
delete f1;
208 }
else if (
isOne (f0)) {
211 }
else if (
isNeg (f0)) {
214 }
else if (
isOne (f1)) {
217 }
else if (
isNeg (f1)) {
221 nr_double_t
t =
D(f0) *
D(f1);
222 delete f0;
delete f1;
246 delete f0;
delete f1;
249 delete f0;
delete f1;
255 nr_double_t
t =
D(f0) /
D(f1);
256 delete f0;
delete f1;
258 }
else if (
isOne (f1)) {
261 }
else if (
isNeg (f1)) {
275 if (!strcmp (
R(f0)->
n,
R(g1)->
n)) {
316 delete f0;
delete f1;
319 delete f0;
delete f1;
323 delete f0;
delete f1;
327 delete f0;
delete f1;
329 }
else if (
isOne (f1)) {
395 delete d0;
delete f0;
405 return app_reduce (
"exp", d0, f0->recreate());
413 defApp2 (ask,
"<", f0->recreate(), lcon);
422 return app_reduce (
"cos", d0, f0->recreate());
477 return app_reduce (
"sign", d0, f0->recreate());
514 nr_double_t
t =
D(f0) *
D(f0);
578 return app_reduce (
"cosh", d0, f0->recreate());
584 return app_reduce (
"sinh", d0, f0->recreate());
674 if (
D(d1) ==
D(d2)) {
675 nr_double_t
t =
D(d1);
676 delete d1;
delete d2;
680 retApp3 (
"?:", f0->recreate(), d1, d2);
715 delete f0;
delete f1;
725 delete f0;
delete f1;
static node * sec(application *, char *)
#define defApp2(def, op, f0, f1)
static node * sqrt_reduce(node *)
static node * times(application *, char *)
static node * limexp(application *, char *)
static node * power_reduce(node *, node *)
static node * plus_reduce(node *, node *)
nr_complex_t pow(const nr_complex_t z, const nr_double_t d)
Compute power function with real exponent.
static node * over(application *, char *)
#define retApp3(op, f0, f1, f2)
static node * app_reduce(const char *, node *, node *)
static node * arcoth(application *, char *)
static node * times_reduce(node *, node *)
static node * sqr_reduce(node *)
Global physical constants header file.
static node * log2(application *, char *)
#define defApp1(def, op, f0)
static void over_reduce_adv(node *&, node *&)
static node * sqrt(application *, char *)
static node * square(application *, char *)
static node * sinc(application *, char *)
static node * abs(application *, char *)
static node * ln(application *, char *)
nr_complex_t sqr(const nr_complex_t z)
Square of complex number.
static node * cot(application *, char *)
static node * vt(application *, char *)
static node * sinh(application *, char *)
static node * plus_binary(application *, char *)
#define defApp3(def, op, f0, f1, f2)
static node * arcosech(application *, char *)
#define kBoverQ
Boltzmann constant over Elementary charge ( )
static node * tanh(application *, char *)
static node * sign(application *, char *)
static node * step(application *, char *)
static node * plus_unary(application *, char *)
static node * sin(application *, char *)
static node * xhypot(application *, char *)
static node * ln_reduce(node *)
static node * arcsin(application *, char *)
static node * norm(application *, char *)
#define retApp2(op, f0, f1)
Global math constants header file.
struct differentiation_t differentiations[]
static node * hypot_reduce(node *, node *)
static node * tan(application *, char *)
static node * arcosh(application *, char *)
static node * power(application *, char *)
static node * exp(application *, char *)
static node * minus_unary(application *, char *)
static node * arccos(application *, char *)
static node * minus_binary(application *, char *)
static node * over_reduce(node *, node *)
static node * arccosec(application *, char *)
static node * cosh(application *, char *)
virtual node * recreate(void)
static node * ifthenelse(application *, char *)
static node * arcsec(application *, char *)
static node * arccot(application *, char *)
static node * minus_reduce(node *, node *)
static node * log10(application *, char *)
static node * arctan(application *, char *)
static node * cosec(application *, char *)
static node * arsech(application *, char *)
static node * coth(application *, char *)
static node * arsinh(application *, char *)
static node * artanh(application *, char *)
static node * cos(application *, char *)