50 static char * zvr_vector_txt (
struct zvr_vector_t * vec) {
51 int i, i1 = -1, i2 = -1, off = 0, len = strlen (vec->
n1);
54 if (strstr (vec->
n1,
"re") == vec->
n1 ||
55 strstr (vec->
n1,
"im") == vec->
n1 ||
56 strstr (vec->
n1,
"db") == vec->
n1) {
60 else if (strstr (vec->
n1,
"mag") == vec->
n1 ||
61 strstr (vec->
n1,
"ang") == vec->
n1) {
64 for (i = off; i < len; i++)
if (!isalpha (vec->
n1[i]))
break;
67 if (isdigit (vec->
n1[i])) { i1 = vec->
n1[
i] -
'0'; vec->
n1[
i] =
'\0'; }
71 if (isdigit (vec->
n1[i])) { i2 = vec->
n1[
i] -
'0'; vec->
n1[
i] =
'\0'; }
74 if (i1 >= 0 && i2 >= 0) {
75 sprintf (txt,
"%s[%d,%d]", &vec->
n1[off], i1, i2);
78 sprintf (txt,
"%s[%d]", &vec->
n1[off], i1);
81 sprintf (txt,
"%s", &vec->
n1[off]);
87 static void zvr_finalize (
void) {
90 for (root = zvr_root; root; root =
next) {
97 for (rl = root->
d; rl; rl = nl) {
112 if (vec->
nf) free (vec->
nf);
113 if (vec->
n1) free (vec->
n1);
114 if (vec->
n2) free (vec->
n2);
122 static strlist * zvr_create_dep (
char *
n) {
129 static void zvr_check_dependencies (
void) {
135 for (equal =
true; depn != NULL; depn = (
vector *) depn->
getNext ()) {
141 if (depn->
get (
i) != dep1->
get (
i)) {
153 for (depn = (
vector *) dep1->
getNext (); depn != NULL; depn = ndep) {
162 char txt[64];
int i = 1;
165 while (depn != NULL && varn != NULL) {
166 sprintf (txt,
"%s.%d", depn->
getName (),
i);
177 static void zvr_conversion (
struct zvr_data_t * root) {
178 for (; root != NULL; root = root->
next) {
183 if (!strcmp (hdr->
d_FMT,
"COMPLEX") && !strcmp (hdr->
d_UNT,
"dB")) {
184 for (n = 0; n < var->
getSize (); n++) {
185 nr_double_t r =
real (var->
get (n));
186 nr_double_t i =
imag (var->
get (n));
191 else if (!strcmp (hdr->
d_FMT,
"MAGNITUDE") && !strcmp (hdr->
d_UNT,
"dB")) {
192 for (n = 0; n < var->
getSize (); n++) {
193 nr_double_t r =
real (var->
get (n));
194 var->
set (
pow (10.0, r / 20.0), n);
198 else if (!strcmp (hdr->
d_FMT,
"MA")) {
199 for (n = 0; n < var->
getSize (); n++) {
200 nr_double_t r =
real (var->
get (n));
201 nr_double_t i =
imag (var->
get (n));
206 else if (!strcmp (hdr->
d_FMT,
"DB")) {
207 for (n = 0; n < var->
getSize (); n++) {
208 nr_double_t r =
real (var->
get (n));
209 nr_double_t i =
imag (var->
get (n));
226 for (root = zvr_root; root; root = root->
next) {
231 vec->
vi->
add (line->d);
240 zvr_check_dependencies ();
243 zvr_conversion (zvr_root);
249 return errors ? -1 : 0;
254 if (zvr_result != NULL) {
259 if (zvr_root != NULL) {