47 #include "tokens_mdl.h"
59 for (
int i = 0;
i < data->getSize ();
i++) v.add (data->get (
i));
73 const char *
name,
const char *
type,
75 vector *
v =
new vector[dsize->
x * dsize->
y] ();
77 if (!strcmp (type,
"MEAS"))
79 else if (!strcmp (type,
"SIMU"))
81 else if (!strcmp (type,
"COMMON"))
85 int n = (p->y - 1) * 2 + p->x - 1;
89 for (
int x = 1;
x < dsize->
x + 1;
x++) {
90 for (
int y = 1;
y < dsize->
y + 1;
y++) {
92 int n = (
y - 1) * 2 +
x - 1;
93 char * txt = (
char *) malloc (strlen (name) + strlen (type) + 4 + 2 * 3);
94 if (dsize->
x > 1 || dsize->
y > 1)
95 sprintf (txt,
"%s%s[%d,%d]", name, type,
x,
y);
97 sprintf (txt,
"%s%s", name, type);
101 if (v[n].getSize () > 1) {
102 v[
n].setDependencies (
new strlist (*deps));
105 v[
n].setDependencies (
new strlist ());
116 for (; root != NULL; root = root->
next) {
117 if (!strcmp (root->
name, name))
return root->
value;
125 for (; root != NULL; root = root->
next) {
126 if (!strcmp (root->
name,
"Name") && !strcmp (root->
value, name)) {
127 if (root->
next && !strcmp (root->
next->
name,
"Value")) {
140 case 'K': f = 1e+03;
break;
141 case 'M': f = 1e+06;
break;
142 case 'G': f = 1e+09;
break;
143 case 'T': f = 1e+12;
break;
144 case 'm': f = 1e-03;
break;
145 case 'u': f = 1e-06;
break;
146 case 'n': f = 1e-09;
break;
147 case 'p': f = 1e-12;
break;
148 case 'f': f = 1e-15;
break;
149 case 'a': f = 1e-18;
break;
166 for (root = link->
content; !done && root != NULL; root = root->
next) {
167 if (root->
type == t_TABLE) {
176 if (!done && link->
parent) {
192 while (*t) { *t = *(t + 1); t++; }
198 val = strtod (txt, &end);
202 if (*txt ==
'-') { f = -1.0; txt++; }
203 else if (*txt ==
'+') { f = +1.0; txt++; }
206 if (!strcmp (txt,
"PI")) {
212 "checker error, unable to resolve `%s' variable in '%s'\n",
255 for (root = droot; root != NULL; root = root->
next) {
256 if (root->
type == t_DATASET) {
275 int nof = 0, order = 0;
276 valuelist<int> * deps =
new valuelist<int> ();
280 for (root = droot; root != NULL; root = root->
next) {
281 if (root->
type == t_HYPTABLE) {
284 if (!strcmp (hyptab->
name,
"Edit Sweep Def")) {
285 if (!strcmp (stype,
"LIN")) {
292 if (nof <= 0) nof = (
int) fabs ((stop - start) /
step) + 1;
293 deps->append (name,
new int (order));
294 linsweep * sw =
new linsweep ();
295 sw->create (start, stop, nof);
299 else if (!strcmp (stype,
"CON")) {
304 else if (!strcmp (stype,
"LOG")) {
312 if (start * stop == 0.0) {
313 if (start == 0.0) start = 1.0;
314 if (stop == 0.0) stop = 1.0;
316 deps->append (name,
new int (order));
317 logsweep * sw =
new logsweep ();
318 sw->create (start, stop, nof);
322 else if (!strcmp (stype,
"LIST")) {
326 deps->append (name,
new int (order));
328 else if (!strcmp (stype,
"SYNC")) {
336 sync->
name = strdup (name);
342 else if (!strcmp (hyptab->
name,
"Edit Sweep Info")) {
346 else if (!strcmp (hyptab->
name,
"List Table")) {
347 lstsweep * sw =
new lstsweep ();
350 for (
int i = 0;
i < nof;
i++) {
351 sprintf (txt,
"Value %d",
i + 1);
365 char * txt = (
char *) malloc (strlen (base) + 2 + strlen (name));
366 sprintf (txt,
"%s.%s", base, name);
372 valuelist<int> * deps) {
376 for (root = link->
content; root != NULL; root = root->
next) {
378 if (root->
type == t_DATA) {
386 else if (root->
type == t_LINK && !strcmp (root->
link->
type,
"SWEEP")) {
400 for (root = link->
content; root != NULL; root = root->
next) {
402 if (root->
type == t_DATA) {
406 else if (root->
type == t_LINK && (!strcmp (root->
link->
type,
"OUT") ||
407 !strcmp (root->
link->
type,
"XFORM"))) {
418 strlist * deps =
new strlist ();
419 for (
int i = 0;
i < d->length ();
i++) {
420 for (valuelistiterator<int> it (*d); *it; ++it) {
421 if (*(it.currentVal ()) ==
i + 1) {
422 deps->append (it.currentKey ());
434 valuelist<int> * vdeps =
new valuelist<int> ();
444 for (root = link->
content; root != NULL; root = root->
next) {
445 if (root->
type == t_LINK &&
447 strcmp (root->
link->
type,
"SWEEP") &&
448 strcmp (root->
link->
type,
"XFORM")) {
466 for (sync = root; sync != NULL; sync = sync->
next) {
469 int i = strlen (link) - 1;
470 while (i > 0 && link[i] !=
'.') i--;
471 if (link[i] ==
'.') {
473 char * txt = (
char *) malloc (i + 2 + strlen (sync->
master));
474 sprintf (txt,
"%s.%s", link, sync->
master);
482 vector *
s =
new vector ((*v) * sync->
ratio + sync->
offset);
506 for (e = h->
data; e != NULL; e = next) {
517 for (e = t->
data; e != NULL; e = next) {
528 for (p = d->
data1; p != NULL; p = next) {
533 for (p = d->
data2; p != NULL; p = next) {
551 for (c = d->
content; c != NULL; c = next) {
575 for (c = l->
content; c != NULL; c = next) {
584 for (; s != NULL; s =
next) {
597 for (
int i = 0;
i < deps->length ();
i++) {
598 if ((n = deps->get (
i)) != NULL)
600 res *= v->getSize ();
610 next = (vector *) v->getNext ();
611 strlist * deps = v->getDependencies ();
612 if (deps->length () <= 0) {
613 vector *
d =
new vector (*v);
625 deps = v->getDependencies ();
628 if (v->getSize () !=
s) {
630 for (
int i = 0;
i < deps->length ();
i++) {
632 char *
n = deps->get (
i);
635 if (d != NULL && v->getSize () == d->getSize ()) {
636 strlist * dep =
new strlist ();
638 v->setDependencies (dep);
645 if (!found) v->setDependencies (
new strlist ());
668 return errors ? -1 : 0;
void addDependency(qucs::vector *)
std::complex< nr_double_t > nr_complex_t
static int mdl_resolve_variable(struct mdl_link_t *link, char *name, double &val)
qucs::vector * getVariables(void)
static double mdl_telement_dvalue(struct mdl_link_t *, struct mdl_element_t *, const char *)
nr_complex_t step(const nr_complex_t z)
Heaviside step function for complex number.
static void mdl_find_deplink(struct mdl_link_t *link, char *name, valuelist< int > *deps)
static void mdl_free_datasize(struct mdl_datasize_t *d)
Global physical constants header file.
struct mdl_element_t * next
struct mdl_dcontent_t * next
static double mdl_helement_dvalue(struct mdl_link_t *link, struct mdl_element_t *eroot, const char *name)
struct mdl_sync_t * mdl_sync_root
static strlist * mdl_sort_deps(valuelist< int > *d)
static void mdl_create_syndataset(vector *v, char *name)
struct mdl_dcontent_t * content
void appendVariable(qucs::vector *)
struct mdl_element_t * data
static double mdl_convert_factor(char *end)
struct mdl_point_t * data2
struct mdl_link_t * parent
struct mdl_point_t * next
void mdl_find_syncdatasets(struct mdl_sync_t *root)
struct mdl_dataset_t * data
static void mdl_free_link(struct mdl_link_t *)
static int mdl_get_depsize(strlist *deps)
static void mdl_free_dcontent(struct mdl_dcontent_t *c)
static void mdl_create_depdataset(sweep *data, char *name)
static void mdl_free_sync(struct mdl_sync_t *s)
struct mdl_point_t * data1
struct mdl_hyptable_t * hyptable
void delVariable(qucs::vector *)
#define M_PI
Archimedes' constant ( )
static void mdl_free_table(struct mdl_table_t *t)
static void mdl_free_element(struct mdl_element_t *e)
static void mdl_check_xform_deplen(void)
void appendDependency(qucs::vector *)
static void mdl_find_link(struct mdl_link_t *link, char *name)
static double mdl_variable_value(struct mdl_link_t *link, char *txt)
static char * mdl_find_telement(struct mdl_element_t *root, const char *name)
static void mdl_free_lcontent(struct mdl_lcontent_t *c)
static void mdl_check_xforms(void)
static void mdl_free_dataset(struct mdl_dataset_t *d)
static void mdl_free_hyptable(struct mdl_hyptable_t *h)
static void mdl_find_vardataset(struct mdl_dcontent_t *droot, char *name, strlist *deps)
struct mdl_table_t * table
static void mdl_create_condataset(double val, char *name)
qucs::vector * findDependency(const char *)
struct mdl_link_t * mdl_root
struct mdl_element_t * data
static char * mdl_find_helement(struct mdl_element_t *root, const char *name)
struct mdl_lcontent_t * next
valuelist< int > * mdl_find_depdataset(struct mdl_link_t *link, struct mdl_dcontent_t *droot, char *name)
static void mdl_free_data(struct mdl_data_t *d)
void logprint(int level, const char *format,...)
struct mdl_lcontent_t * content
struct mdl_datasize_t * dsize
static void mdl_create_vardataset(struct mdl_point_t *point, struct mdl_datasize_t *dsize, const char *name, const char *type, strlist *deps)
static void mdl_find_varlink(struct mdl_link_t *link, char *name, strlist *deps)
static void mdl_check_xform_dep(void)
static int mdl_helement_ivalue(struct mdl_link_t *link, struct mdl_element_t *eroot, const char *name)
static char * mdl_create_linkname(char *base, char *name)