1 #ifndef ngspice_DVEC_H
2 #define ngspice_DVEC_H
3 
4 #include "ngspice/bool.h"
5 #include "ngspice/complex.h"
6 #include "ngspice/grid.h"
7 #include "ngspice/sim.h"
8 
9 
10 /* Dvec flags. */
11 enum dvec_flags {
12   VF_REAL = (1 << 0),       /* The data is real. */
13   VF_COMPLEX = (1 << 1),    /* The data is complex. */
14   VF_ACCUM = (1 << 2),      /* writedata should save this vector. */
15   VF_PLOT = (1 << 3),       /* writedata should incrementally plot it. */
16   VF_PRINT = (1 << 4),      /* writedata should print this vector. */
17   VF_MINGIVEN = (1 << 5),   /* The v_minsignal value is valid. */
18   VF_MAXGIVEN = (1 << 6),   /* The v_maxsignal value is valid. */
19   VF_PERMANENT = (1 << 7)   /* Don't garbage collect this vector. */
20 };
21 
22 
23 /* Plot types. */
24 typedef enum {
25     PLOT_LIN, PLOT_COMB, PLOT_POINT, PLOT_RETLIN
26 } PLOTTYPE;
27 
28 
29 /* A (possibly multi-dimensional) data vector.  The data is represented
30  * internally by a 1-d array.  The number of dimensions and the size
31  * of each dimension is recorded, along with v_length, the total size of
32  * the array.  If the dimensionality is 0 or 1, v_length is significant
33  * instead of v_numdims and v_dims, and the vector is handled in the old
34  * manner.
35  */
36 
37 #define MAXDIMS 8
38 
39 struct dvec {
40     char *v_name; /* Same as so_vname. */
41     enum simulation_types v_type; /* Same as so_vtype. */
42     short v_flags; /* Flags (a combination of VF_*). */
43     double *v_realdata; /* Real data. */
44     ngcomplex_t *v_compdata; /* Complex data. */
45     double v_minsignal; /* Minimum value to plot. */
46     double v_maxsignal; /* Maximum value to plot. */
47     GRIDTYPE v_gridtype; /* One of GRID_*. */
48     PLOTTYPE v_plottype; /* One of PLOT_*. */
49     int v_length; /* Length of the vector. */
50     int v_alloc_length; /* How much has been actually allocated. */
51     int v_rlength; /* How much space we really have. Used as binary flag */
52     int v_outindex; /* Index if writedata is building the vector. */
53     int v_linestyle; /* What line style we are using. */
54     int v_color; /* What color we are using. */
55     char *v_defcolor; /* The name of a color to use. */
56     int v_numdims; /* How many dims -- 0 = scalar (len = 1). */
57     int v_dims[MAXDIMS]; /* The actual size in each dimension. */
58     struct plot *v_plot; /* The plot structure (if it has one). */
59     struct dvec *v_next; /* Link for list of plot vectors. */
60     struct dvec *v_link2; /* Extra link for things like print. */
61     struct dvec *v_scale; /* If this has a non-standard scale... */
62 } ;
63 
64 #define isreal(v)       ((v)->v_flags & VF_REAL)
65 #define iscomplex(v)    ((v)->v_flags & VF_COMPLEX)
66 
67 /* list of data vectors being displayed */
68 struct dveclist {
69     struct dveclist *next;
70     struct dvec *vector;
71 
72     /* Flag that this list owns the vector in the sense that it is
73      * responsible for freeing it. Depending on how the entry was created,
74      * it either made its own copy or "borrowed" one from anothe use. */
75     bool f_own_vector;
76 };
77 
78 struct dvec *dvec_alloc(/* NOT CONST -- assigned to const */ char *name,
79         int type, short flags, int length, void *storage);
80 void dvec_realloc(struct dvec *v, int length, void *storage);
81 void dvec_extend(struct dvec *v, int length);
82 void dvec_trunc(struct dvec *v, int length);
83 void dvec_free(struct dvec *);
84 
85 #endif
86