dvec abstraction, #8/11, upgrade `dvec_alloc()'
This commit is contained in:
parent
fdae9b7c06
commit
8243696338
|
|
@ -451,19 +451,18 @@ com_compose(wordlist *wl)
|
|||
}
|
||||
}
|
||||
|
||||
result = dvec_alloc();
|
||||
result->v_name = resname;
|
||||
result->v_type = type;
|
||||
|
||||
if (realflag) {
|
||||
result->v_flags = VF_REAL | VF_PERMANENT;
|
||||
result->v_realdata = data;
|
||||
result = dvec_alloc(resname,
|
||||
type,
|
||||
VF_REAL | VF_PERMANENT,
|
||||
length, data);
|
||||
} else {
|
||||
result->v_flags = VF_COMPLEX | VF_PERMANENT;
|
||||
result->v_compdata = cdata;
|
||||
result = dvec_alloc(resname,
|
||||
type,
|
||||
VF_COMPLEX | VF_PERMANENT,
|
||||
length, cdata);
|
||||
}
|
||||
|
||||
result->v_length = length;
|
||||
resname = NULL; /* resname storage has been consumed */
|
||||
|
||||
result->v_numdims = 1;
|
||||
|
|
|
|||
|
|
@ -128,12 +128,10 @@ com_fft(wordlist *wl)
|
|||
plot_cur->pl_name = copy("Spectrum");
|
||||
plot_cur->pl_date = copy(datestring());
|
||||
|
||||
f = dvec_alloc();
|
||||
f->v_name = copy("frequency");
|
||||
f->v_type = SV_FREQUENCY;
|
||||
f->v_flags = (VF_REAL | VF_PERMANENT | VF_PRINT);
|
||||
f->v_length = fpts;
|
||||
f->v_realdata = TMALLOC(double, fpts);
|
||||
f = dvec_alloc(copy("frequency"),
|
||||
SV_FREQUENCY,
|
||||
VF_REAL | VF_PERMANENT | VF_PRINT,
|
||||
fpts, NULL);
|
||||
vec_new(f);
|
||||
freq = f->v_realdata;
|
||||
|
||||
|
|
@ -148,12 +146,10 @@ com_fft(wordlist *wl)
|
|||
fdvec = TMALLOC(ngcomplex_t *, ngood);
|
||||
for (i = 0, vec = vlist; i<ngood; i++) {
|
||||
tdvec[i] = vec->v_realdata; /* real input data */
|
||||
f = dvec_alloc();
|
||||
f->v_name = vec_basename(vec);
|
||||
f->v_type = SV_NOTYPE;
|
||||
f->v_flags = (VF_COMPLEX | VF_PERMANENT);
|
||||
f->v_length = fpts;
|
||||
f->v_compdata = TMALLOC(ngcomplex_t, fpts);
|
||||
f = dvec_alloc(vec_basename(vec),
|
||||
SV_NOTYPE,
|
||||
VF_COMPLEX | VF_PERMANENT,
|
||||
fpts, NULL);
|
||||
vec_new(f);
|
||||
fdvec[i] = f->v_compdata; /* complex output data */
|
||||
vec = vec->v_link2;
|
||||
|
|
@ -352,12 +348,10 @@ com_psd(wordlist *wl)
|
|||
plot_cur->pl_name = copy("PSD");
|
||||
plot_cur->pl_date = copy(datestring());
|
||||
|
||||
f = dvec_alloc();
|
||||
f->v_name = copy("frequency");
|
||||
f->v_type = SV_FREQUENCY;
|
||||
f->v_flags = (VF_REAL | VF_PERMANENT | VF_PRINT);
|
||||
f->v_length = fpts;
|
||||
f->v_realdata = TMALLOC(double, fpts);
|
||||
f = dvec_alloc(copy("frequency"),
|
||||
SV_FREQUENCY,
|
||||
VF_REAL | VF_PERMANENT | VF_PRINT,
|
||||
fpts, NULL);
|
||||
vec_new(f);
|
||||
freq = f->v_realdata;
|
||||
|
||||
|
|
@ -373,12 +367,10 @@ com_psd(wordlist *wl)
|
|||
fdvec = TMALLOC(ngcomplex_t*, ngood);
|
||||
for (i = 0, vec = vlist; i<ngood; i++) {
|
||||
tdvec[i] = vec->v_realdata; /* real input data */
|
||||
f = dvec_alloc();
|
||||
f->v_name = vec_basename(vec);
|
||||
f->v_type = SV_NOTYPE; //vec->v_type;
|
||||
f->v_flags = (VF_COMPLEX | VF_PERMANENT);
|
||||
f->v_length = fpts;
|
||||
f->v_compdata = TMALLOC(ngcomplex_t, fpts);
|
||||
f = dvec_alloc(vec_basename(vec),
|
||||
SV_NOTYPE, //vec->v_type
|
||||
VF_COMPLEX | VF_PERMANENT,
|
||||
fpts, NULL);
|
||||
vec_new(f);
|
||||
fdvec[i] = f->v_compdata; /* complex output data */
|
||||
vec = vec->v_link2;
|
||||
|
|
|
|||
|
|
@ -161,15 +161,10 @@ com_let(wordlist *wl)
|
|||
}
|
||||
|
||||
/* create and assign a new vector */
|
||||
n = dvec_alloc();
|
||||
n->v_name = copy(p);
|
||||
n->v_type = t->v_type;
|
||||
n->v_flags = (t->v_flags | VF_PERMANENT);
|
||||
n->v_length = t->v_length;
|
||||
if (isreal(t))
|
||||
n->v_realdata = TMALLOC(double, n->v_length);
|
||||
else
|
||||
n->v_compdata = TMALLOC(ngcomplex_t, n->v_length);
|
||||
n = dvec_alloc(copy(p),
|
||||
t->v_type,
|
||||
t->v_flags | VF_PERMANENT,
|
||||
t->v_length, NULL);
|
||||
|
||||
if ((t->v_numdims) <= 1) { // changed from "!t->v_numdims" by Friedrich Schmidt
|
||||
n->v_numdims = 1;
|
||||
|
|
|
|||
|
|
@ -161,15 +161,10 @@ savetree(struct pnode *pn)
|
|||
*/
|
||||
d = pn->pn_value;
|
||||
if ((d->v_length != 0) || eq(d->v_name, "list")) {
|
||||
pn->pn_value = dvec_alloc();
|
||||
pn->pn_value->v_name = copy(d->v_name);
|
||||
pn->pn_value->v_length = d->v_length;
|
||||
pn->pn_value->v_type = d->v_type;
|
||||
pn->pn_value->v_flags = d->v_flags;
|
||||
if (isreal(d))
|
||||
pn->pn_value->v_realdata = TMALLOC(double, d->v_length);
|
||||
else
|
||||
pn->pn_value->v_compdata = TMALLOC(ngcomplex_t, d->v_length);
|
||||
pn->pn_value = dvec_alloc(copy(d->v_name),
|
||||
d->v_type,
|
||||
d->v_flags,
|
||||
d->v_length, NULL);
|
||||
|
||||
/* this dvec isn't member of any plot */
|
||||
|
||||
|
|
|
|||
|
|
@ -1317,16 +1317,13 @@ com_alter_common(wordlist *wl, int do_model)
|
|||
return;
|
||||
}
|
||||
|
||||
dv = dvec_alloc();
|
||||
dv = dvec_alloc(copy("real vector"),
|
||||
SV_NOTYPE,
|
||||
VF_REAL,
|
||||
i, list);
|
||||
if (!dv)
|
||||
return;
|
||||
|
||||
dv->v_name = copy("real vector");
|
||||
dv->v_type = SV_NOTYPE;
|
||||
dv->v_flags = VF_REAL;
|
||||
dv->v_realdata = list;
|
||||
dv->v_length = i;
|
||||
|
||||
/* Here I was, to change the inclusion in the circuit.
|
||||
* will have to revise that dv is right for its insertion.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
|
||||
struct dvec *
|
||||
dvec_alloc(void)
|
||||
dvec_alloc(char *name, int type, short flags, int length, void *storage)
|
||||
{
|
||||
struct dvec *rv = TMALLOC(struct dvec, 1);
|
||||
|
||||
|
|
@ -12,6 +12,26 @@ dvec_alloc(void)
|
|||
|
||||
ZERO(rv, struct dvec);
|
||||
|
||||
rv->v_name = name;
|
||||
rv->v_type = type;
|
||||
rv->v_flags = flags;
|
||||
rv->v_length = length;
|
||||
|
||||
if (!length) {
|
||||
rv->v_realdata = NULL;
|
||||
rv->v_compdata = NULL;
|
||||
} else if (flags & VF_REAL) {
|
||||
rv->v_realdata = storage
|
||||
? (double *) storage
|
||||
: TMALLOC(double, length);
|
||||
rv->v_compdata = NULL;
|
||||
} else if (flags & VF_COMPLEX) {
|
||||
rv->v_realdata = NULL;
|
||||
rv->v_compdata = storage
|
||||
? (ngcomplex_t *) storage
|
||||
: TMALLOC(ngcomplex_t, length);
|
||||
}
|
||||
|
||||
rv->v_plot = NULL;
|
||||
rv->v_scale = NULL;
|
||||
rv->v_numdims = 0;
|
||||
|
|
|
|||
|
|
@ -318,22 +318,18 @@ doop(char what,
|
|||
if (!data)
|
||||
return (NULL);
|
||||
/* Make up the new vector. */
|
||||
res = dvec_alloc();
|
||||
if (relflag || (isreal(v1) && isreal(v2) && (func != cx_comma))) {
|
||||
res->v_type = SV_NOTYPE;
|
||||
res->v_flags = (v1->v_flags | v2->v_flags |
|
||||
VF_REAL) & ~ VF_COMPLEX;
|
||||
res->v_realdata = (double *) data;
|
||||
res = dvec_alloc(mkcname(what, v1->v_name, v2->v_name),
|
||||
SV_NOTYPE,
|
||||
(v1->v_flags | v2->v_flags | VF_REAL) & ~VF_COMPLEX,
|
||||
length, data);
|
||||
} else {
|
||||
res->v_type = SV_NOTYPE;
|
||||
res->v_flags = (v1->v_flags | v2->v_flags |
|
||||
VF_COMPLEX) & ~ VF_REAL;
|
||||
res->v_compdata = (ngcomplex_t *) data;
|
||||
res = dvec_alloc(mkcname(what, v1->v_name, v2->v_name),
|
||||
SV_NOTYPE,
|
||||
(v1->v_flags | v2->v_flags | VF_COMPLEX) & ~VF_REAL,
|
||||
length, data);
|
||||
}
|
||||
|
||||
res->v_name = mkcname(what, v1->v_name, v2->v_name);
|
||||
res->v_length = length;
|
||||
|
||||
/* This is a non-obvious thing */
|
||||
if (v1->v_scale != v2->v_scale) {
|
||||
fprintf(cp_err, "Warning: scales of %s and %s are different.\n",
|
||||
|
|
@ -614,15 +610,10 @@ op_range(struct pnode *arg1, struct pnode *arg2)
|
|||
len++;
|
||||
}
|
||||
|
||||
res = dvec_alloc();
|
||||
res->v_name = mkcname('R', v->v_name, ind->v_name);
|
||||
res->v_type = v->v_type;
|
||||
res->v_flags = v->v_flags;
|
||||
res->v_length = len;
|
||||
if (isreal(res))
|
||||
res->v_realdata = TMALLOC(double, len);
|
||||
else
|
||||
res->v_compdata = TMALLOC(ngcomplex_t, len);
|
||||
res = dvec_alloc(mkcname('R', v->v_name, ind->v_name),
|
||||
v->v_type,
|
||||
v->v_flags,
|
||||
len, NULL);
|
||||
|
||||
res->v_gridtype = v->v_gridtype;
|
||||
res->v_plottype = v->v_plottype;
|
||||
|
|
@ -769,15 +760,10 @@ op_ind(struct pnode *arg1, struct pnode *arg2)
|
|||
length = blocksize * (up - down + 1);
|
||||
|
||||
/* Make up the new vector. */
|
||||
res = dvec_alloc();
|
||||
res->v_name = mkcname('[', v->v_name, ind->v_name);
|
||||
res->v_type = v->v_type;
|
||||
res->v_flags = v->v_flags;
|
||||
res->v_length = length;
|
||||
if (isreal(res))
|
||||
res->v_realdata = TMALLOC(double, length);
|
||||
else
|
||||
res->v_compdata = TMALLOC(ngcomplex_t, length);
|
||||
res = dvec_alloc(mkcname('[', v->v_name, ind->v_name),
|
||||
v->v_type,
|
||||
v->v_flags,
|
||||
length, NULL);
|
||||
|
||||
res->v_defcolor = v->v_defcolor;
|
||||
res->v_gridtype = v->v_gridtype;
|
||||
|
|
@ -938,19 +924,12 @@ apply_func(struct func *func, struct pnode *arg)
|
|||
else
|
||||
name = mkcname('b', v->v_name, NULL);
|
||||
|
||||
t = dvec_alloc();
|
||||
t->v_name = name;
|
||||
t = dvec_alloc(name,
|
||||
v->v_type, /* This is strange too. */
|
||||
(v->v_flags & ~VF_COMPLEX & ~VF_REAL &
|
||||
~VF_PERMANENT & ~VF_MINGIVEN & ~VF_MAXGIVEN) | type,
|
||||
len, data);
|
||||
|
||||
t->v_flags = (v->v_flags & ~VF_COMPLEX & ~VF_REAL &
|
||||
~VF_PERMANENT & ~VF_MINGIVEN & ~VF_MAXGIVEN);
|
||||
t->v_flags |= type;
|
||||
if (isreal(t))
|
||||
t->v_realdata = (double *) data;
|
||||
else
|
||||
t->v_compdata = (ngcomplex_t *) data;
|
||||
|
||||
t->v_type = v->v_type; /* This is strange too. */
|
||||
t->v_length = len;
|
||||
t->v_scale = v->v_scale;
|
||||
|
||||
/* Copy a few useful things */
|
||||
|
|
|
|||
|
|
@ -192,13 +192,10 @@ fourier(wordlist *wl, struct plot *current_plot)
|
|||
/* create and assign a new vector n */
|
||||
/* with size 3 * nfreqs in current plot */
|
||||
/* generate name for new vector, using vec->name */
|
||||
n = dvec_alloc();
|
||||
|
||||
n->v_name = tprintf("fourier%d%d", callstof, newveccount);
|
||||
n->v_type = SV_NOTYPE;
|
||||
n->v_flags = (VF_REAL | VF_PERMANENT);
|
||||
n->v_length = 3 * nfreqs;
|
||||
n->v_realdata = TMALLOC(double, n->v_length);
|
||||
n = dvec_alloc(tprintf("fourier%d%d", callstof, newveccount),
|
||||
SV_NOTYPE,
|
||||
VF_REAL | VF_PERMANENT,
|
||||
3 * nfreqs, NULL);
|
||||
|
||||
n->v_numdims = 2;
|
||||
n->v_dims[0] = 3;
|
||||
|
|
|
|||
|
|
@ -30,13 +30,10 @@ lincopy(struct dvec *ov, double *newscale, int newlen, struct dvec *oldscale)
|
|||
return;
|
||||
}
|
||||
|
||||
v = dvec_alloc();
|
||||
v->v_name = copy(ov->v_name);
|
||||
v->v_type = ov->v_type;
|
||||
v->v_flags = ov->v_flags;
|
||||
v->v_flags |= VF_PERMANENT;
|
||||
v->v_length = newlen;
|
||||
v->v_realdata = TMALLOC(double, newlen);
|
||||
v = dvec_alloc(copy(ov->v_name),
|
||||
ov->v_type,
|
||||
ov->v_flags | VF_PERMANENT,
|
||||
newlen, NULL);
|
||||
|
||||
nd = v->v_realdata;
|
||||
if (!ft_interpolate(ov->v_realdata, nd, oldscale->v_realdata,
|
||||
|
|
|
|||
|
|
@ -62,14 +62,12 @@ com_linearize(wordlist *wl)
|
|||
plot_setcur(new->pl_typename);
|
||||
plot_list = new;
|
||||
len = (int)((tstop - tstart) / tstep + 1.5);
|
||||
newtime = dvec_alloc();
|
||||
newtime->v_name = copy(oldtime->v_name);
|
||||
newtime->v_type = oldtime->v_type;
|
||||
newtime->v_flags = oldtime->v_flags;
|
||||
newtime->v_flags |= VF_PERMANENT;
|
||||
newtime->v_length = len;
|
||||
newtime = dvec_alloc(copy(oldtime->v_name),
|
||||
oldtime->v_type,
|
||||
oldtime->v_flags | VF_PERMANENT,
|
||||
len, NULL);
|
||||
|
||||
newtime->v_plot = new;
|
||||
newtime->v_realdata = TMALLOC(double, len);
|
||||
for (i = 0, d = tstart; i < len; i++, d += tstep)
|
||||
newtime->v_realdata[i] = d;
|
||||
new->pl_scale = new->pl_dvecs = newtime;
|
||||
|
|
|
|||
|
|
@ -1031,20 +1031,12 @@ plotInit(runDesc *run)
|
|||
else
|
||||
name = copy(dd->name);
|
||||
|
||||
v = dvec_alloc();
|
||||
v->v_name = name;
|
||||
v->v_type = guess_type(name);
|
||||
|
||||
v->v_length = 0;
|
||||
if (!run->isComplex) {
|
||||
v->v_flags = VF_REAL;
|
||||
v->v_realdata = NULL;
|
||||
} else {
|
||||
v->v_flags = VF_COMPLEX;
|
||||
v->v_compdata = NULL;
|
||||
}
|
||||
|
||||
v->v_flags |= VF_PERMANENT;
|
||||
v = dvec_alloc(name,
|
||||
guess_type(name),
|
||||
run->isComplex
|
||||
? (VF_COMPLEX | VF_PERMANENT)
|
||||
: (VF_REAL | VF_PERMANENT),
|
||||
0, NULL);
|
||||
|
||||
vec_new(v);
|
||||
dd->vec = v;
|
||||
|
|
|
|||
|
|
@ -330,20 +330,16 @@ PP_mknnode(double number)
|
|||
struct pnode *p;
|
||||
struct dvec *v;
|
||||
|
||||
v = dvec_alloc();
|
||||
|
||||
/* We don't use printnum because it screws up PP_mkfnode above. We have
|
||||
* to be careful to deal properly with node numbers that are quite
|
||||
* large...
|
||||
*/
|
||||
if (number < MAXPOSINT)
|
||||
v->v_name = tprintf("%d", (int) number);
|
||||
else
|
||||
v->v_name = tprintf("%G", number);
|
||||
v->v_type = SV_NOTYPE;
|
||||
v->v_flags = VF_REAL;
|
||||
v->v_realdata = TMALLOC(double, 1);
|
||||
v->v_length = 1;
|
||||
v = dvec_alloc(number < MAXPOSINT
|
||||
? tprintf("%d", (int) number)
|
||||
: tprintf("%G", number),
|
||||
SV_NOTYPE,
|
||||
VF_REAL,
|
||||
1, NULL);
|
||||
|
||||
v->v_realdata[0] = number;
|
||||
|
||||
|
|
@ -366,8 +362,10 @@ PP_mksnode(const char *string)
|
|||
p = alloc_pnode();
|
||||
v = vec_get(string);
|
||||
if (v == NULL) {
|
||||
nv = dvec_alloc();
|
||||
nv->v_name = copy(string);
|
||||
nv = dvec_alloc(copy(string),
|
||||
SV_NOTYPE,
|
||||
0,
|
||||
0, NULL);
|
||||
p->pn_value = nv;
|
||||
return (p);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -916,15 +916,13 @@ plotit(wordlist *wl, char *hcopy, char *devname)
|
|||
|
||||
double *newscale;
|
||||
|
||||
struct dvec *newv_scale = dvec_alloc();
|
||||
struct dvec *v;
|
||||
struct dvec *v, *newv_scale =
|
||||
dvec_alloc(copy(vecs->v_scale->v_name),
|
||||
vecs->v_scale->v_type,
|
||||
vecs->v_scale->v_flags,
|
||||
newlen, NULL);
|
||||
|
||||
newv_scale->v_name = copy(vecs->v_scale->v_name);
|
||||
newv_scale->v_flags = vecs->v_scale->v_flags;
|
||||
newv_scale->v_type = vecs->v_scale->v_type;
|
||||
newv_scale->v_gridtype = vecs->v_scale->v_gridtype;
|
||||
newv_scale->v_length = newlen;
|
||||
newv_scale->v_realdata = TMALLOC(double, newlen);
|
||||
|
||||
newscale = newv_scale->v_realdata;
|
||||
for (i = 0, ttime = tstart; i < newlen; i++, ttime += tstep)
|
||||
|
|
|
|||
|
|
@ -764,18 +764,14 @@ com_cross(wordlist *wl)
|
|||
}
|
||||
|
||||
vec_remove(newvec);
|
||||
v = dvec_alloc();
|
||||
v->v_name = copy(newvec);
|
||||
v->v_type = vecs ? vecs->v_type : SV_NOTYPE;
|
||||
v->v_length = i;
|
||||
|
||||
if (comp) {
|
||||
v->v_flags = VF_COMPLEX | VF_PERMANENT;
|
||||
v->v_compdata = TMALLOC(ngcomplex_t, i);
|
||||
} else {
|
||||
v->v_flags = VF_REAL | VF_PERMANENT;
|
||||
v->v_realdata = TMALLOC(double, i);
|
||||
}
|
||||
v = dvec_alloc(copy(newvec),
|
||||
vecs
|
||||
? vecs->v_type
|
||||
: SV_NOTYPE,
|
||||
comp
|
||||
? (VF_COMPLEX | VF_PERMANENT)
|
||||
: (VF_REAL | VF_PERMANENT),
|
||||
i, NULL);
|
||||
|
||||
/* Now copy the ind'ths elements into this one. */
|
||||
for (n = vecs, i = 0; n; n = n->v_link2, i++)
|
||||
|
|
|
|||
|
|
@ -468,14 +468,9 @@ raw_read(char *name) {
|
|||
* the desired vector length, but this would
|
||||
* be dangerous if the file is invalid.
|
||||
*/
|
||||
v = dvec_alloc();
|
||||
v->v_type = SV_NOTYPE;
|
||||
v->v_flags = (short)flags;
|
||||
v->v_length = npoints;
|
||||
if (isreal(v))
|
||||
v->v_realdata = TMALLOC(double, npoints);
|
||||
else
|
||||
v->v_compdata = TMALLOC(ngcomplex_t, npoints);
|
||||
v = dvec_alloc(NULL,
|
||||
SV_NOTYPE, (short) flags,
|
||||
npoints, NULL);
|
||||
/* Length and dims might be changed by options. */
|
||||
|
||||
v->v_plot = curpl;
|
||||
|
|
|
|||
|
|
@ -207,12 +207,10 @@ com_spec(wordlist *wl)
|
|||
plot_cur->pl_name = copy("Spectrum");
|
||||
plot_cur->pl_date = copy(datestring());
|
||||
|
||||
f = dvec_alloc();
|
||||
f->v_name = copy("frequency");
|
||||
f->v_type = SV_FREQUENCY;
|
||||
f->v_flags = (VF_REAL | VF_PERMANENT | VF_PRINT);
|
||||
f->v_length = fpts;
|
||||
f->v_realdata = TMALLOC(double, fpts);
|
||||
f = dvec_alloc(copy("frequency"),
|
||||
SV_FREQUENCY,
|
||||
VF_REAL | VF_PERMANENT | VF_PRINT,
|
||||
fpts, NULL);
|
||||
vec_new(f);
|
||||
freq = f->v_realdata;
|
||||
|
||||
|
|
@ -220,12 +218,10 @@ com_spec(wordlist *wl)
|
|||
fdvec = TMALLOC(ngcomplex_t *, ngood);
|
||||
for (i = 0, vec = vlist; i < ngood; i++) {
|
||||
tdvec[i] = vec->v_realdata;
|
||||
f = dvec_alloc();
|
||||
f->v_name = vec_basename(vec);
|
||||
f->v_type = vec->v_type;
|
||||
f->v_flags = (VF_COMPLEX | VF_PERMANENT);
|
||||
f->v_length = fpts;
|
||||
f->v_compdata = TMALLOC(ngcomplex_t, fpts);
|
||||
f = dvec_alloc(vec_basename(vec),
|
||||
vec->v_type,
|
||||
VF_COMPLEX | VF_PERMANENT,
|
||||
fpts, NULL);
|
||||
vec_new(f);
|
||||
fdvec[i] = f->v_compdata;
|
||||
vec = vec->v_link2;
|
||||
|
|
@ -279,12 +275,10 @@ com_spec(wordlist *wl)
|
|||
fprintf(cp_err, " \r");
|
||||
|
||||
#ifdef KEEPWINDOW
|
||||
f = dvec_alloc();
|
||||
f->v_name = copy("win");
|
||||
f->v_type = SV_NOTYPE;
|
||||
f->v_flags = (VF_REAL | VF_PERMANENT);
|
||||
f->v_length = tlen;
|
||||
f->v_realdata = win;
|
||||
f = dvec_alloc(copy("win"),
|
||||
SV_NOTYPE,
|
||||
VF_REAL | VF_PERMANENT,
|
||||
tlen, win);
|
||||
win = NULL;
|
||||
vec_new(f);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -522,12 +522,10 @@ vec_get(const char *vec_name)
|
|||
return (NULL);
|
||||
}
|
||||
|
||||
d = dvec_alloc();
|
||||
d->v_name = copy(whole); /* MW. The same as word before */
|
||||
d->v_type = SV_NOTYPE;
|
||||
d->v_flags |= VF_REAL; /* No complex values yet... */
|
||||
d->v_realdata = TMALLOC(double, 1);
|
||||
d->v_length = 1;
|
||||
d = dvec_alloc(copy(whole), /* MW. The same as word before */
|
||||
SV_NOTYPE,
|
||||
VF_REAL, /* No complex values yet... */
|
||||
1, NULL);
|
||||
|
||||
/* In case the represented variable is a REAL vector this takes
|
||||
* the actual value of the first element of the linked list which
|
||||
|
|
@ -684,19 +682,10 @@ vec_copy(struct dvec *v)
|
|||
if (!v)
|
||||
return (NULL);
|
||||
|
||||
nv = dvec_alloc();
|
||||
nv->v_name = copy(v->v_name);
|
||||
nv->v_type = v->v_type;
|
||||
nv->v_flags = v->v_flags & ~VF_PERMANENT;
|
||||
|
||||
nv->v_length = v->v_length;
|
||||
if (isreal(v)) {
|
||||
nv->v_realdata = TMALLOC(double, v->v_length);
|
||||
nv->v_compdata = NULL;
|
||||
} else {
|
||||
nv->v_realdata = NULL;
|
||||
nv->v_compdata = TMALLOC(ngcomplex_t, v->v_length);
|
||||
}
|
||||
nv = dvec_alloc(copy(v->v_name),
|
||||
v->v_type,
|
||||
v->v_flags & ~VF_PERMANENT,
|
||||
v->v_length, NULL);
|
||||
|
||||
if (isreal(v))
|
||||
bcopy(v->v_realdata, nv->v_realdata,
|
||||
|
|
@ -1121,16 +1110,10 @@ vec_mkfamily(struct dvec *v)
|
|||
|
||||
indexstring(count, v->v_numdims - 1, buf2);
|
||||
|
||||
d = dvec_alloc();
|
||||
|
||||
d->v_name = tprintf("%s%s", v->v_name, buf2);
|
||||
d->v_type = v->v_type;
|
||||
d->v_flags = v->v_flags;
|
||||
d->v_length = size;
|
||||
if (isreal(v))
|
||||
d->v_realdata = TMALLOC(double, size);
|
||||
else
|
||||
d->v_compdata = TMALLOC(ngcomplex_t, size);
|
||||
d = dvec_alloc(tprintf("%s%s", v->v_name, buf2),
|
||||
v->v_type,
|
||||
v->v_flags,
|
||||
size, NULL);
|
||||
|
||||
d->v_minsignal = v->v_minsignal;
|
||||
d->v_maxsignal = v->v_maxsignal;
|
||||
|
|
|
|||
|
|
@ -68,6 +68,6 @@ struct dveclist {
|
|||
struct dveclist *next;
|
||||
};
|
||||
|
||||
struct dvec *dvec_alloc(void);
|
||||
struct dvec *dvec_alloc(char *name, int type, short flags, int length, void *storage);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -626,12 +626,10 @@ cx_fft(void *data, short int type, int length, int *newlength, short int *newtyp
|
|||
goto done;
|
||||
|
||||
/* create a new scale vector */
|
||||
sv = dvec_alloc();
|
||||
sv->v_name = copy("fft_scale");
|
||||
sv->v_type = SV_FREQUENCY;
|
||||
sv->v_flags = (VF_REAL | VF_PERMANENT | VF_PRINT);
|
||||
sv->v_length = fpts;
|
||||
sv->v_realdata = xscale;
|
||||
sv = dvec_alloc(copy("fft_scale"),
|
||||
SV_FREQUENCY,
|
||||
VF_REAL | VF_PERMANENT | VF_PRINT,
|
||||
fpts, xscale);
|
||||
vec_new(sv);
|
||||
|
||||
if (type == VF_COMPLEX) { /* input vector is complex */
|
||||
|
|
@ -862,12 +860,10 @@ cx_ifft(void *data, short int type, int length, int *newlength, short int *newty
|
|||
span = xscale[tpts-1] - xscale[0];
|
||||
|
||||
/* create a new scale vector */
|
||||
sv = dvec_alloc();
|
||||
sv->v_name = copy("ifft_scale");
|
||||
sv->v_type = SV_TIME;
|
||||
sv->v_flags = (VF_REAL | VF_PERMANENT | VF_PRINT);
|
||||
sv->v_length = tpts;
|
||||
sv->v_realdata = xscale;
|
||||
sv = dvec_alloc(copy("ifft_scale"),
|
||||
SV_TIME,
|
||||
VF_REAL | VF_PERMANENT | VF_PRINT,
|
||||
tpts, xscale);
|
||||
vec_new(sv);
|
||||
|
||||
*newtype = VF_COMPLEX;
|
||||
|
|
|
|||
|
|
@ -114,7 +114,9 @@ oldread(char *name)
|
|||
fprintf(cp_err, "Warning: magic number 4 is wrong...\n");
|
||||
|
||||
for (i = 0; i < nv; i++) {
|
||||
v = dvec_alloc();
|
||||
v = dvec_alloc(NULL,
|
||||
SV_NOTYPE, 0,
|
||||
0, NULL);
|
||||
if (end)
|
||||
end->v_next = v;
|
||||
else
|
||||
|
|
|
|||
|
|
@ -187,21 +187,16 @@ struct dvec *EVTfindvec(
|
|||
/* Allocate dvec structures and assign the vectors into them. */
|
||||
/* See FTE/OUTinterface.c:plotInit() for initialization example. */
|
||||
|
||||
scale = dvec_alloc();
|
||||
scale = dvec_alloc(MIFcopy("step"),
|
||||
SV_TIME,
|
||||
VF_REAL & ~VF_PERMANENT,
|
||||
i, anal_point_vec);
|
||||
|
||||
scale->v_name = MIFcopy("step");
|
||||
scale->v_type = SV_TIME;
|
||||
scale->v_flags = VF_REAL & ~VF_PERMANENT;
|
||||
scale->v_length = i;
|
||||
scale->v_realdata = anal_point_vec;
|
||||
d = dvec_alloc(name,
|
||||
SV_VOLTAGE,
|
||||
VF_REAL & ~VF_PERMANENT,
|
||||
i, value_vec);
|
||||
|
||||
d = dvec_alloc();
|
||||
|
||||
d->v_name = name;
|
||||
d->v_type = SV_VOLTAGE;
|
||||
d->v_flags = VF_REAL & ~VF_PERMANENT;
|
||||
d->v_length = i;
|
||||
d->v_realdata = value_vec;
|
||||
d->v_scale = scale;
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue