1086 static double matr[9], f, t1, t2;
1087 static double fmat[6], ftmat[6], g, t3, t4;
1088 static double adj_m[9], df[9], dg[9], loc0, loc1, loc2, loc3, loc4;
1089 static double A[12], J_A[6], J_B[9], J_C[9],
cross;
1090 static double aux[45];
1093 f = x[1][0] - x[0][0];
1094 g = x[2][0] - x[0][0];
1095 t1 = x[3][0] - x[0][0];
1096 matr[0] = f*invW[0][0] + g*invW[1][0] + t1*invW[2][0];
1097 matr[1] = f*invW[0][1] + g*invW[1][1] + t1*invW[2][1];
1098 matr[2] = f*invW[0][2] + g*invW[1][2] + t1*invW[2][2];
1100 f = x[1][1] - x[0][1];
1101 g = x[2][1] - x[0][1];
1102 t1 = x[3][1] - x[0][1];
1103 matr[3] = f*invW[0][0] + g*invW[1][0] + t1*invW[2][0];
1104 matr[4] = f*invW[0][1] + g*invW[1][1] + t1*invW[2][1];
1105 matr[5] = f*invW[0][2] + g*invW[1][2] + t1*invW[2][2];
1107 f = x[1][2] - x[0][2];
1108 g = x[2][2] - x[0][2];
1109 t1 = x[3][2] - x[0][2];
1110 matr[6] = f*invW[0][0] + g*invW[1][0] + t1*invW[2][0];
1111 matr[7] = f*invW[0][1] + g*invW[1][1] + t1*invW[2][1];
1112 matr[8] = f*invW[0][2] + g*invW[1][2] + t1*invW[2][2];
1115 aux[ 0] = matr[0]*matr[0];
1116 aux[ 1] = matr[0]*matr[1];
1117 aux[ 2] = matr[0]*matr[2];
1118 aux[ 3] = matr[0]*matr[3];
1119 aux[ 4] = matr[0]*matr[4];
1120 aux[ 5] = matr[0]*matr[5];
1121 aux[ 6] = matr[0]*matr[6];
1122 aux[ 7] = matr[0]*matr[7];
1123 aux[ 8] = matr[0]*matr[8];
1124 aux[ 9] = matr[1]*matr[1];
1125 aux[10] = matr[1]*matr[2];
1126 aux[11] = matr[1]*matr[3];
1127 aux[12] = matr[1]*matr[4];
1128 aux[13] = matr[1]*matr[5];
1129 aux[14] = matr[1]*matr[6];
1130 aux[15] = matr[1]*matr[7];
1131 aux[16] = matr[1]*matr[8];
1132 aux[17] = matr[2]*matr[2];
1133 aux[18] = matr[2]*matr[3];
1134 aux[19] = matr[2]*matr[4];
1135 aux[20] = matr[2]*matr[5];
1136 aux[21] = matr[2]*matr[6];
1137 aux[22] = matr[2]*matr[7];
1138 aux[23] = matr[2]*matr[8];
1139 aux[24] = matr[3]*matr[3];
1140 aux[25] = matr[3]*matr[4];
1141 aux[26] = matr[3]*matr[5];
1142 aux[27] = matr[3]*matr[6];
1143 aux[28] = matr[3]*matr[7];
1144 aux[29] = matr[3]*matr[8];
1145 aux[30] = matr[4]*matr[4];
1146 aux[31] = matr[4]*matr[5];
1147 aux[32] = matr[4]*matr[6];
1148 aux[33] = matr[4]*matr[7];
1149 aux[34] = matr[4]*matr[8];
1150 aux[35] = matr[5]*matr[5];
1151 aux[36] = matr[5]*matr[6];
1152 aux[37] = matr[5]*matr[7];
1153 aux[38] = matr[5]*matr[8];
1154 aux[39] = matr[6]*matr[6];
1155 aux[40] = matr[6]*matr[7];
1156 aux[41] = matr[6]*matr[8];
1157 aux[42] = matr[7]*matr[7];
1158 aux[43] = matr[7]*matr[8];
1159 aux[44] = matr[8]*matr[8];
1162 dg[0] = aux[34] - aux[37];
1163 dg[1] = aux[36] - aux[29];
1164 dg[2] = aux[28] - aux[32];
1165 t1 = matr[0]*dg[0] + matr[1]*dg[1] + matr[2]*dg[2];
1166 t2 = t1*t1 + 4.0*delta*delta;
1169 if (g <
MSQ_MIN) { obj = g;
return false; }
1171 fmat[0] = aux[ 0] + aux[ 9] + aux[17] - 1.0;
1172 fmat[1] = aux[ 3] + aux[12] + aux[20];
1173 fmat[2] = aux[ 6] + aux[15] + aux[23];
1175 fmat[3] = aux[24] + aux[30] + aux[35] - 1.0;
1176 fmat[4] = aux[27] + aux[33] + aux[38];
1178 fmat[5] = aux[39] + aux[42] + aux[44] - 1.0;
1180 f = fmat[0]*fmat[0] + 2.0*fmat[1]*fmat[1] + 2.0*fmat[2]*fmat[2] +
1181 fmat[3]*fmat[3] + 2.0*fmat[4]*fmat[4] +
1194 obj = a * f *
pow(g, c);
1195 f = a *
pow(g, c) * 2.0;
1196 g = c * obj / g * t4;
1199 obj = a * f * f *
pow(g, c);
1200 f = a * f *
pow(g, c) * 4.0;
1201 g = c * obj / g * t4;
1210 obj = a *
pow(f, b) *
pow(g, c);
1211 f = b * obj / f * 2.0;
1212 g = c * obj / g * t4;
1216 printf(
"b = %5.4e not allowed in RI_DFT\n", (
double)b);
1220 df[0] = fmat[0]*matr[0] + fmat[1]*matr[3] + fmat[2]*matr[6];
1221 df[1] = fmat[0]*matr[1] + fmat[1]*matr[4] + fmat[2]*matr[7];
1222 df[2] = fmat[0]*matr[2] + fmat[1]*matr[5] + fmat[2]*matr[8];
1224 df[3] = fmat[1]*matr[0] + fmat[3]*matr[3] + fmat[4]*matr[6];
1225 df[4] = fmat[1]*matr[1] + fmat[3]*matr[4] + fmat[4]*matr[7];
1226 df[5] = fmat[1]*matr[2] + fmat[3]*matr[5] + fmat[4]*matr[8];
1228 df[6] = fmat[2]*matr[0] + fmat[4]*matr[3] + fmat[5]*matr[6];
1229 df[7] = fmat[2]*matr[1] + fmat[4]*matr[4] + fmat[5]*matr[7];
1230 df[8] = fmat[2]*matr[2] + fmat[4]*matr[5] + fmat[5]*matr[8];
1232 dg[3] = aux[22] - aux[16];
1233 dg[4] = aux[ 8] - aux[21];
1234 dg[5] = aux[14] - aux[ 7];
1236 dg[6] = aux[13] - aux[19];
1237 dg[7] = aux[18] - aux[ 5];
1238 dg[8] = aux[ 4] - aux[11];
1240 adj_m[0] = df[0]*f + dg[0]*g;
1241 adj_m[1] = df[1]*f + dg[1]*g;
1242 adj_m[2] = df[2]*f + dg[2]*g;
1243 adj_m[3] = df[3]*f + dg[3]*g;
1244 adj_m[4] = df[4]*f + dg[4]*g;
1245 adj_m[5] = df[5]*f + dg[5]*g;
1246 adj_m[6] = df[6]*f + dg[6]*g;
1247 adj_m[7] = df[7]*f + dg[7]*g;
1248 adj_m[8] = df[8]*f + dg[8]*g;
1250 loc0 = invW[0][0]*adj_m[0];
1251 loc1 = invW[1][0]*adj_m[0];
1252 loc2 = invW[2][0]*adj_m[0];
1253 g_obj[0][0] = -loc0 - loc1 - loc2;
1258 loc0 = invW[0][1]*adj_m[1];
1259 loc1 = invW[1][1]*adj_m[1];
1260 loc2 = invW[2][1]*adj_m[1];
1261 g_obj[0][0] -= loc0 + loc1 + loc2;
1262 g_obj[1][0] += loc0;
1263 g_obj[2][0] += loc1;
1264 g_obj[3][0] += loc2;
1266 loc0 = invW[0][2]*adj_m[2];
1267 loc1 = invW[1][2]*adj_m[2];
1268 loc2 = invW[2][2]*adj_m[2];
1269 g_obj[0][0] -= loc0 + loc1 + loc2;
1270 g_obj[1][0] += loc0;
1271 g_obj[2][0] += loc1;
1272 g_obj[3][0] += loc2;
1274 loc0 = invW[0][0]*adj_m[3];
1275 loc1 = invW[1][0]*adj_m[3];
1276 loc2 = invW[2][0]*adj_m[3];
1277 g_obj[0][1] = -loc0 - loc1 - loc2;
1282 loc0 = invW[0][1]*adj_m[4];
1283 loc1 = invW[1][1]*adj_m[4];
1284 loc2 = invW[2][1]*adj_m[4];
1285 g_obj[0][1] -= loc0 + loc1 + loc2;
1286 g_obj[1][1] += loc0;
1287 g_obj[2][1] += loc1;
1288 g_obj[3][1] += loc2;
1290 loc0 = invW[0][2]*adj_m[5];
1291 loc1 = invW[1][2]*adj_m[5];
1292 loc2 = invW[2][2]*adj_m[5];
1293 g_obj[0][1] -= loc0 + loc1 + loc2;
1294 g_obj[1][1] += loc0;
1295 g_obj[2][1] += loc1;
1296 g_obj[3][1] += loc2;
1298 loc0 = invW[0][0]*adj_m[6];
1299 loc1 = invW[1][0]*adj_m[6];
1300 loc2 = invW[2][0]*adj_m[6];
1301 g_obj[0][2] = -loc0 - loc1 - loc2;
1306 loc0 = invW[0][1]*adj_m[7];
1307 loc1 = invW[1][1]*adj_m[7];
1308 loc2 = invW[2][1]*adj_m[7];
1309 g_obj[0][2] -= loc0 + loc1 + loc2;
1310 g_obj[1][2] += loc0;
1311 g_obj[2][2] += loc1;
1312 g_obj[3][2] += loc2;
1314 loc0 = invW[0][2]*adj_m[8];
1315 loc1 = invW[1][2]*adj_m[8];
1316 loc2 = invW[2][2]*adj_m[8];
1317 g_obj[0][2] -= loc0 + loc1 + loc2;
1318 g_obj[1][2] += loc0;
1319 g_obj[2][2] += loc1;
1320 g_obj[3][2] += loc2;
1324 ftmat[0] = aux[ 0] + aux[24] + aux[39];
1325 ftmat[1] = aux[ 1] + aux[25] + aux[40];
1326 ftmat[2] = aux[ 2] + aux[26] + aux[41];
1328 ftmat[3] = aux[ 9] + aux[30] + aux[42];
1329 ftmat[4] = aux[10] + aux[31] + aux[43];
1331 ftmat[5] = aux[17] + aux[35] + aux[44];
1336 cross = f * c / loc4 * t4;
1338 g = g *((c - 1) * t4 + 4.0*delta*delta / t2) / loc4;
1342 cross = f * c / loc4 * t4;
1343 f = a *
pow(loc4, c) * 8.0;
1344 g = g *((c - 1) * t4 + 4.0*delta*delta / t2) / loc4;
1354 cross = f * c / loc4 * t4;
1355 f = f * (b - 1) / loc3 * 2.0;
1356 g = g *((c - 1) * t4 + 4.0*delta*delta / t2) / loc4;
1367 loc3 = df[0]*f + dg[0]*
cross;
1368 loc4 = dg[0]*g + df[0]*
cross;
1370 J_A[0] = loc3*df[0] + loc4*dg[0];
1371 J_A[1] = loc3*df[1] + loc4*dg[1];
1372 J_A[2] = loc3*df[2] + loc4*dg[2];
1373 J_B[0] = loc3*df[3] + loc4*dg[3];
1374 J_B[1] = loc3*df[4] + loc4*dg[4];
1375 J_B[2] = loc3*df[5] + loc4*dg[5];
1376 J_C[0] = loc3*df[6] + loc4*dg[6];
1377 J_C[1] = loc3*df[7] + loc4*dg[7];
1378 J_C[2] = loc3*df[8] + loc4*dg[8];
1380 loc3 = df[1]*f + dg[1]*
cross;
1381 loc4 = dg[1]*g + df[1]*
cross;
1383 J_A[3] = loc3*df[1] + loc4*dg[1];
1384 J_A[4] = loc3*df[2] + loc4*dg[2];
1385 J_B[3] = loc3*df[3] + loc4*dg[3];
1386 J_B[4] = loc3*df[4] + loc4*dg[4];
1387 J_B[5] = loc3*df[5] + loc4*dg[5];
1388 J_C[3] = loc3*df[6] + loc4*dg[6];
1389 J_C[4] = loc3*df[7] + loc4*dg[7];
1390 J_C[5] = loc3*df[8] + loc4*dg[8];
1392 loc3 = df[2]*f + dg[2]*
cross;
1393 loc4 = dg[2]*g + df[2]*
cross;
1395 J_A[5] = loc3*df[2] + loc4*dg[2];
1396 J_B[6] = loc3*df[3] + loc4*dg[3];
1397 J_B[7] = loc3*df[4] + loc4*dg[4];
1398 J_B[8] = loc3*df[5] + loc4*dg[5];
1399 J_C[6] = loc3*df[6] + loc4*dg[6];
1400 J_C[7] = loc3*df[7] + loc4*dg[7];
1401 J_C[8] = loc3*df[8] + loc4*dg[8];
1404 J_A[0] += loc0*(fmat[0] + ftmat[0] + aux[ 0]);
1405 J_A[1] += loc0*( ftmat[1] + aux[ 1]);
1406 J_A[2] += loc0*( ftmat[2] + aux[ 2]);
1408 J_A[3] += loc0*(fmat[0] + ftmat[3] + aux[ 9]);
1409 J_A[4] += loc0*( ftmat[4] + aux[10]);
1411 J_A[5] += loc0*(fmat[0] + ftmat[5] + aux[17]);
1413 loc2 = invW[0][0]+invW[1][0]+invW[2][0];
1414 loc3 = invW[0][1]+invW[1][1]+invW[2][1];
1415 loc4 = invW[0][2]+invW[1][2]+invW[2][2];
1417 A[0] = -J_A[0]*loc2 - J_A[1]*loc3 - J_A[2]*loc4;
1418 A[1] = J_A[0]*invW[0][0] + J_A[1]*invW[0][1] + J_A[2]*invW[0][2];
1419 A[2] = J_A[0]*invW[1][0] + J_A[1]*invW[1][1] + J_A[2]*invW[1][2];
1420 A[3] = J_A[0]*invW[2][0] + J_A[1]*invW[2][1] + J_A[2]*invW[2][2];
1422 A[4] = -J_A[1]*loc2 - J_A[3]*loc3 - J_A[4]*loc4;
1423 A[5] = J_A[1]*invW[0][0] + J_A[3]*invW[0][1] + J_A[4]*invW[0][2];
1424 A[6] = J_A[1]*invW[1][0] + J_A[3]*invW[1][1] + J_A[4]*invW[1][2];
1425 A[7] = J_A[1]*invW[2][0] + J_A[3]*invW[2][1] + J_A[4]*invW[2][2];
1427 A[8] = -J_A[2]*loc2 - J_A[4]*loc3 - J_A[5]*loc4;
1428 A[9] = J_A[2]*invW[0][0] + J_A[4]*invW[0][1] + J_A[5]*invW[0][2];
1429 A[10] = J_A[2]*invW[1][0] + J_A[4]*invW[1][1] + J_A[5]*invW[1][2];
1430 A[11] = J_A[2]*invW[2][0] + J_A[4]*invW[2][1] + J_A[5]*invW[2][2];
1432 h_obj[0][0][0] = -A[0]*loc2 - A[4]*loc3 - A[8]*loc4;
1433 h_obj[1][0][0] = A[0]*invW[0][0] + A[4]*invW[0][1] + A[8]*invW[0][2];
1434 h_obj[2][0][0] = A[0]*invW[1][0] + A[4]*invW[1][1] + A[8]*invW[1][2];
1435 h_obj[3][0][0] = A[0]*invW[2][0] + A[4]*invW[2][1] + A[8]*invW[2][2];
1437 h_obj[4][0][0] = A[1]*invW[0][0] + A[5]*invW[0][1] + A[9]*invW[0][2];
1438 h_obj[5][0][0] = A[1]*invW[1][0] + A[5]*invW[1][1] + A[9]*invW[1][2];
1439 h_obj[6][0][0] = A[1]*invW[2][0] + A[5]*invW[2][1] + A[9]*invW[2][2];
1441 h_obj[7][0][0] = A[2]*invW[1][0] + A[6]*invW[1][1] + A[10]*invW[1][2];
1442 h_obj[8][0][0] = A[2]*invW[2][0] + A[6]*invW[2][1] + A[10]*invW[2][2];
1444 h_obj[9][0][0] = A[3]*invW[2][0] + A[7]*invW[2][1] + A[11]*invW[2][2];
1447 J_B[0] += loc0*(fmat[1] + aux[3]);
1448 J_B[1] += loc0*aux[11];
1449 J_B[2] += loc0*aux[18];
1451 J_B[3] += loc0*aux[ 4];
1452 J_B[4] += loc0*(fmat[1] + aux[12]);
1453 J_B[5] += loc0*aux[19];
1455 J_B[6] += loc0*aux[ 5];
1456 J_B[7] += loc0*aux[13];
1457 J_B[8] += loc0*(fmat[1] + aux[20]);
1459 loc2 = matr[8]*loc1;
1463 loc2 = matr[7]*loc1;
1467 loc2 = matr[6]*loc1;
1471 loc2 = invW[0][0]+invW[1][0]+invW[2][0];
1472 loc3 = invW[0][1]+invW[1][1]+invW[2][1];
1473 loc4 = invW[0][2]+invW[1][2]+invW[2][2];
1475 A[0] = -J_B[0]*loc2 - J_B[1]*loc3 - J_B[2]*loc4;
1476 A[1] = J_B[0]*invW[0][0] + J_B[1]*invW[0][1] + J_B[2]*invW[0][2];
1477 A[2] = J_B[0]*invW[1][0] + J_B[1]*invW[1][1] + J_B[2]*invW[1][2];
1478 A[3] = J_B[0]*invW[2][0] + J_B[1]*invW[2][1] + J_B[2]*invW[2][2];
1480 A[4] = -J_B[3]*loc2 - J_B[4]*loc3 - J_B[5]*loc4;
1481 A[5] = J_B[3]*invW[0][0] + J_B[4]*invW[0][1] + J_B[5]*invW[0][2];
1482 A[6] = J_B[3]*invW[1][0] + J_B[4]*invW[1][1] + J_B[5]*invW[1][2];
1483 A[7] = J_B[3]*invW[2][0] + J_B[4]*invW[2][1] + J_B[5]*invW[2][2];
1485 A[8] = -J_B[6]*loc2 - J_B[7]*loc3 - J_B[8]*loc4;
1486 A[9] = J_B[6]*invW[0][0] + J_B[7]*invW[0][1] + J_B[8]*invW[0][2];
1487 A[10] = J_B[6]*invW[1][0] + J_B[7]*invW[1][1] + J_B[8]*invW[1][2];
1488 A[11] = J_B[6]*invW[2][0] + J_B[7]*invW[2][1] + J_B[8]*invW[2][2];
1490 h_obj[0][0][1] = -A[0]*loc2 - A[4]*loc3 - A[8]*loc4;
1491 h_obj[1][1][0] = A[0]*invW[0][0] + A[4]*invW[0][1] + A[8]*invW[0][2];
1492 h_obj[2][1][0] = A[0]*invW[1][0] + A[4]*invW[1][1] + A[8]*invW[1][2];
1493 h_obj[3][1][0] = A[0]*invW[2][0] + A[4]*invW[2][1] + A[8]*invW[2][2];
1495 h_obj[1][0][1] = -A[1]*loc2 - A[5]*loc3 - A[9]*loc4;
1496 h_obj[4][0][1] = A[1]*invW[0][0] + A[5]*invW[0][1] + A[9]*invW[0][2];
1497 h_obj[5][1][0] = A[1]*invW[1][0] + A[5]*invW[1][1] + A[9]*invW[1][2];
1498 h_obj[6][1][0] = A[1]*invW[2][0] + A[5]*invW[2][1] + A[9]*invW[2][2];
1500 h_obj[2][0][1] = -A[2]*loc2 - A[6]*loc3 - A[10]*loc4;
1501 h_obj[5][0][1] = A[2]*invW[0][0] + A[6]*invW[0][1] + A[10]*invW[0][2];
1502 h_obj[7][0][1] = A[2]*invW[1][0] + A[6]*invW[1][1] + A[10]*invW[1][2];
1503 h_obj[8][1][0] = A[2]*invW[2][0] + A[6]*invW[2][1] + A[10]*invW[2][2];
1505 h_obj[3][0][1] = -A[3]*loc2 - A[7]*loc3 - A[11]*loc4;
1506 h_obj[6][0][1] = A[3]*invW[0][0] + A[7]*invW[0][1] + A[11]*invW[0][2];
1507 h_obj[8][0][1] = A[3]*invW[1][0] + A[7]*invW[1][1] + A[11]*invW[1][2];
1508 h_obj[9][0][1] = A[3]*invW[2][0] + A[7]*invW[2][1] + A[11]*invW[2][2];
1511 J_C[0] += loc0*(fmat[2] + aux[6]);
1512 J_C[1] += loc0*aux[14];
1513 J_C[2] += loc0*aux[21];
1515 J_C[3] += loc0*aux[ 7];
1516 J_C[4] += loc0*(fmat[2] + aux[15]);
1517 J_C[5] += loc0*aux[22];
1519 J_C[6] += loc0*aux[ 8];
1520 J_C[7] += loc0*aux[16];
1521 J_C[8] += loc0*(fmat[2] + aux[23]);
1523 loc2 = matr[5]*loc1;
1527 loc2 = matr[4]*loc1;
1531 loc2 = matr[3]*loc1;
1535 loc2 = invW[0][0]+invW[1][0]+invW[2][0];
1536 loc3 = invW[0][1]+invW[1][1]+invW[2][1];
1537 loc4 = invW[0][2]+invW[1][2]+invW[2][2];
1539 A[0] = -J_C[0]*loc2 - J_C[1]*loc3 - J_C[2]*loc4;
1540 A[1] = J_C[0]*invW[0][0] + J_C[1]*invW[0][1] + J_C[2]*invW[0][2];
1541 A[2] = J_C[0]*invW[1][0] + J_C[1]*invW[1][1] + J_C[2]*invW[1][2];
1542 A[3] = J_C[0]*invW[2][0] + J_C[1]*invW[2][1] + J_C[2]*invW[2][2];
1544 A[4] = -J_C[3]*loc2 - J_C[4]*loc3 - J_C[5]*loc4;
1545 A[5] = J_C[3]*invW[0][0] + J_C[4]*invW[0][1] + J_C[5]*invW[0][2];
1546 A[6] = J_C[3]*invW[1][0] + J_C[4]*invW[1][1] + J_C[5]*invW[1][2];
1547 A[7] = J_C[3]*invW[2][0] + J_C[4]*invW[2][1] + J_C[5]*invW[2][2];
1549 A[8] = -J_C[6]*loc2 - J_C[7]*loc3 - J_C[8]*loc4;
1550 A[9] = J_C[6]*invW[0][0] + J_C[7]*invW[0][1] + J_C[8]*invW[0][2];
1551 A[10] = J_C[6]*invW[1][0] + J_C[7]*invW[1][1] + J_C[8]*invW[1][2];
1552 A[11] = J_C[6]*invW[2][0] + J_C[7]*invW[2][1] + J_C[8]*invW[2][2];
1554 h_obj[0][0][2] = -A[0]*loc2 - A[4]*loc3 - A[8]*loc4;
1555 h_obj[1][2][0] = A[0]*invW[0][0] + A[4]*invW[0][1] + A[8]*invW[0][2];
1556 h_obj[2][2][0] = A[0]*invW[1][0] + A[4]*invW[1][1] + A[8]*invW[1][2];
1557 h_obj[3][2][0] = A[0]*invW[2][0] + A[4]*invW[2][1] + A[8]*invW[2][2];
1559 h_obj[1][0][2] = -A[1]*loc2 - A[5]*loc3 - A[9]*loc4;
1560 h_obj[4][0][2] = A[1]*invW[0][0] + A[5]*invW[0][1] + A[9]*invW[0][2];
1561 h_obj[5][2][0] = A[1]*invW[1][0] + A[5]*invW[1][1] + A[9]*invW[1][2];
1562 h_obj[6][2][0] = A[1]*invW[2][0] + A[5]*invW[2][1] + A[9]*invW[2][2];
1564 h_obj[2][0][2] = -A[2]*loc2 - A[6]*loc3 - A[10]*loc4;
1565 h_obj[5][0][2] = A[2]*invW[0][0] + A[6]*invW[0][1] + A[10]*invW[0][2];
1566 h_obj[7][0][2] = A[2]*invW[1][0] + A[6]*invW[1][1] + A[10]*invW[1][2];
1567 h_obj[8][2][0] = A[2]*invW[2][0] + A[6]*invW[2][1] + A[10]*invW[2][2];
1569 h_obj[3][0][2] = -A[3]*loc2 - A[7]*loc3 - A[11]*loc4;
1570 h_obj[6][0][2] = A[3]*invW[0][0] + A[7]*invW[0][1] + A[11]*invW[0][2];
1571 h_obj[8][0][2] = A[3]*invW[1][0] + A[7]*invW[1][1] + A[11]*invW[1][2];
1572 h_obj[9][0][2] = A[3]*invW[2][0] + A[7]*invW[2][1] + A[11]*invW[2][2];
1575 loc3 = df[3]*f + dg[3]*
cross;
1576 loc4 = dg[3]*g + df[3]*
cross;
1578 J_A[0] = loc3*df[3] + loc4*dg[3];
1579 J_A[1] = loc3*df[4] + loc4*dg[4];
1580 J_A[2] = loc3*df[5] + loc4*dg[5];
1581 J_B[0] = loc3*df[6] + loc4*dg[6];
1582 J_B[1] = loc3*df[7] + loc4*dg[7];
1583 J_B[2] = loc3*df[8] + loc4*dg[8];
1585 loc3 = df[4]*f + dg[4]*
cross;
1586 loc4 = dg[4]*g + df[4]*
cross;
1588 J_A[3] = loc3*df[4] + loc4*dg[4];
1589 J_A[4] = loc3*df[5] + loc4*dg[5];
1590 J_B[3] = loc3*df[6] + loc4*dg[6];
1591 J_B[4] = loc3*df[7] + loc4*dg[7];
1592 J_B[5] = loc3*df[8] + loc4*dg[8];
1594 loc3 = df[5]*f + dg[5]*
cross;
1595 loc4 = dg[5]*g + df[5]*
cross;
1597 J_A[5] = loc3*df[5] + loc4*dg[5];
1598 J_B[6] = loc3*df[6] + loc4*dg[6];
1599 J_B[7] = loc3*df[7] + loc4*dg[7];
1600 J_B[8] = loc3*df[8] + loc4*dg[8];
1603 J_A[0] += loc0*(fmat[3] + ftmat[0] + aux[24]);
1604 J_A[1] += loc0*( ftmat[1] + aux[25]);
1605 J_A[2] += loc0*( ftmat[2] + aux[26]);
1607 J_A[3] += loc0*(fmat[3] + ftmat[3] + aux[30]);
1608 J_A[4] += loc0*( ftmat[4] + aux[31]);
1610 J_A[5] += loc0*(fmat[3] + ftmat[5] + aux[35]);
1612 loc2 = invW[0][0]+invW[1][0]+invW[2][0];
1613 loc3 = invW[0][1]+invW[1][1]+invW[2][1];
1614 loc4 = invW[0][2]+invW[1][2]+invW[2][2];
1616 A[0] = -J_A[0]*loc2 - J_A[1]*loc3 - J_A[2]*loc4;
1617 A[1] = J_A[0]*invW[0][0] + J_A[1]*invW[0][1] + J_A[2]*invW[0][2];
1618 A[2] = J_A[0]*invW[1][0] + J_A[1]*invW[1][1] + J_A[2]*invW[1][2];
1619 A[3] = J_A[0]*invW[2][0] + J_A[1]*invW[2][1] + J_A[2]*invW[2][2];
1621 A[4] = -J_A[1]*loc2 - J_A[3]*loc3 - J_A[4]*loc4;
1622 A[5] = J_A[1]*invW[0][0] + J_A[3]*invW[0][1] + J_A[4]*invW[0][2];
1623 A[6] = J_A[1]*invW[1][0] + J_A[3]*invW[1][1] + J_A[4]*invW[1][2];
1624 A[7] = J_A[1]*invW[2][0] + J_A[3]*invW[2][1] + J_A[4]*invW[2][2];
1626 A[8] = -J_A[2]*loc2 - J_A[4]*loc3 - J_A[5]*loc4;
1627 A[9] = J_A[2]*invW[0][0] + J_A[4]*invW[0][1] + J_A[5]*invW[0][2];
1628 A[10] = J_A[2]*invW[1][0] + J_A[4]*invW[1][1] + J_A[5]*invW[1][2];
1629 A[11] = J_A[2]*invW[2][0] + J_A[4]*invW[2][1] + J_A[5]*invW[2][2];
1631 h_obj[0][1][1] = -A[0]*loc2 - A[4]*loc3 - A[8]*loc4;
1632 h_obj[1][1][1] = A[0]*invW[0][0] + A[4]*invW[0][1] + A[8]*invW[0][2];
1633 h_obj[2][1][1] = A[0]*invW[1][0] + A[4]*invW[1][1] + A[8]*invW[1][2];
1634 h_obj[3][1][1] = A[0]*invW[2][0] + A[4]*invW[2][1] + A[8]*invW[2][2];
1636 h_obj[4][1][1] = A[1]*invW[0][0] + A[5]*invW[0][1] + A[9]*invW[0][2];
1637 h_obj[5][1][1] = A[1]*invW[1][0] + A[5]*invW[1][1] + A[9]*invW[1][2];
1638 h_obj[6][1][1] = A[1]*invW[2][0] + A[5]*invW[2][1] + A[9]*invW[2][2];
1640 h_obj[7][1][1] = A[2]*invW[1][0] + A[6]*invW[1][1] + A[10]*invW[1][2];
1641 h_obj[8][1][1] = A[2]*invW[2][0] + A[6]*invW[2][1] + A[10]*invW[2][2];
1643 h_obj[9][1][1] = A[3]*invW[2][0] + A[7]*invW[2][1] + A[11]*invW[2][2];
1646 J_B[0] += loc0*(fmat[4] + aux[27]);
1647 J_B[1] += loc0*aux[32];
1648 J_B[2] += loc0*aux[36];
1650 J_B[3] += loc0*aux[28];
1651 J_B[4] += loc0*(fmat[4] + aux[33]);
1652 J_B[5] += loc0*aux[37];
1654 J_B[6] += loc0*aux[29];
1655 J_B[7] += loc0*aux[34];
1656 J_B[8] += loc0*(fmat[4] + aux[38]);
1658 loc2 = matr[2]*loc1;
1662 loc2 = matr[1]*loc1;
1666 loc2 = matr[0]*loc1;
1670 loc2 = invW[0][0]+invW[1][0]+invW[2][0];
1671 loc3 = invW[0][1]+invW[1][1]+invW[2][1];
1672 loc4 = invW[0][2]+invW[1][2]+invW[2][2];
1674 A[0] = -J_B[0]*loc2 - J_B[1]*loc3 - J_B[2]*loc4;
1675 A[1] = J_B[0]*invW[0][0] + J_B[1]*invW[0][1] + J_B[2]*invW[0][2];
1676 A[2] = J_B[0]*invW[1][0] + J_B[1]*invW[1][1] + J_B[2]*invW[1][2];
1677 A[3] = J_B[0]*invW[2][0] + J_B[1]*invW[2][1] + J_B[2]*invW[2][2];
1679 A[4] = -J_B[3]*loc2 - J_B[4]*loc3 - J_B[5]*loc4;
1680 A[5] = J_B[3]*invW[0][0] + J_B[4]*invW[0][1] + J_B[5]*invW[0][2];
1681 A[6] = J_B[3]*invW[1][0] + J_B[4]*invW[1][1] + J_B[5]*invW[1][2];
1682 A[7] = J_B[3]*invW[2][0] + J_B[4]*invW[2][1] + J_B[5]*invW[2][2];
1684 A[8] = -J_B[6]*loc2 - J_B[7]*loc3 - J_B[8]*loc4;
1685 A[9] = J_B[6]*invW[0][0] + J_B[7]*invW[0][1] + J_B[8]*invW[0][2];
1686 A[10] = J_B[6]*invW[1][0] + J_B[7]*invW[1][1] + J_B[8]*invW[1][2];
1687 A[11] = J_B[6]*invW[2][0] + J_B[7]*invW[2][1] + J_B[8]*invW[2][2];
1689 h_obj[0][1][2] = -A[0]*loc2 - A[4]*loc3 - A[8]*loc4;
1690 h_obj[1][2][1] = A[0]*invW[0][0] + A[4]*invW[0][1] + A[8]*invW[0][2];
1691 h_obj[2][2][1] = A[0]*invW[1][0] + A[4]*invW[1][1] + A[8]*invW[1][2];
1692 h_obj[3][2][1] = A[0]*invW[2][0] + A[4]*invW[2][1] + A[8]*invW[2][2];
1694 h_obj[1][1][2] = -A[1]*loc2 - A[5]*loc3 - A[9]*loc4;
1695 h_obj[4][1][2] = A[1]*invW[0][0] + A[5]*invW[0][1] + A[9]*invW[0][2];
1696 h_obj[5][2][1] = A[1]*invW[1][0] + A[5]*invW[1][1] + A[9]*invW[1][2];
1697 h_obj[6][2][1] = A[1]*invW[2][0] + A[5]*invW[2][1] + A[9]*invW[2][2];
1699 h_obj[2][1][2] = -A[2]*loc2 - A[6]*loc3 - A[10]*loc4;
1700 h_obj[5][1][2] = A[2]*invW[0][0] + A[6]*invW[0][1] + A[10]*invW[0][2];
1701 h_obj[7][1][2] = A[2]*invW[1][0] + A[6]*invW[1][1] + A[10]*invW[1][2];
1702 h_obj[8][2][1] = A[2]*invW[2][0] + A[6]*invW[2][1] + A[10]*invW[2][2];
1704 h_obj[3][1][2] = -A[3]*loc2 - A[7]*loc3 - A[11]*loc4;
1705 h_obj[6][1][2] = A[3]*invW[0][0] + A[7]*invW[0][1] + A[11]*invW[0][2];
1706 h_obj[8][1][2] = A[3]*invW[1][0] + A[7]*invW[1][1] + A[11]*invW[1][2];
1707 h_obj[9][1][2] = A[3]*invW[2][0] + A[7]*invW[2][1] + A[11]*invW[2][2];
1710 loc3 = df[6]*f + dg[6]*
cross;
1711 loc4 = dg[6]*g + df[6]*
cross;
1713 J_A[0] = loc3*df[6] + loc4*dg[6];
1714 J_A[1] = loc3*df[7] + loc4*dg[7];
1715 J_A[2] = loc3*df[8] + loc4*dg[8];
1717 loc3 = df[7]*f + dg[7]*
cross;
1718 loc4 = dg[7]*g + df[7]*
cross;
1720 J_A[3] = loc3*df[7] + loc4*dg[7];
1721 J_A[4] = loc3*df[8] + loc4*dg[8];
1723 loc3 = df[8]*f + dg[8]*
cross;
1724 loc4 = dg[8]*g + df[8]*
cross;
1726 J_A[5] = loc3*df[8] + loc4*dg[8];
1729 J_A[0] += loc0*(fmat[5] + ftmat[0] + aux[39]);
1730 J_A[1] += loc0*( ftmat[1] + aux[40]);
1731 J_A[2] += loc0*( ftmat[2] + aux[41]);
1733 J_A[3] += loc0*(fmat[5] + ftmat[3] + aux[42]);
1734 J_A[4] += loc0*( ftmat[4] + aux[43]);
1736 J_A[5] += loc0*(fmat[5] + ftmat[5] + aux[44]);
1738 loc2 = invW[0][0]+invW[1][0]+invW[2][0];
1739 loc3 = invW[0][1]+invW[1][1]+invW[2][1];
1740 loc4 = invW[0][2]+invW[1][2]+invW[2][2];
1742 A[0] = -J_A[0]*loc2 - J_A[1]*loc3 - J_A[2]*loc4;
1743 A[1] = J_A[0]*invW[0][0] + J_A[1]*invW[0][1] + J_A[2]*invW[0][2];
1744 A[2] = J_A[0]*invW[1][0] + J_A[1]*invW[1][1] + J_A[2]*invW[1][2];
1745 A[3] = J_A[0]*invW[2][0] + J_A[1]*invW[2][1] + J_A[2]*invW[2][2];
1747 A[4] = -J_A[1]*loc2 - J_A[3]*loc3 - J_A[4]*loc4;
1748 A[5] = J_A[1]*invW[0][0] + J_A[3]*invW[0][1] + J_A[4]*invW[0][2];
1749 A[6] = J_A[1]*invW[1][0] + J_A[3]*invW[1][1] + J_A[4]*invW[1][2];
1750 A[7] = J_A[1]*invW[2][0] + J_A[3]*invW[2][1] + J_A[4]*invW[2][2];
1752 A[8] = -J_A[2]*loc2 - J_A[4]*loc3 - J_A[5]*loc4;
1753 A[9] = J_A[2]*invW[0][0] + J_A[4]*invW[0][1] + J_A[5]*invW[0][2];
1754 A[10] = J_A[2]*invW[1][0] + J_A[4]*invW[1][1] + J_A[5]*invW[1][2];
1755 A[11] = J_A[2]*invW[2][0] + J_A[4]*invW[2][1] + J_A[5]*invW[2][2];
1757 h_obj[0][2][2] = -A[0]*loc2 - A[4]*loc3 - A[8]*loc4;
1758 h_obj[1][2][2] = A[0]*invW[0][0] + A[4]*invW[0][1] + A[8]*invW[0][2];
1759 h_obj[2][2][2] = A[0]*invW[1][0] + A[4]*invW[1][1] + A[8]*invW[1][2];
1760 h_obj[3][2][2] = A[0]*invW[2][0] + A[4]*invW[2][1] + A[8]*invW[2][2];
1762 h_obj[4][2][2] = A[1]*invW[0][0] + A[5]*invW[0][1] + A[9]*invW[0][2];
1763 h_obj[5][2][2] = A[1]*invW[1][0] + A[5]*invW[1][1] + A[9]*invW[1][2];
1764 h_obj[6][2][2] = A[1]*invW[2][0] + A[5]*invW[2][1] + A[9]*invW[2][2];
1766 h_obj[7][2][2] = A[2]*invW[1][0] + A[6]*invW[1][1] + A[10]*invW[1][2];
1767 h_obj[8][2][2] = A[2]*invW[2][0] + A[6]*invW[2][1] + A[10]*invW[2][2];
1769 h_obj[9][2][2] = A[3]*invW[2][0] + A[7]*invW[2][1] + A[11]*invW[2][2];
NVec< 3, T > cross(const NVec< 3, T > &u, const NVec< 3, T > &v)
void fill_lower_triangle()
double pow(double value, const Exponent &exp)