39 setVariableSized (
true);
45 if (peqn) free (peqn);
55 if (!strcmp (dc,
"short")) {
66 else if (!strcmp (dc,
"open")) {
72 else if (!strcmp (dc,
"zerofrequency")) {
86 #define A(a) ((assignment *) (a))
89 char * rfedd::createVariable (
const char * base,
int r,
int c,
bool pfx) {
95 char * txt = (
char *) malloc (strlen (str) + strlen (base) + 4);
97 sprintf (txt,
"%s.%s%d%d", str, base, r, c);
99 sprintf (txt,
"%s%d%d", base, r, c);
104 char * rfedd::createVariable (
const char * base,
bool pfx) {
110 char * txt = (
char *) malloc (strlen (str) + strlen (base) + 2);
112 sprintf (txt,
"%s.%s", str, base);
114 sprintf (txt,
"%s", base);
119 void rfedd::setResult (
void *
eqn, nr_double_t val) {
121 constant *
c =
A(eqn)->getResult ();
128 constant * c =
A(eqn)->getResult ();
135 return A(eqn)->getResultComplex ();
139 void rfedd::initModel (
void) {
141 char *
type, * pn, * sn, * snold, * fn, * fnold, * vr;
145 peqn = (
void **) malloc (
sizeof (assignment *) * ports * ports);
148 sn = createVariable (
"S");
149 snold = createVariable (
"S",
false);
150 fn = createVariable (
"F");
151 fnold = createVariable (
"F",
false);
154 A(seqn)->evalType ();
A(seqn)->skip = 1;
155 A(feqn)->evalType ();
A(feqn)->skip = 1;
161 for (k = 0, i = 0; i < ports; i++) {
162 for (j = 0; j < ports; j++, k++) {
164 pn = createVariable (
"P", i + 1, j + 1,
false);
169 "RFEDD `%s'\n", type, vr,
getName ());
176 A(pvalue)->evalType ();
185 free (sn); free (snold);
186 free (fn); free (fnold);
190 void rfedd::prepareModel (
void) {
191 if (peqn == NULL) initModel ();
195 void rfedd::updateLocals (nr_double_t frequency) {
198 setResult (seqn,
rect (0, 2 *
M_PI * frequency));
199 setResult (feqn, frequency);
211 void rfedd::initMNA (
void) {
222 for (i = 0; i < ports; i++)
setC (i, i, -1);
223 for (i = 0; i < ports; i++)
setB (i, i, +1);
228 for (i = 0; i < ports; i++)
setB (i, i, +1);
255 void rfedd::calcMNA (nr_double_t frequency) {
258 matrix p = calcMatrix (frequency);
264 for (r = 0; r < ports; r++)
265 for (c = 0; c < ports; c++)
266 setD (r, c, p (r, c));
269 for (r = 0; r < ports; r++)
270 for (c = 0; c < ports; c++) {
272 setC (r, c, p (r, c) - 1.0);
273 setD (r, c,
z0 * (p (r, c) + 1.0));
276 setC (r, c, p (r, c));
277 setD (r, c,
z0 * p (r, c));
282 setY (1, 1, p (1, 1));
setB (1, 0, p (1, 0));
283 setC (0, 1, p (0, 1));
setD (0, 0, p (0, 0));
286 setY (0, 0, p (0, 0));
setB (0, 0, p (0, 1));
287 setC (0, 0, p (1, 0));
setD (0, 0, p (1, 1));
290 setY (0, 1, p (1, 0));
setB (0, 0, p (1, 1));
291 setC (0, 1, p (0, 0));
setD (0, 0, p (0, 1));
294 setC (0, 1, p (0, 1) + p (0, 0));
295 setC (1, 1, p (1, 1) + p (1, 0));
298 setD (0, 1,
z0 * (p (0, 1) - p (0, 0)));
299 setD (1, 1,
z0 * (p (1, 1) - p (1, 0)));
316 matrix rfedd::calcMatrix (nr_double_t frequency) {
321 updateLocals (frequency);
324 for (k = 0, i = 0; i < ports; i++) {
325 for (j = 0; j < ports; j++, k++) {
326 p (i, j) = getResult (peqn[k]);
352 matrix p = calcMatrix (frequency);
383 PROP_RNG_STR4 (
"open",
"short",
"unspecified",
"zerofrequency") },