48 using namespace transient;
54 nr_double_t * coefficients,
55 nr_double_t * delta) {
69 for (i = 0; i < order + 1; i++) b.
set (i, 1);
70 for (i = 1; i < order + 1; i++) {
74 for (c = 1; c <= order - 1; c++) {
75 nr_double_t entry = -
c;
76 for (r = 1; r <= order; r++) {
77 A.
set (r, c + 1, entry);
87 for (i = 0; i < x.getRows (); i++) {
92 nr_double_t k = x.
get (0);
93 coefficients[
COEFF_G] = 1 / delta[0] / k;
94 for (i = 1; i <= order; i++) {
95 coefficients[
i] = - 1 / delta[0] / k * x.
get (i);
100 b.
set (1, -1 / delta[0]);
102 for (c = 0; c < order + 1; c++) A.
set (0, c, 1);
104 for (f = 0, c = 0; c < order; c++) {
106 for (a = 1, r = 0; r < order; r++) {
108 A.
set (r + 1, c + 1, a);
113 for (r = 0; r <= order; r++) coefficients[r] = x.
get (r);
118 coefficients[
COEFF_G] = 1 / delta[0];
119 coefficients[1] = - 1 / delta[0];
122 coefficients[
COEFF_G] = 2 / delta[0];
123 coefficients[1] = - 2 / delta[0];
129 for (i = 0; i < order + 1; i++) b.
set (i, 1);
130 for (i = 1; i < order + 1; i++) {
135 for (c = 1; c <= order - 2; c++) {
136 nr_double_t entry = -
c;
137 for (r = 2; r <= order; r++) {
138 A.
set (r, c + 2, r * entry);
148 for (i = 0; i < x.getRows (); i++) {
153 nr_double_t k = x.
get (1);
154 coefficients[
COEFF_G] = 1 / delta[0] / k;
155 coefficients[1] = -x.
get (0) / delta[0] / k;
156 for (i = 2; i <= order; i++) {
157 coefficients[
i] = -x.
get (i) / k;
168 nr_double_t * coefficients,
169 nr_double_t * delta) {
184 for (c = 0; c < order + 1; c++) A.
set (0, c, 1);
186 for (f = 0, c = 0; c < order + 1; c++) {
188 for (a = 1, r = 0; r < order; r++) {
195 for (r = 0; r <= order; r++) coefficients[r] = x.
get (r);
202 for (i = 0; i < order + 1; i++) b.
set (i, 1);
203 for (i = 1; i < order + 1; i++) A.
set (1, i, 1);
205 for (c = 1; c <= order - 1; c++) {
206 nr_double_t entry = -
c;
207 for (r = 2; r <= order; r++) {
208 A.
set (r, c + 1, r * entry);
218 for (i = 0; i < x.getRows (); i++) {
224 for (i = 1; i <= order; i++) {
225 coefficients[
i] = x.
get (i) * delta[0];
229 nr_double_t f = - delta[0] / (2 * delta[1]);
231 coefficients[1] = (1 - f) * delta[0];
232 coefficients[2] = f * delta[0];
239 coefficients[1] = delta[0];
253 nr_double_t& geq, nr_double_t& ceq) {
255 int cstate = qstate + 1;
258 ceq = c->
getState (qstate, 1) * coeff[1];
265 nr_double_t& geq, nr_double_t& ceq) {
267 int cstate = qstate + 1;
277 nr_double_t& geq, nr_double_t& ceq) {
279 int i, cstate = qstate + 1;
282 for (ceq = 0, i = 1; i <= c->
getOrder (); i++) {
283 ceq += c->
getState (qstate, i) * coeff[
i];
291 nr_double_t& geq, nr_double_t& ceq) {
293 int i, cstate = qstate + 1;
296 ceq = c->
getState (qstate, 1) * coeff[1];
297 for (i = 2; i <= c->
getOrder (); i++) {
298 ceq += c->
getState (cstate, i - 1) * coeff[
i];
330 if (!strcmp (Method,
"Gear")) {
331 if (MaxOrder > 6) MaxOrder = 6;
332 if (MaxOrder < 1) MaxOrder = 1;
335 else if (!strcmp (Method,
"Trapezoidal")) {
339 else if (!strcmp (Method,
"Euler")) {
343 else if (!strcmp (Method,
"AdamsMoulton")) {
344 if (MaxOrder > 6) MaxOrder = 6;
345 if (MaxOrder < 1) MaxOrder = 1;
348 else if (!strcmp (Method,
"AdamsBashford")) {
349 if (MaxOrder > 6) MaxOrder = 6;
350 if (MaxOrder < 1) MaxOrder = 1;
361 switch (corrMethod) {
375 predOrder = corrOrder;
382 int integratorType[6];
383 nr_double_t corrErrorConstant[6];
384 nr_double_t predErrorConstant[6];
401 { -1.0/2, -2.0/9, -3.0/22, -12.0/125, -10.0/137, -20.0/343 },
402 { +1.0, +1.0, +1.0, +1.0, +1.0, +1.0 }
408 { -1.0/2, -1.0/12, -1.0/24, -19.0/720, -3.0/160, -863.0/60480 },
409 { +1.0/2, +1.0/12, +1.0/24, +19.0/720, +3.0/160, +863.0/60480 }
415 { -1.0/2, -5.0/12, -3.0/8, -251.0/720, -95.0/288, -19087.0/60480 },
416 { +1.0/2, +5.0/12, +3.0/8, +251.0/720, +95.0/288, +19087.0/60480 }