55 MatrixN = MatrixS = MatrixY = NULL;
56 MatrixB = MatrixC = MatrixD = NULL;
57 VectorQ = VectorE = VectorI = VectorV = VectorJ = NULL;
59 VectorCV = VectorGV = NULL;
82 if (size > 0) nodes =
new node[
s];
83 MatrixN = MatrixS = MatrixY = NULL;
84 MatrixB = MatrixC = MatrixD = NULL;
85 VectorQ = VectorE = VectorI = VectorV = VectorJ = NULL;
87 VectorCV = VectorGV = NULL;
114 vsources = c.vsources;
115 nsources = c.nsources;
116 inserted = c.inserted;
119 nHistories = c.nHistories;
121 subcircuit = c.subcircuit ? strdup (c.subcircuit) : NULL;
125 nodes =
new node[size];
126 for (
int i = 0;
i < size;
i++) {
127 nodes[
i] =
node (c.nodes[
i]);;
133 memcpy (MatrixS, c.MatrixS, size * size * sizeof (
nr_complex_t));
138 int i = size + nsources;
139 memcpy (MatrixN, c.MatrixN, i * i * sizeof (
nr_complex_t));
144 memcpy (MatrixQV, c.MatrixQV, size * size * sizeof (
nr_complex_t));
145 memcpy (VectorGV, c.VectorGV, size * sizeof (
nr_complex_t));
146 memcpy (VectorCV, c.VectorCV, size * sizeof (
nr_complex_t));
147 memcpy (VectorQ, c.VectorQ, size * sizeof (
nr_complex_t));
152 memcpy (MatrixY, c.MatrixY, size * size * sizeof (
nr_complex_t));
153 memcpy (VectorI, c.VectorI, size * sizeof (
nr_complex_t));
154 memcpy (VectorV, c.VectorV, size * sizeof (
nr_complex_t));
156 memcpy (MatrixB, c.MatrixB, vsources * size * sizeof (
nr_complex_t));
157 memcpy (MatrixC, c.MatrixC, vsources * size * sizeof (
nr_complex_t));
158 memcpy (MatrixD, c.MatrixD, vsources * vsources * sizeof (
nr_complex_t));
159 memcpy (VectorE, c.VectorE, vsources * sizeof (
nr_complex_t));
160 memcpy (VectorJ, c.VectorJ, vsources * sizeof (
nr_complex_t));
166 MatrixS = MatrixN = MatrixY = NULL;
167 MatrixB = MatrixC = MatrixD = NULL;
168 VectorQ = VectorE = VectorI = VectorV = VectorJ = NULL;
170 VectorCV = VectorGV = NULL;
180 if (MatrixS)
delete[] MatrixS;
181 if (MatrixN)
delete[] MatrixN;
186 if (subcircuit) free (subcircuit);
195 if (size == s)
return;
200 if (MatrixS)
delete[] MatrixS;
201 if (MatrixN)
delete[] MatrixN;
202 MatrixS = MatrixN = NULL;
204 delete[] nodes; nodes = NULL;
207 if ((size = s) > 0) {
209 nodes =
new node[size];
218 if (VectorQ) {
delete[] VectorQ; VectorQ = NULL; }
219 if (MatrixQV) {
delete[] MatrixQV; MatrixQV = NULL; }
220 if (VectorCV) {
delete[] VectorCV; VectorCV = NULL; }
221 if (VectorGV) {
delete[] VectorGV; VectorGV = NULL; }
232 memset (MatrixQV, 0, size * size *
sizeof (
nr_complex_t));
251 memset (MatrixS, 0, size * size *
sizeof (
nr_complex_t));
260 if (MatrixN)
delete[] MatrixN;
261 MatrixN =
new nr_complex_t[(size + sources) * (size + sources)];
283 if (MatrixY) {
delete[] MatrixY; MatrixY = NULL; }
284 if (MatrixB) {
delete[] MatrixB; MatrixB = NULL; }
285 if (MatrixC) {
delete[] MatrixC; MatrixC = NULL; }
286 if (MatrixD) {
delete[] MatrixD; MatrixD = NULL; }
287 if (VectorE) {
delete[] VectorE; VectorE = NULL; }
288 if (VectorI) {
delete[] VectorI; VectorI = NULL; }
289 if (VectorV) {
delete[] VectorV; VectorV = NULL; }
290 if (VectorJ) {
delete[] VectorJ; VectorJ = NULL; }
311 if (subcircuit) free (subcircuit);
312 subcircuit = n ? strdup (n) : NULL;
319 for (
int j = 0; j <
getSize (); j++) {
342 return MatrixB[(nr - vsource) * size + port];
348 MatrixB[nr * size + port] = z;
354 return MatrixC[(nr - vsource) * size + port];
360 MatrixC[nr * size + port] = z;
366 return MatrixD[(r - vsource) * vsources + c - vsource];
372 MatrixD[r * vsources +
c] = z;
378 return VectorE[nr - vsource];
390 return VectorI[port];
412 return VectorQ[port];
429 VectorJ[nr - vsource] = z;
434 return VectorV[port];
445 return MatrixY[r * size +
c];
451 MatrixY[r * size +
c] = y;
457 MatrixY[r * size +
c] += y;
462 MatrixY[r * size +
c] += y;
468 return real (MatrixY[r * size + c]);
474 MatrixY[r * size +
c] = y;
480 return MatrixQV[r * size +
c];
486 MatrixQV[r * size +
c] = qv;
492 return VectorGV[port];
504 return VectorCV[port];
525 if (p != NULL)
return p->
getValue ();
543 return (oper.
get (n)) ? 1 : 0;
558 if (p != NULL)
return p->
getValue ();
576 return (charac.
get (n)) ? 1 : 0;
581 return MatrixS[y + x * size];
586 MatrixS[y + x * size] = z;
591 return MatrixN[c + r * (size + nsources)];
596 MatrixN[c + r * (size + nsources)] = z;
625 char *
n = (
char *) malloc (strlen (prefix) + strlen (obj) + 3);
626 sprintf (n,
"_%s#%s", prefix, obj);
645 if (r > 0 && c > 0 && r * c == size * size) {
664 if (r > 0 && c > 0 && r * c == size * size) {
683 if (r > 0 && c > 0 && r * c == size * size) {
698 memset (MatrixB, 0,
sizeof (
nr_complex_t) * size * vsources);
703 memset (MatrixC, 0,
sizeof (
nr_complex_t) * size * vsources);
708 memset (MatrixD, 0,
sizeof (
nr_complex_t) * vsources * vsources);
733 memset (MatrixY, 0,
sizeof (
nr_complex_t) * size * size);
741 setC (n, pos, +1.0);
setC (n, neg, -1.0);
742 setB (pos, n, +1.0);
setB (neg, n, -1.0);
752 nr_double_t cap, nr_double_t voltage,
753 nr_double_t charge) {
755 int cstate = qstate + 1;
758 addY (pos, pos, +g);
addY (neg, neg, +g);
759 addY (pos, neg, -g);
addY (neg, pos, -g);
768 nr_double_t voltage, nr_double_t charge) {
770 int cstate = qstate + 1;
773 addY (node, node, +g);
783 nr_double_t charge) {
784 nr_double_t unused,
i;
785 int cstate = qstate + 1;
796 nr_double_t charge) {
797 nr_double_t unused,
i;
798 int cstate = qstate + 1;
812 nr_double_t cap, nr_double_t voltage) {
815 addY (qpos, vpos, +g);
addY (qneg, vneg, +g);
816 addY (qpos, vneg, -g);
addY (qneg, vpos, -g);
817 i =
pol * (g * voltage);
826 nr_double_t cap, nr_double_t voltage) {
829 addY (qpos, vpos, +g);
830 addY (qpos, vneg, -g);
831 i =
pol * (g * voltage);
839 nr_double_t cap, nr_double_t voltage) {
842 addY (qpos, vpos, +g);
addY (qneg, vpos, -g);
843 i =
pol * (g * voltage);
852 nr_double_t cap, nr_double_t voltage) {
855 addY (qpos, vpos, +g);
856 i =
pol * (g * voltage);
863 histories =
new history[nHistories];
864 for (
int i = 0;
i < nHistories;
i++) histories[
i].setAge (age);
869 if (histories != NULL) {
883 if (histories)
return histories[0].
getAge ();
891 for (
int i = 0;
i < nHistories;
i++) histories[
i].setTvector (t);
896 return histories[port].
nearest (t);