114 int run1, run2, run3;
138 A =
new double*[
dim];
139 b4 =
new double [
dim];
140 b5 =
new double [
dim];
141 c =
new double [
dim];
143 for( run1 = 0; run1 <
dim; run1++ ){
144 A[run1] =
new double[
dim];
153 eta4 =
new double [
m];
154 eta5 =
new double [
m];
158 for( run1 = 0; run1 <
m; run1++ ){
168 k2 =
new double**[4];
170 l2 =
new double**[4];
172 for( run3 = 0; run3 < 4; run3++ ){
174 k [run3] =
new double*[
dim];
175 k2 [run3] =
new double*[
dim];
176 l [run3] =
new double*[
dim];
177 l2 [run3] =
new double*[
dim];
179 for( run1 = 0; run1 <
dim; run1++ ){
180 k [run3][run1] =
new double[
m];
181 k2 [run3][run1] =
new double[
m];
183 for( run2 = 0; run2 <
m; run2++ ){
184 k [run3][run1][run2] = 0.0;
185 k2[run3][run1][run2] = 0.0;
188 l [run3][run1] =
new double[
ndir];
189 l2 [run3][run1] =
new double[
ndir];
191 for( run2 = 0; run2 <
ndir; run2++ ){
192 l [run3][run1][run2] = 0.0;
193 l2[run3][run1][run2] = 0.0;
201 x =
new double [
ndir];
203 for( run1 = 0; run1 <
ndir; run1++ ){
214 psi = (
double**)calloc(1,
sizeof(
double*));
216 gamma = (
double**)calloc(1,
sizeof(
double*));
222 eta =
new double*[4];
223 eta2 =
new double*[4];
227 psi [0] = (
double*)calloc(
nstep,
sizeof(
double));
228 gamma [0] = (
double*)calloc(
nstep,
sizeof(
double));
243 for( run1 = 0; run1 <
nstep; run1++ ){
246 gamma[0][run1] = 0.0;
259 for( run1 = 0; run1 < 4; run1++ ){
260 eta [run1] =
new double[
m];
261 eta2[run1] =
new double[
m];
262 for( run2 = 0; run2 <
m; run2++ ){
263 eta [run1][run2] = 0.0;
264 eta2[run1][run2] = 0.0;
277 for( run1 = 0; run1 <
md; run1++ ){
286 for( run1 = 0; run1 <
md; run1++ ){
296 for( run1 = 0; run1 <
ma; run1++ ){
303 for( run1 = 0; run1 <
mu; run1++ ){
309 for( run1 = 0; run1 <
mp; run1++ ){
315 for( run1 = 0; run1 <
mui; run1++ ){
321 for( run1 = 0; run1 <
mpi; run1++ ){
327 for( run1 = 0; run1 <
mw; run1++ ){
338 for( run1 = 0; run1 <
md; run1++ ){
341 for( run1 = 0; run1 <
ma; run1++ ){
347 for( run1 = 0; run1 <
m; run1++ ){
367 kH =
new double**[
dim];
368 for( run1 = 0; run1 <
dim; run1++ ){
370 for( run2 = 0; run2 <
nstep; run2++ ){
371 kH[run1][run2] =
new double[
ndir];
375 for( run1 = 0; run1 < 6; run1++ ){
376 zH[run1] =
new double[
ndir];
380 for( run1 = 0; run1 <
dim; run1++ ){
382 for( run2 = 0; run2 <
nstep; run2++ ){
383 kH2[run1][run2] =
new double[
ndir];
386 zH2 =
new double*[6];
387 for( run1 = 0; run1 < 6; run1++ ){
391 for( run1 = 0; run1 <
dim; run1++ ){
393 for( run2 = 0; run2 <
nstep; run2++ ){
394 kH3[run1][run2] =
new double[
ndir];
397 zH3 =
new double*[6];
398 for( run1 = 0; run1 < 6; run1++ ){
419 k = 0;
k2 = 0;
l = 0;
l2 = 0;
448 int run1, run2, run3;
470 A =
new double*[
dim];
471 b4 =
new double [
dim];
472 b5 =
new double [
dim];
473 c =
new double [
dim];
475 for( run1 = 0; run1 <
dim; run1++ ){
476 A[run1] =
new double[
dim];
486 eta4 =
new double [
m];
487 eta5 =
new double [
m];
491 for( run1 = 0; run1 <
m; run1++ ){
501 k2 =
new double**[4];
503 l2 =
new double**[4];
505 for( run3 = 0; run3 < 4; run3++ ){
507 k [run3] =
new double*[
dim];
508 k2 [run3] =
new double*[
dim];
509 l [run3] =
new double*[
dim];
510 l2 [run3] =
new double*[
dim];
512 for( run1 = 0; run1 <
dim; run1++ ){
513 k [run3][run1] =
new double[
m];
514 k2 [run3][run1] =
new double[
m];
516 for( run2 = 0; run2 <
m; run2++ ){
517 k [run3][run1][run2] = 0.0;
518 k2[run3][run1][run2] = 0.0;
521 l [run3][run1] =
new double[
ndir];
522 l2 [run3][run1] =
new double[
ndir];
524 for( run2 = 0; run2 <
ndir; run2++ ){
525 l [run3][run1][run2] = 0.0;
526 l2[run3][run1][run2] = 0.0;
533 x =
new double [
ndir];
535 for( run1 = 0; run1 <
ndir; run1++ ){
546 psi = (
double**)calloc(1,
sizeof(
double*));
548 gamma = (
double**)calloc(1,
sizeof(
double*));
554 eta =
new double*[4];
555 eta2 =
new double*[4];
559 psi [0] = (
double*)calloc(
nstep,
sizeof(
double));
560 gamma [0] = (
double*)calloc(
nstep,
sizeof(
double));
574 for( run1 = 0; run1 <
nstep; run1++ ){
578 gamma[0][run1] = 0.0;
592 for( run1 = 0; run1 < 4; run1++ ){
593 eta [run1] =
new double[
m];
594 eta2[run1] =
new double[
m];
595 for( run2 = 0; run2 <
m; run2++ ){
596 eta [run1][run2] = 0.0;
597 eta2[run1][run2] = 0.0;
607 h = (
double*)calloc(1,
sizeof(
double));
621 for( run1 = 0; run1 <
md; run1++ ){
630 for( run1 = 0; run1 <
md; run1++ ){
639 for( run1 = 0; run1 <
ma; run1++ ){
646 for( run1 = 0; run1 <
mu; run1++ ){
652 for( run1 = 0; run1 <
mp; run1++ ){
658 for( run1 = 0; run1 <
mui; run1++ ){
664 for( run1 = 0; run1 <
mpi; run1++ ){
670 for( run1 = 0; run1 <
mw; run1++ ){
686 for( run1 = 0; run1 <
md; run1++ ){
689 for( run1 = 0; run1 <
ma; run1++ ){
695 for( run1 = 0; run1 <
m; run1++ ){
738 kH =
new double**[
dim];
739 for( run1 = 0; run1 <
dim; run1++ ){
741 for( run2 = 0; run2 <
nstep; run2++ ){
742 kH[run1][run2] =
new double[
ndir];
746 for( run1 = 0; run1 < 6; run1++ ){
747 zH[run1] =
new double[
ndir];
756 for( run1 = 0; run1 <
dim; run1++ ){
758 for( run2 = 0; run2 <
nstep; run2++ ){
759 kH2[run1][run2] =
new double[
ndir];
762 zH2 =
new double*[6];
763 for( run1 = 0; run1 < 6; run1++ ){
767 for( run1 = 0; run1 <
dim; run1++ ){
769 for( run2 = 0; run2 <
nstep; run2++ ){
770 kH3[run1][run2] =
new double[
ndir];
773 zH3 =
new double*[6];
774 for( run1 = 0; run1 < 6; run1++ ){
809 for( run1 = 0; run1 <
dim; run1++ ){
836 for( run2 = 0; run2 < 4; run2++ ){
838 for( run1 = 0; run1 <
dim; run1++ ){
839 if(
k[run2] != NULL )
840 delete[]
k[run2][run1] ;
841 if(
k2[run2] != NULL )
842 delete[]
k2[run2][run1];
843 if(
l[run2] != NULL )
844 delete[]
l[run2][run1] ;
845 if(
l2[run2] != NULL )
846 delete[]
l2[run2][run1];
884 for( run1 = 0; run1 <
maxAlloc; run1++ ){
886 if(
psi[run1] != NULL ){
889 if(
gamma[run1] != NULL ){
908 for( run1 = 0; run1 < 4; run1++ ){
919 for( run1 = 0; run1 <
maxNM; run1++ ){
975 for( run1 = 0; run1 <
nstep; run1++ ){
979 delete[]
etaH2[run1];
981 delete[]
etaH3[run1];
991 for( run1 = 0; run1 <
dim; run1++ ){
992 for( run2 = 0; run2 <
nstep; run2++ ){
994 delete[]
kH[run1][run2];
996 delete[]
kH2[run1][run2];
998 delete[]
kH3[run1][run2];
1015 for( run1 = 0; run1 < 6; run1++ ){
1065 for( run1 = 1; run1 <
maxAlloc; run1++ ){
1067 if(
psi[run1] != NULL ){
1070 if(
gamma[run1] != NULL ){
1077 psi = (
double**)realloc(
psi,maxAlloc*
sizeof(
double*));
1078 gamma = (
double**)realloc(
gamma,maxAlloc*
sizeof(
double*));
1081 for( run1 = 0; run1 <
maxAlloc; run1++ ){
1085 for( run1 = 0; run1 <
maxAlloc; run1++ ){
1087 for( run2 = 0; run2 < 5; run2++ ){
1088 psi [run1][run2] = 0.0;
1089 gamma[run1][run2] = 0.0;
1093 for( run1 = 0; run1 <
maxNM; run1++ ){
1104 h = (
double*)realloc(
h,maxAlloc*
sizeof(
double));
1141 for( run1 = 0; run1 <
md; run1++ ){
1142 eta4[run1] = x0(run1);
1143 eta5[run1] = x0(run1);
1144 xStore(0,run1) = x0(run1);
1155 if(
h[0] < 10.0*
EPS )
1164 for( run1 = 0; run1 <
ma; run1++ ){
1165 eta4[md+run1] = xa(run1);
1166 eta5[md+run1] = xa(run1);
1167 xStore(0,md+run1) = xa(run1);
1174 for( run1 = 0; run1 <
md; run1++ )
1182 for( run1 = 0; run1 <
mp; run1++ ){
1192 for( run1 = 0; run1 <
mu; run1++ ){
1203 for( run1 = 0; run1 <
mw; run1++ ){
1225 for( run1 = 0; run1 <
m; run1++ )
1243 cout <<
"BDF: t = " <<
t <<
"\t";
1244 for( run1 = 0; run1 <
md; run1++ ){
1245 cout <<
"x[" << run1 <<
"] = " << scientific <<
eta4[run1] <<
" ";
1247 for( run1 = 0; run1 <
ma; run1++ ){
1248 cout <<
"xq[" << run1 <<
"] = " <<
eta4[md+run1] <<
" ";
1291 for( run1 = 0; run1 <
mn; run1++ )
1331 cout <<
"\n Results at t = " <<
t <<
" : \n\n";
1332 for( run1 = 0; run1 <
md; run1++ ){
1333 cout <<
"x[" << run1 <<
"] = " << scientific <<
nablaY(0,run1) <<
" ";
1335 for( run1 = 0; run1 <
ma; run1++ ){
1336 cout <<
"x[" << run1 <<
"] = " << scientific <<
nablaY(0,md+run1) <<
" ";
1342 int printIntegratorProfile = 0;
1352 cout <<
"BDF: number of steps: " <<
count - 1 << endl;
1368 if( order < 1 || order > 2 ){
1393 G =
new double[
ndir];
1395 for( run2 = 0; run2 < (
ndir); run2++ )
1398 etaG =
new double[
m];
1403 if( xSeed.
getDim() != 0 )
1404 for( run2 = 0; run2 <
md; run2++ )
1407 if( pSeed.
getDim() != 0 )
1408 for( run2 = 0; run2 <
mp; run2++ ){
1413 if( uSeed.
getDim() != 0 )
1414 for( run2 = 0; run2 <
mu; run2++ ){
1419 if( wSeed.
getDim() != 0 )
1420 for( run2 = 0; run2 <
mw; run2++ ){
1447 if(
etaG2 != NULL ){
1452 if(
etaG3 != NULL ){
1466 for( run2 = 0; run2 < (
ndir); run2++ ){
1477 if( xSeed.
getDim() != 0 )
1478 for( run2 = 0; run2 <
md; run2++ )
1481 if( pSeed.
getDim() != 0 )
1482 for( run2 = 0; run2 <
mp; run2++ ){
1487 if( uSeed.
getDim() != 0 )
1488 for( run2 = 0; run2 <
mu; run2++ ){
1493 if( wSeed.
getDim() != 0 )
1494 for( run2 = 0; run2 <
mw; run2++ ){
1508 if( order < 1 || order > 2 ){
1516 int run1, run2, run3;
1523 for( run1 = 0; run1 <
nstep; run1++ ){
1525 delete[]
etaH[run1];
1539 for( run2 = 0; run2 <
md; run2++ )
1540 bseed(run2) = seed(run2);
1543 for( run3 = 0; run3 <
nstep; run3++ ){
1545 for( run2 = 0; run2 <
ndir; run2++ ){
1546 etaH[run3][run2] = 0.0;
1568 int run1, run2, run3;
1579 for( run1 = 0; run1 <
nstep; run1++ ){
1581 delete[]
etaH2[run1];
1583 delete[]
etaH3[run1];
1585 if(
etaH2 != NULL ){
1589 if(
etaH3 != NULL ){
1601 if( seed.
getDim() != 0 ){
1602 for( run2 = 0; run2 <
md; run2++ ){
1603 bseed2(run2) = seed(run2);
1608 for( run3 = 0; run3 <
nstep; run3++ ){
1610 for( run2 = 0; run2 <
ndir; run2++ ){
1611 etaH2[run3][run2] = 0.0;
1615 for( run3 = 0; run3 <
nstep; run3++ ){
1617 for( run2 = 0; run2 <
ndir; run2++ ){
1618 etaH3[run3][run2] = 0.0;
1666 for( run1 = 0; run1 <
md; run1++ ){
1674 for( run1 = 0; run1 <
md; run1++ ){
1682 for( run1 = 0; run1 <
md; run1++ ){
1692 for( run1 = 0; run1 <
md; run1++ ){
1705 int oldCount =
count;
1759 for( run1 = 0; run1 <
m; run1++ )
1763 for( run1 = 0; run1 <
m; run1++ )
1803 for( run1 = oldAlloc; run1 <
maxAlloc; run1++ ){
1806 for( run1 = oldAlloc; run1 <
maxAlloc; run1++ ){
1807 psi [run1] = (
double*)calloc(
nstep,
sizeof(
double));
1808 gamma[run1] = (
double*)calloc(
nstep,
sizeof(
double));
1812 h = (
double*)realloc(
h,maxAlloc*
sizeof(
double));
1846 int number_of_rejected_steps = 0;
1858 cout <<
"STEP REJECTED: error estimate = " << scientific << E
1859 <<
" required local tolerance = " <<
TOL << endl;
1862 number_of_rejected_steps++;
1885 if( E > 0.9*
INFTY )
h[0] = 0.2*
h[0];
1906 count3 += number_of_rejected_steps;
1993 h = (
double*)realloc(
h,
maxAlloc*
sizeof(
double));
2007 for( jj = i1+1; jj <= i2; jj++ )
2008 for( run1 = 0; run1 <
mn; run1++ )
2021 for( run1 = 0; run1 <
m; run1++ ){
2048 for( run1 = 0; run1 <
m; run1++ )
2056 if( E < Emin ) E = Emin ;
2057 if( E < 10.0*
EPS ) E = 10.0*
EPS;
2096 if( (
int) xEnd[0].
getDim() !=
m )
2099 for( run1 = 0; run1 <
m; run1++ )
2100 xEnd[0](run1) =
nablaY(0,run1);
2114 if( order == 1 &&
nFDirs2 == 0 ){
2116 if( (
int) Dx[0].getNumCols() !=
nFDirs )
2118 if( (
int) Dx[0].getNumRows() !=
m )
2121 for( run1 = 0; run1 <
m; run1++ ){
2122 Dx[0](run1,0) =
nablaG(0,run1);
2128 if( (
int) Dx[0].getNumCols() !=
nFDirs2 )
2130 if( (
int) Dx[0].getNumRows() !=
m )
2133 for( run1 = 0; run1 <
m; run1++ ){
2134 Dx[0](run1,0) =
nablaG3(0,run1);
2138 if( order == 1 &&
nFDirs2 > 0 ){
2140 if( (
int) Dx[0].getNumCols() !=
nFDirs2 )
2142 if( (
int) Dx[0].getNumRows() !=
m )
2145 for( run1 = 0; run1 <
m; run1++ ){
2146 Dx[0](run1,0) =
nablaG2(0,run1);
2150 if( order < 1 || order > 2 ){
2164 if( order == 1 &&
nBDirs2 == 0 )
2167 if( order == 1 &&
nBDirs2 > 0 )
2173 if( order < 1 || order > 2 )
2187 for( run1 = 0; run1 <
md; run1++ ){
2193 for( run1 = 0; run1 <
md; run1++ ){
2198 for( run1 = 0; run1 <
md; run1++ ){
2245 psi[number_][3] =
psi[number_][2] +
h[0];
2246 psi[number_][2] =
psi[number_][1] + h[0];
2247 psi[number_][1] =
psi[number_][0] + h[0];
2248 psi[number_][0] = h[0];
2250 gamma[number_][4] = 1.0/
psi[number_][0] + 1.0/
psi[number_][1]
2251 + 1.0/
psi[number_][2] + 1.0/
psi[number_][3];
2255 psi[number_][3] =
psi[number_-1][2] +
h[0];
2256 psi[number_][2] =
psi[number_-1][1] + h[0];
2257 psi[number_][1] =
psi[number_-1][0] + h[0];
2258 psi[number_][0] = h[0];
2260 gamma[number_][4] = 1.0/
psi[number_][0] + 1.0/
psi[number_][1]
2261 + 1.0/
psi[number_][2] + 1.0/
psi[number_][3];
2267 pp =
psi[number_][0]*scalT/
h[0];
2268 for( run1 = 0; run1 <
m; run1++ )
2271 pp *=
psi[number_][1]*scalT/
h[0];
2272 for( run1 = 0; run1 <
m; run1++ )
2275 pp *=
psi[number_][2]*scalT/
h[0];
2276 for( run1 = 0; run1 <
m; run1++ )
2279 pp *=
psi[number_][3]*scalT/
h[0];
2280 for( run1 = 0; run1 <
m; run1++ )
2284 for( run1 = 0; run1 <
m; run1++ )
2287 for( run1 = 0; run1 <
m; run1++ )
2290 for( run1 = 0; run1 <
m; run1++ )
2293 for( run1 = 0; run1 <
m; run1++ )
2297 for( run1 = 0; run1 <
md; run1++ ){
2320 for( run1 = 0; run1 <
m; run1++ ){
2331 for( run1 = 0; run1 <
md; run1++ ){
2356 COMPUTE_JACOBIAN = ini;
2363 if( stepnumber > 0 ){
2369 while( newtonsteps < 3 ){
2374 for( run2 = 0; run2 <
m; run2++ ){
2377 for( run2 = 0; run2 <
md; run2++ ){
2392 if( COMPUTE_JACOBIAN ==
BT_TRUE ){
2397 cout <<
"(RE-) COMPUTE-JACOBIAN... \n";
2406 for( run1 = oldMN; run1 <
maxNM; run1++ )
2414 if(
M[0] == 0 )
M[0] =
new DMatrix(m,m);
2419 for( run1 = 0; run1 <
md; run1++ ){
2422 if(
rhs[0].AD_forward( 3*stepnumber+newtonsteps,
iseed,
2426 for( run2 = 0; run2 <
m; run2++ )
2427 M[
M_index[stepnumber]]->
operator()(run2,run1) =
k2[0][0][run2];
2429 iseed[ddiff_index[run1]] = 0.0;
2430 iseed[ diff_index[run1]] = 0.0;
2433 for( run1 = 0; run1 <
ma; run1++ ){
2435 if(
rhs[0].AD_forward( 3*stepnumber+newtonsteps,
iseed,
2439 for( run2 = 0; run2 <
m; run2++ )
2440 M[
M_index[stepnumber]]->
operator()(run2,md+run1) =
k2[0][0][run2];
2442 iseed[diff_index[md+run1]] = 0.0;
2471 double subTOL = 1e-3*
TOL;
2473 if( norm1 < subTOL ){
2478 if( newtonsteps == 0 ){
2482 if( newtonsteps == 1 && (norm1/norm2 > 0.33 || norm1/norm2 >
sqrt(0.33*TOL/norm2)) ){
2484 if( JACOBIAN_COMPUTED ==
BT_FALSE ){
2490 if( newtonsteps == 1 ){
2494 if( newtonsteps == 2 ){
2496 if( norm1 > 0.33*TOL ){
2498 if( JACOBIAN_COMPUTED ==
BT_FALSE ){
2522 int run1, run2, run3;
2543 for( run1 = oldAlloc; run1 <
maxAlloc; run1++ ){
2546 for( run1 = oldAlloc; run1 <
maxAlloc; run1++ ){
2548 psi [run1] = (
double*)calloc(
nstep,
sizeof(
double));
2549 gamma[run1] = (
double*)calloc(
nstep,
sizeof(
double));
2554 h = (
double*)realloc(
h,
maxAlloc*
sizeof(
double));
2561 int step_rejections = 0;
2563 while( step_rejections < 1 ){
2569 for( run2 = 0; run2 <
m; run2++ ){
2573 while( run1 <
dim ){
2576 for( run2 = 0; run2 <
m; run2++ ){
2586 cout <<
"RUNGE-KUTTA STARTER: \n" << scientific
2587 <<
"STEP REJECTED: error estimate = " << E << endl
2588 <<
" required local tolerance = " <<
TOL << endl;
2613 for( run1 = 0; run1 <
m; run1++ ){
2621 for( run1 = 0; run1 <
dim; run1++ ){
2622 for( run2 = 0; run2 <
md; run2++ ){
2624 eta5[run2] =
eta5[run2] +
b5[run1]*
h[0]*
k[nOfNewtonSteps[run1]][run1][run2];
2627 for( run1 = 0; run1 <
ma; run1++ ){
2635 for( run2 = 0; run2 <
md; run2++ ){
2650 cout <<
"RUNGE-KUTTA STARTER: \n" << scientific
2651 <<
"STEP REJECTED: error estimate = " << E << endl
2652 <<
" required local tolerance = " <<
TOL*
h[0] << endl;
2656 for( run1 = 0; run1 <
m; run1++ ){
2682 for( run1 = 0; run1 <
nstep-1; run1++ ){
2683 for( run2 = 0; run2 <
md; run2++ ){
2685 for( run3 = 0; run3 <= run1+3; run3++ ){
2686 nablaY(nstep-2-run1,run2) =
nablaY(nstep-2-run1,run2) +
2690 for( run2 = 0; run2 <
ma; run2++ ){
2746 const double hhh =
c[3]*
h[0];
2754 for( run3 = 3; run3 >= 0; run3-- )
2763 for( jj = i1+1; jj <= i2; jj++ ){
2765 for( run1 = 0; run1 <
m; run1++ ){
2770 for( run1 = 0; run1 <
mn; run1++ )
2794 psi[7][1] = 2.0*hhh;
2795 psi[7][2] = 3.0*hhh;
2796 psi[7][3] = 4.0*hhh;
2801 psi[6][1] = 2.0*hhh;
2802 psi[6][2] = 3.0*hhh;
2803 psi[6][3] = 4.0*hhh;
2818 h[0] = 0.2*h[0]*
pow(
tune*(
TOL*h[0]/E) , 1.0/3.0 );
2841 int run1, run2, run3;
2861 if( stepnumber > 0 ){
2867 while( newtonsteps < 3 ){
2872 for( run2 = 0; run2 <
md; run2++ ){
2874 for( run3 = 0; run3 < stepnumber+1; run3++ ){
2875 x[diff_index[run2]] =
x[diff_index[run2]] +
2879 for( run2 = 0; run2 <
ma; run2++ ){
2880 x[
diff_index[md+run2]] =
k[newtonsteps][stepnumber][md+run2];
2882 for( run2 = 0; run2 <
md; run2++ ){
2898 if( COMPUTE_JACOBIAN ==
BT_TRUE ){
2903 cout <<
"(RE-) COMPUTE-JACOBIAN... \n";
2906 const double ise = h[0]*
A[stepnumber][stepnumber];
2914 for( run1 = oldMN; run1 <
maxNM; run1++ )
2927 for( run1 = 0; run1 <
md; run1++ ){
2930 if(
rhs[0].AD_forward( 3*stepnumber+newtonsteps,
iseed,
2935 for( run2 = 0; run2 <
m; run2++ )
2936 M[
M_index[stepnumber]]->
operator()(run2,run1) =
k2[0][0][run2];
2938 iseed[ddiff_index[run1]] = 0.0;
2939 iseed[ diff_index[run1]] = 0.0;
2941 for( run1 = 0; run1 <
ma; run1++ ){
2943 if(
rhs[0].AD_forward( 3*stepnumber+newtonsteps,
iseed,
2948 for( run2 = 0; run2 <
m; run2++ )
2949 M[
M_index[stepnumber]]->
operator()(run2,md+run1) =
k2[0][0][run2];
2951 iseed[diff_index[md+run1]] = 0.0;
2968 k[newtonsteps+1][stepnumber],
2969 k[newtonsteps][stepnumber] ,
2979 double subTOL = 1e-3*
TOL;
2981 if( norm1 < subTOL ){
2987 if( newtonsteps == 0 ){
2991 if( newtonsteps == 1 && (norm1/norm2 > 0.33 || norm1/norm2 >
sqrt(0.33*TOL/norm2)) ){
2993 if( JACOBIAN_COMPUTED ==
BT_FALSE ){
2999 if( newtonsteps == 1 ){
3003 if( newtonsteps == 2 ){
3005 if( JACOBIAN_COMPUTED ==
BT_FALSE ){
3011 if( norm1 > 0.33*TOL ){
3031 int run1, run2, run3, newtonsteps;
3034 for( run2 = 0; run2 <
m; run2++ ){
3035 k[0][0][run2] = 0.0;
3041 for( run1 = 0; run1 <
dim; run1++ ){
3044 for( run2 = 0; run2 <
m; run2++ ){
3052 for( run2 = 0; run2 <
md; run2++ ){
3054 for( run3 = 0; run3 < run1; run3++ ){
3055 G[diff_index[run2]] =
G[diff_index[run2]] +
3058 G[diff_index[run2]] =
G[diff_index[run2]] +
3059 A[run1][run1]*
h[0]*
k[newtonsteps][run1][run2];
3061 for( run2 = 0; run2 <
ma; run2++ ){
3062 G[
diff_index[md+run2]] =
k[newtonsteps][run1][md+run2];
3064 for( run2 = 0; run2 <
md; run2++ ){
3068 if(
rhs[0].AD_forward( 3*run1+newtonsteps,
G,
F )
3076 k[newtonsteps+1][run1],
3077 k[newtonsteps][run1] ,
3088 for( run1 = 0; run1 <
nstep-1; run1++ ){
3089 for( run2 = 0; run2 <
md; run2++ ){
3091 for( run3 = 0; run3 <= run1+3; run3++ ){
3092 nablaG(nstep-2-run1,run2) =
nablaG(nstep-2-run1,run2) +
3096 for( run2 = 0; run2 <
ma; run2++ ){
3105 int run1, run2, run3, newtonsteps;
3106 const double hhh =
c[3]*
h[0];
3108 double *Hstore =
new double[
ndir];
3112 for( run3 = 0; run3 < 4; run3++ ){
3113 for( run1 = 0; run1 <
dim; run1++ ){
3114 for( run2 = 0; run2 <
ndir; run2++ ){
3115 l[run3][run1][run2] = 0.0;
3120 for( run1 = 0; run1 <
ndir; run1++ ){
3121 Hstore[run1] =
nablaH(0,run1);
3124 for( run1 = 0; run1 <
ndir; run1++ ){
3126 zH[5][run1] =
nablaH(3,run1)*scalT*scalT;
3127 zH[4][run1] =
nablaH(2,run1)*scalT +
zH[5][run1]/(3.0);
3128 zH[3][run1] = -
zH[5][run1]/(3.0);
3129 zH[2][run1] =
nablaH(1,run1) +
zH[4][run1]/(2.0);
3130 zH[1][run1] = (
zH[3][run1]-
zH[4][run1])/(2.0);
3131 zH[0][run1] = -
zH[3][run1]/(2.0);
3134 nablaH(2,run1) = (
zH[1][run1]-
zH[2][run1])*(h[0]/hhh);
3135 nablaH(1,run1) = (
zH[0][run1]-
zH[1][run1])*(h[0]/hhh);
3136 nablaH(0,run1) = -
zH[0][run1]*(h[0]/hhh);
3139 for( run1 = 0; run1 <
ndir; run1++ ){
3142 for( run1 = 0; run1 <
md; run1++ ){
3152 while( newtonsteps >= 0 ){
3158 if(
rhs[0].AD_backward( 3*number_+newtonsteps,
H,
l[newtonsteps][number_] )
3164 for( run1 = 0; run1 <
ndir; run1++ ){
3165 kH[number_][newtonsteps][run1] =
kH[number_][newtonsteps+1][run1]
3166 -
l[newtonsteps][number_][run1];
3168 for( run1 = 0; run1 <
md; run1++ ){
3170 kH[number_][newtonsteps+1][diff_index[run1]]
3171 -
l[newtonsteps][number_][diff_index[run1]]*h[0]*
A[number_][number_]
3179 for( run1 = 0; run1 <
ndir; run1++ ){
3182 for( run1 = 0; run1 <
md; run1++ ){
3184 +
nablaH(3,diff_index[run1])*
A[6][5]
3185 +
nablaH(2,diff_index[run1])*
A[5][5];
3187 kH[5][nOfNewtonSteps[5]][diff_index[run1]] =
3188 kH[5][nOfNewtonSteps[5]][diff_index[run1]]
3189 -
l[run3][number_][diff_index[run1]]*h[0]*A[6][5];
3199 while( newtonsteps >= 0 ){
3205 if(
rhs[0].AD_backward( 3*number_+newtonsteps,
H,
l[newtonsteps][number_] )
3211 for( run1 = 0; run1 <
ndir; run1++ ){
3212 kH[number_][newtonsteps][run1] =
kH[number_][newtonsteps+1][run1]
3213 -
l[newtonsteps][number_][run1];
3215 for( run1 = 0; run1 <
md; run1++ ){
3217 kH[number_][newtonsteps+1][diff_index[run1]]
3218 -
l[newtonsteps][number_][diff_index[run1]]*h[0]*
A[number_][number_]
3226 for( run1 = 0; run1 <
ndir; run1++ ){
3229 for( run1 = 0; run1 <
md; run1++ ){
3231 +
nablaH(3,diff_index[run1])*
A[6][4]
3232 +
nablaH(2,diff_index[run1])*
A[5][4]
3233 +
nablaH(1,diff_index[run1])*
A[4][4];
3235 kH[4][nOfNewtonSteps[4]][diff_index[run1]] =
3236 kH[4][nOfNewtonSteps[4]][diff_index[run1]]
3237 -
l[run3][5][diff_index[run1]]*h[0]*A[5][4];
3239 for( run3 = 0; run3 < nOfNewtonSteps[6]; run3++){
3240 kH[4][nOfNewtonSteps[4]][diff_index[run1]] =
3241 kH[4][nOfNewtonSteps[4]][diff_index[run1]]
3242 -
l[run3][6][diff_index[run1]]*h[0]*A[6][4];
3252 while( newtonsteps >= 0 ){
3258 if(
rhs[0].AD_backward( 3*number_+newtonsteps,
H,
l[newtonsteps][number_] )
3264 for( run1 = 0; run1 <
ndir; run1++ ){
3265 kH[number_][newtonsteps][run1] =
kH[number_][newtonsteps+1][run1]
3266 -
l[newtonsteps][number_][run1];
3268 for( run1 = 0; run1 <
md; run1++ ){
3270 kH[number_][newtonsteps+1][diff_index[run1]]
3271 -
l[newtonsteps][number_][diff_index[run1]]*h[0]*
A[number_][number_]
3279 for( run1 = 0; run1 <
ndir; run1++ ){
3282 for( run1 = 0; run1 <
md; run1++ ){
3284 +
nablaH(3,diff_index[run1])*
A[6][3]
3285 +
nablaH(2,diff_index[run1])*
A[5][3]
3286 +
nablaH(1,diff_index[run1])*
A[4][3]
3287 +
nablaH(0,diff_index[run1])*
A[3][3];
3289 kH[3][nOfNewtonSteps[3]][diff_index[run1]] =
3290 kH[3][nOfNewtonSteps[3]][diff_index[run1]]
3291 -
l[run3][4][diff_index[run1]]*h[0]*A[4][3];
3293 for( run3 = 0; run3 < nOfNewtonSteps[5]; run3++){
3294 kH[3][nOfNewtonSteps[3]][diff_index[run1]] =
3295 kH[3][nOfNewtonSteps[3]][diff_index[run1]]
3296 -
l[run3][5][diff_index[run1]]*h[0]*A[5][3];
3298 for( run3 = 0; run3 < nOfNewtonSteps[6]; run3++){
3299 kH[3][nOfNewtonSteps[3]][diff_index[run1]] =
3300 kH[3][nOfNewtonSteps[3]][diff_index[run1]]
3301 -
l[run3][6][diff_index[run1]]*h[0]*A[6][3];
3311 while( newtonsteps >= 0 ){
3317 if(
rhs[0].AD_backward( 3*number_+newtonsteps,
H,
l[newtonsteps][number_] )
3323 for( run1 = 0; run1 <
ndir; run1++ ){
3324 kH[number_][newtonsteps][run1] =
kH[number_][newtonsteps+1][run1]
3325 -
l[newtonsteps][number_][run1];
3327 for( run1 = 0; run1 <
md; run1++ ){
3329 kH[number_][newtonsteps+1][diff_index[run1]]
3330 -
l[newtonsteps][number_][diff_index[run1]]*h[0]*
A[number_][number_]
3338 for( run1 = 0; run1 <
ndir; run1++ ){
3341 for( run1 = 0; run1 <
md; run1++ ){
3343 +
nablaH(3,diff_index[run1])*
A[6][2]
3344 +
nablaH(2,diff_index[run1])*
A[5][2]
3345 +
nablaH(1,diff_index[run1])*
A[4][2]
3346 +
nablaH(0,diff_index[run1])*
A[3][2];
3348 kH[2][nOfNewtonSteps[2]][diff_index[run1]] =
3349 kH[2][nOfNewtonSteps[2]][diff_index[run1]]
3350 -
l[run3][3][diff_index[run1]]*h[0]*A[3][2];
3352 for( run3 = 0; run3 < nOfNewtonSteps[4]; run3++){
3353 kH[2][nOfNewtonSteps[2]][diff_index[run1]] =
3354 kH[2][nOfNewtonSteps[2]][diff_index[run1]]
3355 -
l[run3][4][diff_index[run1]]*h[0]*A[4][2];
3357 for( run3 = 0; run3 < nOfNewtonSteps[5]; run3++){
3358 kH[2][nOfNewtonSteps[2]][diff_index[run1]] =
3359 kH[2][nOfNewtonSteps[2]][diff_index[run1]]
3360 -
l[run3][5][diff_index[run1]]*h[0]*A[5][2];
3362 for( run3 = 0; run3 < nOfNewtonSteps[6]; run3++){
3363 kH[2][nOfNewtonSteps[2]][diff_index[run1]] =
3364 kH[2][nOfNewtonSteps[2]][diff_index[run1]]
3365 -
l[run3][6][diff_index[run1]]*h[0]*A[6][2];
3375 while( newtonsteps >= 0 ){
3381 if(
rhs[0].AD_backward( 3*number_+newtonsteps,
H,
l[newtonsteps][number_] )
3387 for( run1 = 0; run1 <
ndir; run1++ ){
3388 kH[number_][newtonsteps][run1] =
kH[number_][newtonsteps+1][run1]
3389 -
l[newtonsteps][number_][run1];
3391 for( run1 = 0; run1 <
md; run1++ ){
3393 kH[number_][newtonsteps+1][diff_index[run1]]
3394 -
l[newtonsteps][number_][diff_index[run1]]*h[0]*
A[number_][number_]
3402 for( run1 = 0; run1 <
ndir; run1++ ){
3405 for( run1 = 0; run1 <
md; run1++ ){
3407 +
nablaH(3,diff_index[run1])*
A[6][1]
3408 +
nablaH(2,diff_index[run1])*
A[5][1]
3409 +
nablaH(1,diff_index[run1])*
A[4][1]
3410 +
nablaH(0,diff_index[run1])*
A[3][1];
3412 kH[1][nOfNewtonSteps[1]][diff_index[run1]] =
3413 kH[1][nOfNewtonSteps[1]][diff_index[run1]]
3414 -
l[run3][2][diff_index[run1]]*h[0]*A[2][1];
3416 for( run3 = 0; run3 < nOfNewtonSteps[3]; run3++){
3417 kH[1][nOfNewtonSteps[1]][diff_index[run1]] =
3418 kH[1][nOfNewtonSteps[1]][diff_index[run1]]
3419 -
l[run3][3][diff_index[run1]]*h[0]*A[3][1];
3421 for( run3 = 0; run3 < nOfNewtonSteps[4]; run3++){
3422 kH[1][nOfNewtonSteps[1]][diff_index[run1]] =
3423 kH[1][nOfNewtonSteps[1]][diff_index[run1]]
3424 -
l[run3][4][diff_index[run1]]*h[0]*A[4][1];
3426 for( run3 = 0; run3 < nOfNewtonSteps[5]; run3++){
3427 kH[1][nOfNewtonSteps[1]][diff_index[run1]] =
3428 kH[1][nOfNewtonSteps[1]][diff_index[run1]]
3429 -
l[run3][5][diff_index[run1]]*h[0]*A[5][1];
3431 for( run3 = 0; run3 < nOfNewtonSteps[6]; run3++){
3432 kH[1][nOfNewtonSteps[1]][diff_index[run1]] =
3433 kH[1][nOfNewtonSteps[1]][diff_index[run1]]
3434 -
l[run3][6][diff_index[run1]]*h[0]*A[6][1];
3444 while( newtonsteps >= 0 ){
3450 if(
rhs[0].AD_backward( 3*number_+newtonsteps,
H,
l[newtonsteps][number_] )
3456 for( run1 = 0; run1 <
ndir; run1++ ){
3457 kH[number_][newtonsteps][run1] =
kH[number_][newtonsteps+1][run1]
3458 -
l[newtonsteps][number_][run1];
3460 for( run1 = 0; run1 <
md; run1++ ){
3462 kH[number_][newtonsteps+1][diff_index[run1]]
3463 -
l[newtonsteps][number_][diff_index[run1]]*h[0]*
A[number_][number_]
3472 for( run1 = 0; run1 <
ndir; run1++ ){
3475 for( run1 = 0; run1 <
md; run1++ ){
3477 +
nablaH(3,diff_index[run1])*
A[6][0]
3478 +
nablaH(2,diff_index[run1])*
A[5][0]
3479 +
nablaH(1,diff_index[run1])*
A[4][0]
3480 +
nablaH(0,diff_index[run1])*
A[3][0];
3482 kH[0][nOfNewtonSteps[0]][diff_index[run1]] =
3483 kH[0][nOfNewtonSteps[0]][diff_index[run1]]
3484 -
l[run3][1][diff_index[run1]]*h[0]*A[1][0];
3486 for( run3 = 0; run3 < nOfNewtonSteps[2]; run3++){
3487 kH[0][nOfNewtonSteps[0]][diff_index[run1]] =
3488 kH[0][nOfNewtonSteps[0]][diff_index[run1]]
3489 -
l[run3][2][diff_index[run1]]*h[0]*A[2][0];
3491 for( run3 = 0; run3 < nOfNewtonSteps[3]; run3++){
3492 kH[0][nOfNewtonSteps[0]][diff_index[run1]] =
3493 kH[0][nOfNewtonSteps[0]][diff_index[run1]]
3494 -
l[run3][3][diff_index[run1]]*h[0]*A[3][0];
3496 for( run3 = 0; run3 < nOfNewtonSteps[4]; run3++){
3497 kH[0][nOfNewtonSteps[0]][diff_index[run1]] =
3498 kH[0][nOfNewtonSteps[0]][diff_index[run1]]
3499 -
l[run3][4][diff_index[run1]]*h[0]*A[4][0];
3501 for( run3 = 0; run3 < nOfNewtonSteps[5]; run3++){
3502 kH[0][nOfNewtonSteps[0]][diff_index[run1]] =
3503 kH[0][nOfNewtonSteps[0]][diff_index[run1]]
3504 -
l[run3][5][diff_index[run1]]*h[0]*A[5][0];
3506 for( run3 = 0; run3 < nOfNewtonSteps[6]; run3++){
3507 kH[0][nOfNewtonSteps[0]][diff_index[run1]] =
3508 kH[0][nOfNewtonSteps[0]][diff_index[run1]]
3509 -
l[run3][6][diff_index[run1]]*h[0]*A[6][0];
3518 while( newtonsteps >= 0 ){
3524 if(
rhs[0].AD_backward( 3*number_+newtonsteps,
H,
l[newtonsteps][number_] )
3529 for( run1 = 0; run1 <
ndir; run1++ ){
3530 kH[number_][newtonsteps][run1] =
kH[number_][newtonsteps+1][run1]
3531 -
l[newtonsteps][number_][run1];
3533 for( run1 = 0; run1 <
md; run1++ ){
3535 kH[number_][newtonsteps+1][diff_index[run1]]
3536 -
l[newtonsteps][number_][diff_index[run1]]*h[0]*
A[number_][number_]
3543 for( run1 = 0; run1 <
ndir; run1++ ){
3544 nablaH(0,run1) = Hstore[run1];
3546 for( run1 = 0; run1 <
ndir; run1++ ){
3548 nablaH(0,run1) -=
l[run3][0][run1];
3549 for( run3 = 0; run3 < nOfNewtonSteps[1]; run3++)
3550 nablaH(0,run1) -=
l[run3][1][run1];
3551 for( run3 = 0; run3 < nOfNewtonSteps[2]; run3++)
3552 nablaH(0,run1) -=
l[run3][2][run1];
3553 for( run3 = 0; run3 < nOfNewtonSteps[3]; run3++)
3554 nablaH(0,run1) -=
l[run3][3][run1];
3555 for( run3 = 0; run3 < nOfNewtonSteps[4]; run3++)
3556 nablaH(0,run1) -=
l[run3][4][run1];
3557 for( run3 = 0; run3 < nOfNewtonSteps[5]; run3++)
3558 nablaH(0,run1) -=
l[run3][5][run1];
3559 for( run3 = 0; run3 < nOfNewtonSteps[6]; run3++)
3560 nablaH(0,run1) -=
l[run3][6][run1];
3569 int run1, run2, run3, newtonsteps;
3572 for( run2 = 0; run2 <
m; run2++ ){
3573 k [0][0][run2] = 0.0;
3574 k2[0][0][run2] = 0.0;
3580 for( run1 = 0; run1 <
dim; run1++ ){
3583 for( run2 = 0; run2 <
m; run2++ ){
3585 k2[0][run1][run2] =
k2[nOfNewtonSteps[run1-1]][run1-1][run2];
3592 for( run2 = 0; run2 <
md; run2++ ){
3594 G3[diff_index[run2]] =
etaG3[run2];
3595 for( run3 = 0; run3 < run1; run3++ ){
3596 G2[diff_index[run2]] =
G2[diff_index[run2]] +
3598 G3[diff_index[run2]] =
G3[diff_index[run2]] +
3599 A[run1][run3]*
h[0]*
k2[nOfNewtonSteps[run3]][run3][run2];
3601 G2[diff_index[run2]] =
G2[diff_index[run2]] +
3602 A[run1][run1]*
h[0]*
k [newtonsteps][run1][run2];
3603 G3[diff_index[run2]] =
G3[diff_index[run2]] +
3604 A[run1][run1]*
h[0]*
k2[newtonsteps][run1][run2];
3606 for( run2 = 0; run2 <
ma; run2++ ){
3608 G3[diff_index[md+run2]] =
k2[newtonsteps][run1][md+run2];
3610 for( run2 = 0; run2 <
md; run2++ ){
3612 G3[ddiff_index[run2]] =
k2[newtonsteps][run1][run2];
3615 if(
rhs[0].AD_forward2( 3*run1+newtonsteps,
G2,
G3,
F,
F2 )
3623 k[newtonsteps][run1] ,
3627 k2[newtonsteps][run1] ,
3638 for( run1 = 0; run1 <
nstep-1; run1++ ){
3639 for( run2 = 0; run2 <
md; run2++ ){
3642 for( run3 = 0; run3 <= run1+3; run3++ ){
3646 h[0]*
A[run1+3][run3]*
k2[nOfNewtonSteps[run3]][run3][run2];
3649 for( run2 = 0; run2 <
ma; run2++ ){
3651 nablaG3(nstep-2-run1,md+run2) =
k2[nOfNewtonSteps[run1+3]][run1+3][md+run2];
3659 int run1, run2, run3, run4, newtonsteps;
3660 const double hhh =
c[3]*
h[0];
3663 double *H1store =
new double[
ndir];
3664 double *H2store =
new double[
ndir];
3668 for( run4 = 0; run4 <
nBDirs2; run4++ ){
3670 for( run3 = 0; run3 < 4; run3++ ){
3671 for( run1 = 0; run1 <
dim; run1++ ){
3672 for( run2 = 0; run2 <
ndir; run2++ ){
3673 l [run3][run1][run2] = 0.0;
3674 l2[run3][run1][run2] = 0.0;
3679 for( run1 = 0; run1 <
ndir; run1++ ){
3680 H1store[run1] =
nablaH2(0,run1);
3681 H2store[run1] =
nablaH3(0,run1);
3684 for( run1 = 0; run1 <
ndir; run1++ ){
3688 zH2[3][run1] = -
zH2[5][run1]/(3.0);
3690 zH2[1][run1] = (
zH2[3][run1]-
zH2[4][run1])/(2.0);
3691 zH2[0][run1] = -
zH2[3][run1]/(2.0);
3695 zH3[3][run1] = -
zH3[5][run1]/(3.0);
3697 zH3[1][run1] = (
zH3[3][run1]-
zH3[4][run1])/(2.0);
3698 zH3[0][run1] = -
zH3[3][run1]/(2.0);
3712 for( run1 = 0; run1 <
ndir; run1++ ){
3714 kH3[6][nOfNewtonSteps[6]][run1] =
nablaH3(3,run1)/h[0];
3716 for( run1 = 0; run1 <
md; run1++ ){
3728 while( newtonsteps >= 0 ){
3739 if(
rhs[0].AD_backward2( 3*number_+newtonsteps,
H2,
H3,
3740 l[newtonsteps][number_],
l2[newtonsteps][number_] )
3746 for( run1 = 0; run1 <
ndir; run1++ ){
3747 kH2[number_][newtonsteps][run1] =
kH2[number_][newtonsteps+1][run1]
3748 -
l[newtonsteps][number_][run1];
3749 kH3[number_][newtonsteps][run1] =
kH3[number_][newtonsteps+1][run1]
3750 -
l2[newtonsteps][number_][run1];
3752 for( run1 = 0; run1 <
md; run1++ ){
3754 kH2[number_][newtonsteps+1][diff_index[run1]]
3755 -
l[newtonsteps][number_][diff_index[run1]]*h[0]*
A[number_][number_]
3757 kH3[number_][newtonsteps][diff_index[run1]] =
3758 kH3[number_][newtonsteps+1][diff_index[run1]]
3759 -
l2[newtonsteps][number_][diff_index[run1]]*h[0]*
A[number_][number_]
3760 -
l2[newtonsteps][number_][ddiff_index[run1]];
3766 for( run1 = 0; run1 <
ndir; run1++ ){
3768 kH3[5][nOfNewtonSteps[5]][run1] =
kH3[6][0][run1] +
nablaH3(2,run1)/h[0];
3770 for( run1 = 0; run1 <
md; run1++ ){
3772 +
nablaH2(3,diff_index[run1])*
A[6][5]
3773 +
nablaH2(2,diff_index[run1])*
A[5][5];
3775 kH2[5][nOfNewtonSteps[5]][diff_index[run1]] =
3776 kH2[5][nOfNewtonSteps[5]][diff_index[run1]]
3777 -
l[run3][number_][diff_index[run1]]*h[0]*A[6][5];
3779 kH3[5][nOfNewtonSteps[5]][diff_index[run1]] =
kH3[6][0][diff_index[run1]]
3780 +
nablaH3(3,diff_index[run1])*A[6][5]
3781 +
nablaH3(2,diff_index[run1])*A[5][5];
3782 for( run3 = 0; run3 < nOfNewtonSteps[6]; run3++){
3783 kH3[5][nOfNewtonSteps[5]][diff_index[run1]] =
3784 kH3[5][nOfNewtonSteps[5]][diff_index[run1]]
3785 -
l2[run3][number_][diff_index[run1]]*h[0]*A[6][5];
3795 while( newtonsteps >= 0 ){
3804 if(
rhs[0].AD_backward2( 3*number_+newtonsteps,
H2,
H3,
3805 l[newtonsteps][number_],
l2[newtonsteps][number_] )
3811 for( run1 = 0; run1 <
ndir; run1++ ){
3812 kH2[number_][newtonsteps][run1] =
kH2[number_][newtonsteps+1][run1]
3813 -
l[newtonsteps][number_][run1];
3814 kH3[number_][newtonsteps][run1] =
kH3[number_][newtonsteps+1][run1]
3815 -
l2[newtonsteps][number_][run1];
3817 for( run1 = 0; run1 <
md; run1++ ){
3819 kH2[number_][newtonsteps+1][diff_index[run1]]
3820 -
l[newtonsteps][number_][diff_index[run1]]*h[0]*
A[number_][number_]
3822 kH3[number_][newtonsteps][diff_index[run1]] =
3823 kH3[number_][newtonsteps+1][diff_index[run1]]
3824 -
l2[newtonsteps][number_][diff_index[run1]]*h[0]*
A[number_][number_]
3825 -
l2[newtonsteps][number_][ddiff_index[run1]];
3832 for( run1 = 0; run1 <
ndir; run1++ ){
3834 kH3[4][nOfNewtonSteps[4]][run1] =
kH3[5][0][run1] +
nablaH3(1,run1)/h[0];
3836 for( run1 = 0; run1 <
md; run1++ ){
3838 +
nablaH2(3,diff_index[run1])*
A[6][4]
3839 +
nablaH2(2,diff_index[run1])*
A[5][4]
3840 +
nablaH2(1,diff_index[run1])*
A[4][4];
3842 kH2[4][nOfNewtonSteps[4]][diff_index[run1]] =
3843 kH2[4][nOfNewtonSteps[4]][diff_index[run1]]
3844 -
l[run3][5][diff_index[run1]]*h[0]*A[5][4];
3846 for( run3 = 0; run3 < nOfNewtonSteps[6]; run3++){
3847 kH2[4][nOfNewtonSteps[4]][diff_index[run1]] =
3848 kH2[4][nOfNewtonSteps[4]][diff_index[run1]]
3849 -
l[run3][6][diff_index[run1]]*h[0]*A[6][4];
3851 kH3[4][nOfNewtonSteps[4]][diff_index[run1]] =
kH3[5][0][diff_index[run1]]
3852 +
nablaH3(3,diff_index[run1])*A[6][4]
3853 +
nablaH3(2,diff_index[run1])*A[5][4]
3854 +
nablaH3(1,diff_index[run1])*A[4][4];
3855 for( run3 = 0; run3 < nOfNewtonSteps[5]; run3++){
3856 kH3[4][nOfNewtonSteps[4]][diff_index[run1]] =
3857 kH3[4][nOfNewtonSteps[4]][diff_index[run1]]
3858 -
l2[run3][5][diff_index[run1]]*h[0]*A[5][4];
3860 for( run3 = 0; run3 < nOfNewtonSteps[6]; run3++){
3861 kH3[4][nOfNewtonSteps[4]][diff_index[run1]] =
3862 kH3[4][nOfNewtonSteps[4]][diff_index[run1]]
3863 -
l2[run3][6][diff_index[run1]]*h[0]*A[6][4];
3873 while( newtonsteps >= 0 ){
3882 if(
rhs[0].AD_backward2( 3*number_+newtonsteps,
H2,
H3,
3883 l[newtonsteps][number_],
l2[newtonsteps][number_] )
3889 for( run1 = 0; run1 <
ndir; run1++ ){
3890 kH2[number_][newtonsteps][run1] =
kH2[number_][newtonsteps+1][run1]
3891 -
l[newtonsteps][number_][run1];
3892 kH3[number_][newtonsteps][run1] =
kH3[number_][newtonsteps+1][run1]
3893 -
l2[newtonsteps][number_][run1];
3895 for( run1 = 0; run1 <
md; run1++ ){
3897 kH2[number_][newtonsteps+1][diff_index[run1]]
3898 -
l[newtonsteps][number_][diff_index[run1]]*h[0]*
A[number_][number_]
3900 kH3[number_][newtonsteps][diff_index[run1]] =
3901 kH3[number_][newtonsteps+1][diff_index[run1]]
3902 -
l2[newtonsteps][number_][diff_index[run1]]*h[0]*
A[number_][number_]
3903 -
l2[newtonsteps][number_][ddiff_index[run1]];
3910 for( run1 = 0; run1 <
ndir; run1++ ){
3912 kH3[3][nOfNewtonSteps[3]][run1] =
kH3[4][0][run1] +
nablaH3(0,run1)/h[0];
3914 for( run1 = 0; run1 <
md; run1++ ){
3916 +
nablaH2(3,diff_index[run1])*
A[6][3]
3917 +
nablaH2(2,diff_index[run1])*
A[5][3]
3918 +
nablaH2(1,diff_index[run1])*
A[4][3]
3919 +
nablaH2(0,diff_index[run1])*
A[3][3];
3921 kH2[3][nOfNewtonSteps[3]][diff_index[run1]] =
3922 kH2[3][nOfNewtonSteps[3]][diff_index[run1]]
3923 -
l[run3][4][diff_index[run1]]*h[0]*A[4][3];
3925 for( run3 = 0; run3 < nOfNewtonSteps[5]; run3++){
3926 kH2[3][nOfNewtonSteps[3]][diff_index[run1]] =
3927 kH2[3][nOfNewtonSteps[3]][diff_index[run1]]
3928 -
l[run3][5][diff_index[run1]]*h[0]*A[5][3];
3930 for( run3 = 0; run3 < nOfNewtonSteps[6]; run3++){
3931 kH2[3][nOfNewtonSteps[3]][diff_index[run1]] =
3932 kH2[3][nOfNewtonSteps[3]][diff_index[run1]]
3933 -
l[run3][6][diff_index[run1]]*h[0]*A[6][3];
3935 kH3[3][nOfNewtonSteps[3]][diff_index[run1]] =
kH3[4][0][diff_index[run1]]
3936 +
nablaH3(3,diff_index[run1])*A[6][3]
3937 +
nablaH3(2,diff_index[run1])*A[5][3]
3938 +
nablaH3(1,diff_index[run1])*A[4][3]
3939 +
nablaH3(0,diff_index[run1])*A[3][3];
3940 for( run3 = 0; run3 < nOfNewtonSteps[4]; run3++){
3941 kH3[3][nOfNewtonSteps[3]][diff_index[run1]] =
3942 kH3[3][nOfNewtonSteps[3]][diff_index[run1]]
3943 -
l2[run3][4][diff_index[run1]]*h[0]*A[4][3];
3945 for( run3 = 0; run3 < nOfNewtonSteps[5]; run3++){
3946 kH3[3][nOfNewtonSteps[3]][diff_index[run1]] =
3947 kH3[3][nOfNewtonSteps[3]][diff_index[run1]]
3948 -
l2[run3][5][diff_index[run1]]*h[0]*A[5][3];
3950 for( run3 = 0; run3 < nOfNewtonSteps[6]; run3++){
3951 kH3[3][nOfNewtonSteps[3]][diff_index[run1]] =
3952 kH3[3][nOfNewtonSteps[3]][diff_index[run1]]
3953 -
l2[run3][6][diff_index[run1]]*h[0]*A[6][3];
3963 while( newtonsteps >= 0 ){
3972 if(
rhs[0].AD_backward2( 3*number_+newtonsteps,
H2,
H3,
3973 l[newtonsteps][number_],
l2[newtonsteps][number_] )
3979 for( run1 = 0; run1 <
ndir; run1++ ){
3980 kH2[number_][newtonsteps][run1] =
kH2[number_][newtonsteps+1][run1]
3981 -
l[newtonsteps][number_][run1];
3982 kH3[number_][newtonsteps][run1] =
kH3[number_][newtonsteps+1][run1]
3983 -
l2[newtonsteps][number_][run1];
3985 for( run1 = 0; run1 <
md; run1++ ){
3987 kH2[number_][newtonsteps+1][diff_index[run1]]
3988 -
l[newtonsteps][number_][diff_index[run1]]*h[0]*
A[number_][number_]
3990 kH3[number_][newtonsteps][diff_index[run1]] =
3991 kH3[number_][newtonsteps+1][diff_index[run1]]
3992 -
l2[newtonsteps][number_][diff_index[run1]]*h[0]*
A[number_][number_]
3993 -
l2[newtonsteps][number_][ddiff_index[run1]];
4000 for( run1 = 0; run1 <
ndir; run1++ ){
4002 kH3[2][nOfNewtonSteps[2]][run1] =
kH3[3][0][run1];
4004 for( run1 = 0; run1 <
md; run1++ ){
4006 +
nablaH2(3,diff_index[run1])*
A[6][2]
4007 +
nablaH2(2,diff_index[run1])*
A[5][2]
4008 +
nablaH2(1,diff_index[run1])*
A[4][2]
4009 +
nablaH2(0,diff_index[run1])*
A[3][2];
4011 kH2[2][nOfNewtonSteps[2]][diff_index[run1]] =
4012 kH2[2][nOfNewtonSteps[2]][diff_index[run1]]
4013 -
l[run3][3][diff_index[run1]]*h[0]*A[3][2];
4015 for( run3 = 0; run3 < nOfNewtonSteps[4]; run3++){
4016 kH2[2][nOfNewtonSteps[2]][diff_index[run1]] =
4017 kH2[2][nOfNewtonSteps[2]][diff_index[run1]]
4018 -
l[run3][4][diff_index[run1]]*h[0]*A[4][2];
4020 for( run3 = 0; run3 < nOfNewtonSteps[5]; run3++){
4021 kH2[2][nOfNewtonSteps[2]][diff_index[run1]] =
4022 kH2[2][nOfNewtonSteps[2]][diff_index[run1]]
4023 -
l[run3][5][diff_index[run1]]*h[0]*A[5][2];
4025 for( run3 = 0; run3 < nOfNewtonSteps[6]; run3++){
4026 kH2[2][nOfNewtonSteps[2]][diff_index[run1]] =
4027 kH2[2][nOfNewtonSteps[2]][diff_index[run1]]
4028 -
l[run3][6][diff_index[run1]]*h[0]*A[6][2];
4030 kH3[2][nOfNewtonSteps[2]][diff_index[run1]] =
kH3[3][0][diff_index[run1]]
4031 +
nablaH3(3,diff_index[run1])*A[6][2]
4032 +
nablaH3(2,diff_index[run1])*A[5][2]
4033 +
nablaH3(1,diff_index[run1])*A[4][2]
4034 +
nablaH3(0,diff_index[run1])*A[3][2];
4035 for( run3 = 0; run3 < nOfNewtonSteps[3]; run3++){
4036 kH3[2][nOfNewtonSteps[2]][diff_index[run1]] =
4037 kH3[2][nOfNewtonSteps[2]][diff_index[run1]]
4038 -
l2[run3][3][diff_index[run1]]*h[0]*A[3][2];
4040 for( run3 = 0; run3 < nOfNewtonSteps[4]; run3++){
4041 kH3[2][nOfNewtonSteps[2]][diff_index[run1]] =
4042 kH3[2][nOfNewtonSteps[2]][diff_index[run1]]
4043 -
l2[run3][4][diff_index[run1]]*h[0]*A[4][2];
4045 for( run3 = 0; run3 < nOfNewtonSteps[5]; run3++){
4046 kH3[2][nOfNewtonSteps[2]][diff_index[run1]] =
4047 kH3[2][nOfNewtonSteps[2]][diff_index[run1]]
4048 -
l2[run3][5][diff_index[run1]]*h[0]*A[5][2];
4050 for( run3 = 0; run3 < nOfNewtonSteps[6]; run3++){
4051 kH3[2][nOfNewtonSteps[2]][diff_index[run1]] =
4052 kH3[2][nOfNewtonSteps[2]][diff_index[run1]]
4053 -
l2[run3][6][diff_index[run1]]*h[0]*A[6][2];
4063 while( newtonsteps >= 0 ){
4072 if(
rhs[0].AD_backward2( 3*number_+newtonsteps,
H2,
H3,
4073 l[newtonsteps][number_],
l2[newtonsteps][number_] )
4079 for( run1 = 0; run1 <
ndir; run1++ ){
4080 kH2[number_][newtonsteps][run1] =
kH2[number_][newtonsteps+1][run1]
4081 -
l[newtonsteps][number_][run1];
4082 kH3[number_][newtonsteps][run1] =
kH3[number_][newtonsteps+1][run1]
4083 -
l2[newtonsteps][number_][run1];
4085 for( run1 = 0; run1 <
md; run1++ ){
4087 kH2[number_][newtonsteps+1][diff_index[run1]]
4088 -
l[newtonsteps][number_][diff_index[run1]]*h[0]*
A[number_][number_]
4090 kH3[number_][newtonsteps][diff_index[run1]] =
4091 kH3[number_][newtonsteps+1][diff_index[run1]]
4092 -
l2[newtonsteps][number_][diff_index[run1]]*h[0]*
A[number_][number_]
4093 -
l2[newtonsteps][number_][ddiff_index[run1]];
4100 for( run1 = 0; run1 <
ndir; run1++ ){
4102 kH3[1][nOfNewtonSteps[1]][run1] =
kH3[2][0][run1];
4104 for( run1 = 0; run1 <
md; run1++ ){
4106 +
nablaH2(3,diff_index[run1])*
A[6][1]
4107 +
nablaH2(2,diff_index[run1])*
A[5][1]
4108 +
nablaH2(1,diff_index[run1])*
A[4][1]
4109 +
nablaH2(0,diff_index[run1])*
A[3][1];
4111 kH2[1][nOfNewtonSteps[1]][diff_index[run1]] =
4112 kH2[1][nOfNewtonSteps[1]][diff_index[run1]]
4113 -
l[run3][2][diff_index[run1]]*h[0]*A[2][1];
4115 for( run3 = 0; run3 < nOfNewtonSteps[3]; run3++){
4116 kH2[1][nOfNewtonSteps[1]][diff_index[run1]] =
4117 kH2[1][nOfNewtonSteps[1]][diff_index[run1]]
4118 -
l[run3][3][diff_index[run1]]*h[0]*A[3][1];
4120 for( run3 = 0; run3 < nOfNewtonSteps[4]; run3++){
4121 kH2[1][nOfNewtonSteps[1]][diff_index[run1]] =
4122 kH2[1][nOfNewtonSteps[1]][diff_index[run1]]
4123 -
l[run3][4][diff_index[run1]]*h[0]*A[4][1];
4125 for( run3 = 0; run3 < nOfNewtonSteps[5]; run3++){
4126 kH2[1][nOfNewtonSteps[1]][diff_index[run1]] =
4127 kH2[1][nOfNewtonSteps[1]][diff_index[run1]]
4128 -
l[run3][5][diff_index[run1]]*h[0]*A[5][1];
4130 for( run3 = 0; run3 < nOfNewtonSteps[6]; run3++){
4131 kH2[1][nOfNewtonSteps[1]][diff_index[run1]] =
4132 kH2[1][nOfNewtonSteps[1]][diff_index[run1]]
4133 -
l[run3][6][diff_index[run1]]*h[0]*A[6][1];
4135 kH3[1][nOfNewtonSteps[1]][diff_index[run1]] =
kH3[2][0][diff_index[run1]]
4136 +
nablaH3(3,diff_index[run1])*A[6][1]
4137 +
nablaH3(2,diff_index[run1])*A[5][1]
4138 +
nablaH3(1,diff_index[run1])*A[4][1]
4139 +
nablaH3(0,diff_index[run1])*A[3][1];
4140 for( run3 = 0; run3 < nOfNewtonSteps[2]; run3++){
4141 kH3[1][nOfNewtonSteps[1]][diff_index[run1]] =
4142 kH3[1][nOfNewtonSteps[1]][diff_index[run1]]
4143 -
l2[run3][2][diff_index[run1]]*h[0]*A[2][1];
4145 for( run3 = 0; run3 < nOfNewtonSteps[3]; run3++){
4146 kH3[1][nOfNewtonSteps[1]][diff_index[run1]] =
4147 kH3[1][nOfNewtonSteps[1]][diff_index[run1]]
4148 -
l2[run3][3][diff_index[run1]]*h[0]*A[3][1];
4150 for( run3 = 0; run3 < nOfNewtonSteps[4]; run3++){
4151 kH3[1][nOfNewtonSteps[1]][diff_index[run1]] =
4152 kH3[1][nOfNewtonSteps[1]][diff_index[run1]]
4153 -
l2[run3][4][diff_index[run1]]*h[0]*A[4][1];
4155 for( run3 = 0; run3 < nOfNewtonSteps[5]; run3++){
4156 kH3[1][nOfNewtonSteps[1]][diff_index[run1]] =
4157 kH3[1][nOfNewtonSteps[1]][diff_index[run1]]
4158 -
l2[run3][5][diff_index[run1]]*h[0]*A[5][1];
4160 for( run3 = 0; run3 < nOfNewtonSteps[6]; run3++){
4161 kH3[1][nOfNewtonSteps[1]][diff_index[run1]] =
4162 kH3[1][nOfNewtonSteps[1]][diff_index[run1]]
4163 -
l2[run3][6][diff_index[run1]]*h[0]*A[6][1];
4173 while( newtonsteps >= 0 ){
4182 if(
rhs[0].AD_backward2( 3*number_+newtonsteps,
H2,
H3,
4183 l[newtonsteps][number_],
l2[newtonsteps][number_] )
4189 for( run1 = 0; run1 <
ndir; run1++ ){
4190 kH2[number_][newtonsteps][run1] =
kH2[number_][newtonsteps+1][run1]
4191 -
l[newtonsteps][number_][run1];
4192 kH3[number_][newtonsteps][run1] =
kH3[number_][newtonsteps+1][run1]
4193 -
l2[newtonsteps][number_][run1];
4195 for( run1 = 0; run1 <
md; run1++ ){
4197 kH2[number_][newtonsteps+1][diff_index[run1]]
4198 -
l[newtonsteps][number_][diff_index[run1]]*h[0]*
A[number_][number_]
4200 kH3[number_][newtonsteps][diff_index[run1]] =
4201 kH3[number_][newtonsteps+1][diff_index[run1]]
4202 -
l2[newtonsteps][number_][diff_index[run1]]*h[0]*
A[number_][number_]
4203 -
l2[newtonsteps][number_][ddiff_index[run1]];
4211 for( run1 = 0; run1 <
ndir; run1++ ){
4213 kH3[0][nOfNewtonSteps[0]][run1] =
kH3[1][0][run1];
4215 for( run1 = 0; run1 <
md; run1++ ){
4217 +
nablaH2(3,diff_index[run1])*
A[6][0]
4218 +
nablaH2(2,diff_index[run1])*
A[5][0]
4219 +
nablaH2(1,diff_index[run1])*
A[4][0]
4220 +
nablaH2(0,diff_index[run1])*
A[3][0];
4222 kH2[0][nOfNewtonSteps[0]][diff_index[run1]] =
4223 kH2[0][nOfNewtonSteps[0]][diff_index[run1]]
4224 -
l[run3][1][diff_index[run1]]*h[0]*A[1][0];
4226 for( run3 = 0; run3 < nOfNewtonSteps[2]; run3++){
4227 kH2[0][nOfNewtonSteps[0]][diff_index[run1]] =
4228 kH2[0][nOfNewtonSteps[0]][diff_index[run1]]
4229 -
l[run3][2][diff_index[run1]]*h[0]*A[2][0];
4231 for( run3 = 0; run3 < nOfNewtonSteps[3]; run3++){
4232 kH2[0][nOfNewtonSteps[0]][diff_index[run1]] =
4233 kH2[0][nOfNewtonSteps[0]][diff_index[run1]]
4234 -
l[run3][3][diff_index[run1]]*h[0]*A[3][0];
4236 for( run3 = 0; run3 < nOfNewtonSteps[4]; run3++){
4237 kH2[0][nOfNewtonSteps[0]][diff_index[run1]] =
4238 kH2[0][nOfNewtonSteps[0]][diff_index[run1]]
4239 -
l[run3][4][diff_index[run1]]*h[0]*A[4][0];
4241 for( run3 = 0; run3 < nOfNewtonSteps[5]; run3++){
4242 kH2[0][nOfNewtonSteps[0]][diff_index[run1]] =
4243 kH2[0][nOfNewtonSteps[0]][diff_index[run1]]
4244 -
l[run3][5][diff_index[run1]]*h[0]*A[5][0];
4246 for( run3 = 0; run3 < nOfNewtonSteps[6]; run3++){
4247 kH2[0][nOfNewtonSteps[0]][diff_index[run1]] =
4248 kH2[0][nOfNewtonSteps[0]][diff_index[run1]]
4249 -
l[run3][6][diff_index[run1]]*h[0]*A[6][0];
4251 kH3[0][nOfNewtonSteps[0]][diff_index[run1]] =
kH3[1][0][diff_index[run1]]
4252 +
nablaH3(3,diff_index[run1])*A[6][0]
4253 +
nablaH3(2,diff_index[run1])*A[5][0]
4254 +
nablaH3(1,diff_index[run1])*A[4][0]
4255 +
nablaH3(0,diff_index[run1])*A[3][0];
4256 for( run3 = 0; run3 < nOfNewtonSteps[1]; run3++){
4257 kH3[0][nOfNewtonSteps[0]][diff_index[run1]] =
4258 kH3[0][nOfNewtonSteps[0]][diff_index[run1]]
4259 -
l2[run3][1][diff_index[run1]]*h[0]*A[1][0];
4261 for( run3 = 0; run3 < nOfNewtonSteps[2]; run3++){
4262 kH3[0][nOfNewtonSteps[0]][diff_index[run1]] =
4263 kH3[0][nOfNewtonSteps[0]][diff_index[run1]]
4264 -
l2[run3][2][diff_index[run1]]*h[0]*A[2][0];
4266 for( run3 = 0; run3 < nOfNewtonSteps[3]; run3++){
4267 kH3[0][nOfNewtonSteps[0]][diff_index[run1]] =
4268 kH3[0][nOfNewtonSteps[0]][diff_index[run1]]
4269 -
l2[run3][3][diff_index[run1]]*h[0]*A[3][0];
4271 for( run3 = 0; run3 < nOfNewtonSteps[4]; run3++){
4272 kH3[0][nOfNewtonSteps[0]][diff_index[run1]] =
4273 kH3[0][nOfNewtonSteps[0]][diff_index[run1]]
4274 -
l2[run3][4][diff_index[run1]]*h[0]*A[4][0];
4276 for( run3 = 0; run3 < nOfNewtonSteps[5]; run3++){
4277 kH3[0][nOfNewtonSteps[0]][diff_index[run1]] =
4278 kH3[0][nOfNewtonSteps[0]][diff_index[run1]]
4279 -
l2[run3][5][diff_index[run1]]*h[0]*A[5][0];
4281 for( run3 = 0; run3 < nOfNewtonSteps[6]; run3++){
4282 kH3[0][nOfNewtonSteps[0]][diff_index[run1]] =
4283 kH3[0][nOfNewtonSteps[0]][diff_index[run1]]
4284 -
l2[run3][6][diff_index[run1]]*h[0]*A[6][0];
4293 while( newtonsteps >= 0 ){
4302 if(
rhs[0].AD_backward2( 3*number_+newtonsteps,
H2,
H3,
4303 l[newtonsteps][number_],
l2[newtonsteps][number_] )
4309 for( run1 = 0; run1 <
ndir; run1++ ){
4310 kH2[number_][newtonsteps][run1] =
kH2[number_][newtonsteps+1][run1]
4311 -
l[newtonsteps][number_][run1];
4312 kH3[number_][newtonsteps][run1] =
kH3[number_][newtonsteps+1][run1]
4313 -
l2[newtonsteps][number_][run1];
4315 for( run1 = 0; run1 <
md; run1++ ){
4317 kH2[number_][newtonsteps+1][diff_index[run1]]
4318 -
l[newtonsteps][number_][diff_index[run1]]*h[0]*
A[number_][number_]
4320 kH3[number_][newtonsteps][diff_index[run1]] =
4321 kH3[number_][newtonsteps+1][diff_index[run1]]
4322 -
l2[newtonsteps][number_][diff_index[run1]]*h[0]*
A[number_][number_]
4323 -
l2[newtonsteps][number_][ddiff_index[run1]];
4330 for( run1 = 0; run1 <
ndir; run1++ ){
4331 nablaH2(0,run1) = H1store[run1];
4332 nablaH3(0,run1) = H2store[run1];
4335 for( run1 = 0; run1 <
ndir; run1++ ){
4337 for( run2 = 0; run2 <
dim; run2++ ){
4339 -
l[run3][run2][run1];
4341 -
l2[run3][run2][run1];
4355 int run1, run2, run4;
4361 for( run4 = 0; run4 <
nFDirs; run4++ ){
4363 for( run1 = 0; run1 <
m; run1++ ){
4367 pp = (
psi[number_][1]/
psi[number_][0]);
4368 for( run1 = 0; run1 <
m; run1++ ){
4369 phiG(2,run1) = pp*
nablaG(2,run1)*scalT*scalT;
4372 pp = pp*(
psi[number_][2]/
psi[number_][0]);
4373 for( run1 = 0; run1 <
m; run1++ ){
4374 phiG(3,run1) = pp*
nablaG(3,run1)*scalT*scalT*scalT;
4377 pp = pp*(
psi[number_][3]/
psi[number_][0]);
4378 for( run1 = 0; run1 <
m; run1++ ){
4379 phiG(4,run1) = pp*
nablaG(4,run1)*scalT*scalT*scalT*scalT;
4382 for( run1 = 0; run1 <
m; run1++ ){
4386 for( run1 = 0; run1 <
m; run1++ ){
4390 for( run1 = 0; run1 <
m; run1++ ){
4394 for( run1 = 0; run1 <
m; run1++ ){
4399 for( run1 = 0; run1 <
md; run1++ ){
4410 for( run2 = 0; run2 <
m; run2++ ){
4413 for( run2 = 0; run2 <
md; run2++ ){
4415 gamma[number_][4]*
eta[newtonsteps][run2]+
c2G(run2);
4418 if(
rhs[0].AD_forward( 3*number_+newtonsteps,
G,
F )
4431 for( run1 = 0; run1 <
m; run1++ ){
4454 for( run1 = 0; run1 < newtonsteps; run1++ ){
4455 for( run2 = 0; run2 <
ndir; run2++ ){
4456 l[run1][0][run2] = 0.0;
4460 for( run1 = 0; run1 <
ndir; run1++ ){
4473 while( newtonsteps >= 0 ){
4480 for( run1 = 0; run1 <
ndir; run1++ ){
4481 etaH[newtonsteps][run1] =
etaH[newtonsteps+1][run1] -
l[newtonsteps][0][run1];
4484 for( run1 = 0; run1 <
md; run1++ )
4487 for( run1 = 0; run1 <
md; run1++ )
4494 for( run1 = 0; run1 <
ndir; run1++ ){
4501 for( run1 = 0; run1 <
ndir; run1++ ){
4504 -
c2H(run1) /
psi[number_][0]
4507 pp =
psi[number_][0];
4508 for( run1 = 0; run1 <
ndir; run1++ ){
4512 pp = pp*(
psi[number_][1]/
psi[number_][0]);
4513 for( run1 = 0; run1 <
ndir; run1++ ){
4517 pp = pp*(
psi[number_][2]/
psi[number_][0]);
4519 for( run1 = 0; run1 <
ndir; run1++ ){
4523 pp = pp*(
psi[number_][3]/
psi[number_][0]);
4525 for( run1 = 0; run1 <
ndir; run1++ ){
4534 int run1, run2, run4;
4540 for( run4 = 0; run4 <
nFDirs2; run4++ ){
4542 for( run1 = 0; run1 <
m; run1++ ){
4545 for( run1 = 0; run1 <
m; run1++ ){
4549 pp = (
psi[number_][1]/
psi[number_][0]);
4550 for( run1 = 0; run1 <
m; run1++ ){
4553 for( run1 = 0; run1 <
m; run1++ ){
4557 pp = pp*(
psi[number_][2]/
psi[number_][0]);
4558 for( run1 = 0; run1 <
m; run1++ ){
4561 for( run1 = 0; run1 <
m; run1++ ){
4565 pp = pp*(
psi[number_][3]/
psi[number_][0]);
4566 for( run1 = 0; run1 <
m; run1++ ){
4567 phiG2(4,run1) = pp*
nablaG2(4,run1)*scalT*scalT*scalT*scalT;
4569 for( run1 = 0; run1 <
m; run1++ ){
4570 phiG3(4,run1) = pp*
nablaG3(4,run1)*scalT*scalT*scalT*scalT;
4573 for( run1 = 0; run1 <
m; run1++ ){
4576 for( run1 = 0; run1 <
m; run1++ ){
4580 for( run1 = 0; run1 <
m; run1++ ){
4583 for( run1 = 0; run1 <
m; run1++ ){
4587 for( run1 = 0; run1 <
m; run1++ ){
4590 for( run1 = 0; run1 <
m; run1++ ){
4594 for( run1 = 0; run1 <
m; run1++ ){
4597 for( run1 = 0; run1 <
m; run1++ ){
4601 for( run1 = 0; run1 <
md; run1++ ){
4608 for( run1 = 0; run1 <
md; run1++ ){
4619 for( run2 = 0; run2 <
m; run2++ ){
4621 G3[diff_index[run2]] =
eta2[newtonsteps][run2];
4623 for( run2 = 0; run2 <
md; run2++ ){
4626 G3[ddiff_index[run2]] =
4630 if(
rhs[0].AD_forward2( 3*number_+newtonsteps,
G2,
G3,
F,
F2 )
4648 for( run1 = 0; run1 <
m; run1++ ){
4658 for( run1 = 0; run1 <
m; run1++ ){
4673 int run1, run2, run4;
4679 for( run4 = 0; run4 <
nBDirs2; run4++ ){
4683 for( run1 = 0; run1 < newtonsteps; run1++ ){
4684 for( run2 = 0; run2 <
ndir; run2++ ){
4685 l [run1][0][run2] = 0.0;
4686 l2[run1][0][run2] = 0.0;
4690 for( run1 = 0; run1 <
ndir; run1++ ){
4711 while( newtonsteps >= 0 ){
4721 if(
rhs[0].AD_backward2( 3*number_+newtonsteps,
H2,
H3,
4722 l[newtonsteps][0],
l2[newtonsteps][0] )
4727 for( run1 = 0; run1 <
ndir; run1++ ){
4728 etaH2[newtonsteps][run1] =
etaH2[newtonsteps+1][run1] -
4729 l [newtonsteps][0][run1];
4730 etaH3[newtonsteps][run1] =
etaH3[newtonsteps+1][run1] -
4731 l2[newtonsteps][0][run1];
4734 for( run1 = 0; run1 <
md; run1++ ){
4736 etaH2[newtonsteps][diff_index[run1]] -
4738 etaH3[newtonsteps][diff_index[run1]] =
4739 etaH3[newtonsteps][diff_index[run1]] -
4743 for( run1 = 0; run1 <
md; run1++ ){
4751 for( run1 = 0; run1 <
ndir; run1++ ){
4762 for( run1 = 0; run1 <
ndir; run1++ ){
4771 pp =
psi[number_][0];
4772 for( run1 = 0; run1 <
ndir; run1++ ){
4778 pp = pp*(
psi[number_][1]/
psi[number_][0]);
4779 for( run1 = 0; run1 <
ndir; run1++ ){
4785 pp = pp*(
psi[number_][2]/
psi[number_][0]);
4786 for( run1 = 0; run1 <
ndir; run1++ ){
4792 pp = pp*(
psi[number_][3]/
psi[number_][0]);
4793 for( run1 = 0; run1 <
ndir; run1++ ){
4821 A[2][0] = 0.1310450349650284 ;
4822 A[2][1] = 0.07295496503497158102;
4829 A[3][0] = 0.2199597787833081951;
4830 A[3][1] = -0.1447179487179487179;
4831 A[3][2] = 0.02875816993464052288;
4837 A[4][0] = 0.1608848667672197084;
4838 A[4][1] = -0.0512400094214750;
4839 A[4][2] = -0.02467973856209150327;
4840 A[4][3] = 0.2190348812163467684;
4845 A[5][0] = 0.1761704161863276;
4846 A[5][1] = -0.2376951929172075;
4847 A[5][2] = 0.1249803878146932;
4848 A[5][3] = 0.3034259664066430296;
4849 A[5][4] = 0.1371184225095437181;
4853 A[6][0] = 0.1822523881347410759;
4854 A[6][1] = -0.3465441147470548;
4855 A[6][2] = 0.213542483660130719;
4856 A[6][3] = 0.3547492429521829614;
4865 b4[3] = 0.4583333333333333333;
4866 b4[4] = 0.04166666666666666667;
4867 b4[5] = 0.04166666666666666667;
4868 b4[6] = 0.4583333333333333333;
4870 b5[0] = -0.3413924474339141;
4871 b5[1] = 0.8554210048117954;
4872 b5[2] = -0.5726796951403962;
4873 b5[3] = 0.4498353628579520;
4874 b5[4] = 0.0888157749045627;
4875 b5[5] = 0.0400000000000000;
4876 b5[6] = 0.4800000000000000;
4893 cout <<
"w.r.t. the states:\n" << scientific;
4894 for( run2 = 0; run2 <
md; run2++ ){
4900 cout <<
"w.r.t. the controls:\n" << scientific;
4901 for( run2 = 0; run2 <
mu; run2++ ){
4907 cout <<
"w.r.t. the parameters:\n" << scientific;
4908 for( run2 = 0; run2 <
mp; run2++ ){
4914 cout <<
"w.r.t. the diturbances:\n" << scientific;
4915 for( run2 = 0; run2 <
mw; run2++ ){
4934 cout <<
"BDF: Forward Sensitivities:\n";
4935 for( run1 = 0; run1 <
m; run1++ ){
4944 cout <<
"BDF: First Order Forward Sensitivities:\n";
4945 for( run1 = 0; run1 <
m; run1++ ){
4950 cout <<
"BDF: Second Order Forward Sensitivities:\n";
4951 for( run1 = 0; run1 <
m; run1++ ){
4961 cout <<
"BDF: t = " <<
t-
c[6]*
h[0] <<
" h = " <<
h[0] << endl;
4962 cout <<
"BDF: Backward Sensitivities:\n";
4970 cout <<
"BDF: t = " <<
t-
c[6]*
h[0] <<
" h = " <<
h[0] << endl;
4972 cout <<
"BDF: Backward Sensitivities:\n";
4974 cout <<
"BDF: 2nd order Backward Sensitivities:\n";
4990 cout <<
"BDF: t = " <<
t-
c[6]*
h[0] <<
" h = " <<
h[0] << endl;
4994 for( run1 = 0; run1 <
md; run1++ ){
4995 cout <<
"x[" << run1 <<
"] = " <<
nablaY(0,run1) <<
" ";
4997 for( run1 = 0; run1 <
ma; run1++ ){
4998 cout <<
"xa[" << run1 <<
"] = " <<
nablaY(0,md + run1) <<
" ";
5011 cout <<
"BDF: Forward Sensitivities:\n";
5012 for( run1 = 0; run1 <
m; run1++ ){
5013 cout <<
nablaG(0,run1) <<
" ";
5020 cout <<
"BDF: First Order Forward Sensitivities:\n";
5021 for( run1 = 0; run1 <
m; run1++ ){
5022 cout <<
nablaG2(0,run1) <<
" ";
5026 cout <<
"BDF: Second Order Forward Sensitivities:\n";
5027 for( run1 = 0; run1 <
m; run1++ ){
5028 cout <<
nablaG3(0,run1) <<
" ";
5045 for( run3 = 0; run3 < 4; run3++ ){
5047 cout <<
"BDF: t = " <<
t+
h[0]*
c[3+run3] <<
" h = " <<
h[0]*
c[3];
5049 for( run1 = 0; run1 <
md; run1++ ){
5050 cout <<
"x[" << run1 <<
"] = " <<
nablaY(3 - run3, run1) <<
" ";
5052 for( run1 = 0; run1 <
ma; run1++ ){
5053 cout <<
"xa[" << run1 <<
"] = " <<
nablaY(3-run3,run1+md) <<
" ";
5066 cout <<
"BDF: Forward Sensitivities:\n";
5067 for( run1 = 0; run1 <
m; run1++ ){
5068 cout <<
nablaG(3-run3,run1) <<
" ";
5075 cout <<
"BDF: First Order Forward Sensitivities:\n";
5076 for( run1 = 0; run1 <
m; run1++ ){
5077 cout <<
nablaG2(3-run3,run1) <<
" ";
5081 cout <<
"BDF: Second Order Forward Sensitivities:\n";
5082 for( run1 = 0; run1 <
m; run1++ ){
5083 cout <<
nablaG3(3-run3,run1) <<
" ";
5094 <<
"BDF: t = " <<
t-
c[6]*
h[0] <<
" h_RK = " <<
h[0] << endl
5095 <<
"BDF: Backward Sensitivities:\n";
5104 <<
"BDF: t = " <<
t-
c[6]*
h[0] <<
" " <<
"h_RK = " <<
h[0] << endl
5105 <<
"BDF: Backward Sensitivities:\n";
5107 cout <<
"BDF: 2nd order Backward Sensitivities:\n";
5149 deltaX = J.householderQr().solve( bb );
5161 for( run1 = 0; run1 <
m; run1++ )
5162 etakplus1[run1] = etak[run1] - deltaX(run1);
5173 for( run1 = 0; run1 <
m; run1++ )
5182 deltaX = J.transpose().householderQr().solve( bb );
5197 for( run1 = 0; run1 <
m; run1++ )
5198 seed2[run1] = deltaX(run1);
5205 int relaxationType ;
5206 double relaxationPar ;
5211 const double b = 1.0;
5212 double damping = 1.0;
5218 switch( relaxationType ){
5222 for( run1 = 0; run1 <
ma; run1++ )
5228 for( run1 = 0; run1 <
ma; run1++ )
5233 b + a/(normRES+100.0*
EPS) );
5242 for( run1 = 0; run1 <
ma; run1++ )
5265 for( run1 = 0; run1 <
m; run1++ ){
5267 div(3,run1) = div(2,run1) - div(3,run1);
5269 div(2,run1) = div(1,run1) - div(2,run1);
5270 div(3,run1) = ( div(2,run1) - div(3,run1) )/(2.0);
5272 div(1,run1) = div(0,run1) - div(1,run1);
5273 div(2,run1) = ( div(1,run1) - div(2,run1) )/(2.0);
5274 div(3,run1) = ( div(2,run1) - div(3,run1) )/(3.0);
5290 if( Dx_x0.
getDim() != 0 )
5291 for( run1 = 0; run1 <
m; run1++ )
5295 for( run1 = 0; run1 <
mu; run1++ )
5299 for( run1 = 0; run1 <
mp; run1++ )
5303 for( run1 = 0; run1 <
mw; run1++ )
5316 for( jj = i1+1; jj <= i2; jj++ ){
5318 for( run1 = 0; run1 <
m; run1++ )
5319 poly( jj, run1 ) = div(0,run1);
5322 double pp2 = pp1*(pp1*
h[0] +
h[0])/
h[0];
5323 double pp3 = pp2*(pp1*
h[0] +
psi[number_][1])/
h[0];
5324 double pp4 = pp3*(pp1*
h[0] +
psi[number_][2])/
h[0];
5326 for( run1 = 0; run1 <
m; run1++ )
5327 poly( jj, run1 ) += pp1*div(1,run1);
5329 for( run1 = 0; run1 <
m; run1++ )
5330 poly( jj, run1 ) += pp2*div(2,run1);
5332 for( run1 = 0; run1 <
m; run1++ )
5333 poly( jj, run1 ) += pp3*div(3,run1);
5335 for( run1 = 0; run1 <
m; run1++ )
5336 poly( jj, run1 ) += pp4*div(4,run1);
5353 for( run1 = 0; run1 <
md; run1++ )
5354 currentDiffStates( run1 ) =
nablaY( 0,run1 );
5366 for( run1 = 0; run1 <
ma; run1++ )
5367 currentAlgStates( run1 ) =
nablaY( 0,
md+run1 );
returnValue setLast(LogName _name, int lastValue, double time=-INFTY)
int getStateEnumerationIndex(int index_)
virtual returnValue getProtectedBackwardSensitivities(DVector &Dx_x0, DVector &Dx_p, DVector &Dx_u, DVector &Dx_w, int order) const
void determineRKEtaGForward()
IntermediateState sqrt(const Expression &arg)
void printBDFfinalResults()
virtual returnValue getProtectedForwardSensitivities(DMatrix *Dx, int order) const
void constructAll(const IntegratorBDF &arg)
virtual int getNumberOfRejectedSteps() const
void init(unsigned _nRows=0, unsigned _nCols=0)
double applyNewtonStep(int index, double *etakplus1, const double *etak, const DMatrix &J, const double *FFF)
returnValue setForwardSeed2(const DVector &xSeed, const DVector &pSeed, const DVector &uSeed, const DVector &wSeed)
double getTime(uint pointIdx) const
int getNumDynamicEquations() const
int * int_parameter_index
double determinePredictor(int number, BooleanType ini)
double getFirstTime() const
Implements the backward-differentiation formula for integrating DAEs.
virtual returnValue freezeAll()
virtual returnValue stop()
void determineBDFEtaHBackward(int number)
BEGIN_NAMESPACE_ACADO const double EPS
void logCurrentIntegratorStep(const DVector ¤tX=emptyConstVector, const DVector ¤tXA=emptyConstVector)
void init(unsigned _dim=0)
void determineRKEtaGForward2()
Provides a time grid consisting of vector-valued optimization variables at each grid point...
virtual IntegratorBDF & operator=(const IntegratorBDF &arg)
Allows to pass back messages to the calling function.
DVector evaluate(const EvaluationPoint &x, const int &number=0)
void determineBDFEtaGForward(int number)
AlgorithmicBase & operator=(const AlgorithmicBase &rhs)
IntermediateState pow(const Expression &arg1, const Expression &arg2)
returnValue decomposeJacobian(int index, DMatrix &J)
Allows to conveniently handle (one-dimensional) grids consisting of time points.
RealClock functionEvaluation
virtual int getDim() const
void determineRKEtaHBackward()
virtual returnValue evaluate(const DVector &x0, const DVector &xa, const DVector &p, const DVector &u, const DVector &w, const Grid &t_)
void printRKIntermediateResults()
returnValue rk_start_solve(int stepnumber)
#define CLOSE_NAMESPACE_ACADO
virtual Integrator * clone() const
GenericMatrix< double > DMatrix
Abstract base class for all kinds of algorithms for integrating differential equations (ODEs or DAEs)...
uint getFloorIndex(double time) const
#define ACADOFATAL(retval)
double * initialAlgebraicResiduum
void determineBDFEtaHBackward2(int number)
virtual returnValue evaluateSensitivities()
returnValue determineCorrector(int number, BooleanType ini)
double relaxationConstant
BooleanType acadoIsNaN(double x)
double getIntervalLength() const
virtual int getDimX() const
virtual returnValue step(int number)
virtual returnValue unfreeze()
void determineRKEtaHBackward2()
double scale(VariableType variableType_, int index_) const
void printBDFIntermediateResults()
virtual returnValue setProtectedForwardSeed(const DVector &xSeed, const DVector &pSeed, const DVector &uSeed, const DVector &wSeed, const int &order)
RealClock jacDecomposition
void initializeVariables()
returnValue acadoPrintCopyrightNotice(const std::string &subpackage)
Derived & setZero(Index size)
void interpolate(int number_, DMatrix &div, VariablesGrid &poly)
int index(VariableType variableType_, int index_) const
void relaxAlgebraic(double *residuum, double timePoint)
virtual returnValue setProtectedBackwardSeed(const DVector &seed, const int &order)
virtual BooleanType makeImplicit()
virtual returnValue start()
void printBDFfinalResults2(DMatrix &div)
virtual returnValue getProtectedX(DVector *xEnd) const
void prepareDividedDifferences(DMatrix &div)
virtual returnValue setBackwardSeed2(const DVector &seed)
void applyMTranspose(int index, double *seed1, DMatrix &J, double *seed2)
void initializeButcherTableau()
virtual returnValue stop()
virtual int getNumberOfSteps() const
double getLastTime() const
#define ACADOWARNING(retval)
virtual returnValue init(const DifferentialEquation &rhs_)
#define BEGIN_NAMESPACE_ACADO
virtual returnValue freezeMesh()
virtual returnValue setDxInitialization(double *dx0)
IntermediateState exp(const Expression &arg)
void determineBDFEtaGForward2(int number)
virtual returnValue printRunTimeProfile() const
void copyBackward(DVector &Dx_x0, DVector &Dx_p, DVector &Dx_u, DVector &Dx_w, const DMatrix &div) const
virtual double getStepSize() const
int getNumberOfVariables() const
#define ACADOERROR(retval)
T getNorm(VectorNorm _norm) const
virtual returnValue getTime(double &_elapsedTime)
Allows to setup and evaluate differential equations (ODEs and DAEs) based on SymbolicExpressions.
DifferentialEquation * rhs