39 using namespace Mesquite;
65 static double matr[9], f, t1, t2;
66 static double fmat[6], g;
69 f = x[1][0] - x[0][0];
70 g = x[2][0] - x[0][0];
72 matr[0] = f*invW[0][0] + g*invW[1][0] + t1*invW[2][0];
73 matr[1] = f*invW[0][1] + g*invW[1][1] + t1*invW[2][1];
74 matr[2] = f*invW[0][2] + g*invW[1][2] + t1*invW[2][2];
76 f = x[1][1] - x[0][1];
77 g = x[2][1] - x[0][1];
79 matr[3] = f*invW[0][0] + g*invW[1][0] + t1*invW[2][0];
80 matr[4] = f*invW[0][1] + g*invW[1][1] + t1*invW[2][1];
81 matr[5] = f*invW[0][2] + g*invW[1][2] + t1*invW[2][2];
83 f = x[1][2] - x[0][2];
84 g = x[2][2] - x[0][2];
86 matr[6] = f*invW[0][0] + g*invW[1][0] + t1*invW[2][0];
87 matr[7] = f*invW[0][1] + g*invW[1][1] + t1*invW[2][1];
88 matr[8] = f*invW[0][2] + g*invW[1][2] + t1*invW[2][2];
91 t1 = matr[0]*(matr[4]*matr[8] - matr[5]*matr[7]) +
92 matr[1]*(matr[5]*matr[6] - matr[3]*matr[8]) +
93 matr[2]*(matr[3]*matr[7] - matr[4]*matr[6]);
94 t2 =
sqrt(t1*t1 + 4.0*delta*delta);
96 if (g <
MSQ_MIN) { obj = g;
return false; }
99 fmat[0] = matr[0]*matr[0] + matr[1]*matr[1] + matr[2]*matr[2] - 1.0;
100 fmat[1] = matr[0]*matr[3] + matr[1]*matr[4] + matr[2]*matr[5];
101 fmat[2] = matr[0]*matr[6] + matr[1]*matr[7] + matr[2]*matr[8];
103 fmat[3] = matr[3]*matr[3] + matr[4]*matr[4] + matr[5]*matr[5] - 1.0;
104 fmat[4] = matr[3]*matr[6] + matr[4]*matr[7] + matr[5]*matr[8];
106 fmat[5] = matr[6]*matr[6] + matr[7]*matr[7] + matr[8]*matr[8] - 1.0;
108 f = fmat[0]*fmat[0] + 2.0*fmat[1]*fmat[1] + 2.0*fmat[2]*fmat[2] +
109 fmat[3]*fmat[3] + 2.0*fmat[4]*fmat[4] +
113 obj = a *
pow(f, b) *
pow(g, c);
123 static double matr[9], f, t1, t2;
124 static double fmat[6], g;
125 static double adj_m[9], df[9], loc1, loc2, loc3;
128 f = x[1][0] - x[0][0];
129 g = x[2][0] - x[0][0];
131 matr[0] = f*invW[0][0] + g*invW[1][0] + t1*invW[2][0];
132 matr[1] = f*invW[0][1] + g*invW[1][1] + t1*invW[2][1];
133 matr[2] = f*invW[0][2] + g*invW[1][2] + t1*invW[2][2];
135 f = x[1][1] - x[0][1];
136 g = x[2][1] - x[0][1];
138 matr[3] = f*invW[0][0] + g*invW[1][0] + t1*invW[2][0];
139 matr[4] = f*invW[0][1] + g*invW[1][1] + t1*invW[2][1];
140 matr[5] = f*invW[0][2] + g*invW[1][2] + t1*invW[2][2];
142 f = x[1][2] - x[0][2];
143 g = x[2][2] - x[0][2];
145 matr[6] = f*invW[0][0] + g*invW[1][0] + t1*invW[2][0];
146 matr[7] = f*invW[0][1] + g*invW[1][1] + t1*invW[2][1];
147 matr[8] = f*invW[0][2] + g*invW[1][2] + t1*invW[2][2];
150 loc1 = matr[4]*matr[8] - matr[5]*matr[7];
151 loc2 = matr[5]*matr[6] - matr[3]*matr[8];
152 loc3 = matr[3]*matr[7] - matr[4]*matr[6];
153 t1 = matr[0]*loc1 + matr[1]*loc2 + matr[2]*loc3;
154 t2 =
sqrt(t1*t1 + 4.0*delta*delta);
156 if (g <
MSQ_MIN) { obj = g;
return false; }
159 fmat[0] = matr[0]*matr[0] + matr[1]*matr[1] + matr[2]*matr[2] - 1.0;
160 fmat[1] = matr[0]*matr[3] + matr[1]*matr[4] + matr[2]*matr[5];
161 fmat[2] = matr[0]*matr[6] + matr[1]*matr[7] + matr[2]*matr[8];
163 fmat[3] = matr[3]*matr[3] + matr[4]*matr[4] + matr[5]*matr[5] - 1.0;
164 fmat[4] = matr[3]*matr[6] + matr[4]*matr[7] + matr[5]*matr[8];
166 fmat[5] = matr[6]*matr[6] + matr[7]*matr[7] + matr[8]*matr[8] - 1.0;
168 f = fmat[0]*fmat[0] + 2.0*fmat[1]*fmat[1] + 2.0*fmat[2]*fmat[2] +
169 fmat[3]*fmat[3] + 2.0*fmat[4]*fmat[4] +
173 obj = a *
pow(f, b) *
pow(g, c);
176 f = b * obj / f * 4.0;
177 g = c * obj / g * (1 + t1 / t2);
179 df[0] = fmat[0]*matr[0] + fmat[1]*matr[3] + fmat[2]*matr[6];
180 df[1] = fmat[0]*matr[1] + fmat[1]*matr[4] + fmat[2]*matr[7];
181 df[2] = fmat[0]*matr[2] + fmat[1]*matr[5] + fmat[2]*matr[8];
183 df[3] = fmat[1]*matr[0] + fmat[3]*matr[3] + fmat[4]*matr[6];
184 df[4] = fmat[1]*matr[1] + fmat[3]*matr[4] + fmat[4]*matr[7];
185 df[5] = fmat[1]*matr[2] + fmat[3]*matr[5] + fmat[4]*matr[8];
187 df[6] = fmat[2]*matr[0] + fmat[4]*matr[3] + fmat[5]*matr[6];
188 df[7] = fmat[2]*matr[1] + fmat[4]*matr[4] + fmat[5]*matr[7];
189 df[8] = fmat[2]*matr[2] + fmat[4]*matr[5] + fmat[5]*matr[8];
191 adj_m[0] = df[0]*f + loc1*g;
192 adj_m[1] = df[1]*f + loc2*g;
193 adj_m[2] = df[2]*f + loc3*g;
199 adj_m[3] = df[3]*f + loc3*matr[7] - loc2*matr[8];
200 adj_m[4] = df[4]*f + loc1*matr[8] - loc3*matr[6];
201 adj_m[5] = df[5]*f + loc2*matr[6] - loc1*matr[7];
203 adj_m[6] = df[6]*f + loc2*matr[5] - loc3*matr[4];
204 adj_m[7] = df[7]*f + loc3*matr[3] - loc1*matr[5];
205 adj_m[8] = df[8]*f + loc1*matr[4] - loc2*matr[3];
207 loc1 = invW[0][0]*adj_m[0];
208 loc2 = invW[1][0]*adj_m[0];
209 g_obj[0][0] = -loc1 - loc2;
213 loc1 = invW[0][1]*adj_m[1];
214 loc2 = invW[1][1]*adj_m[1];
215 g_obj[0][0] -= loc1 + loc2;
219 loc1 = invW[0][2]*adj_m[2];
220 loc2 = invW[1][2]*adj_m[2];
221 g_obj[0][0] -= loc1 + loc2;
225 loc1 = invW[0][0]*adj_m[3];
226 loc2 = invW[1][0]*adj_m[3];
227 g_obj[0][1] = -loc1 - loc2;
231 loc1 = invW[0][1]*adj_m[4];
232 loc2 = invW[1][1]*adj_m[4];
233 g_obj[0][1] -= loc1 + loc2;
237 loc1 = invW[0][2]*adj_m[5];
238 loc2 = invW[1][2]*adj_m[5];
239 g_obj[0][1] -= loc1 + loc2;
243 loc1 = invW[0][0]*adj_m[6];
244 loc2 = invW[1][0]*adj_m[6];
245 g_obj[0][2] = -loc1 - loc2;
249 loc1 = invW[0][1]*adj_m[7];
250 loc2 = invW[1][1]*adj_m[7];
251 g_obj[0][2] -= loc1 + loc2;
255 loc1 = invW[0][2]*adj_m[8];
256 loc2 = invW[1][2]*adj_m[8];
257 g_obj[0][2] -= loc1 + loc2;
269 static double matr[9], f, t1, t2;
270 static double fmat[6], ftmat[6], g, t3, t4;
271 static double adj_m[9], df[9], dg[9], loc0, loc1, loc2, loc3, loc4;
272 static double A[12], J_A[6], J_B[9], J_C[9],
cross;
273 static double aux[45];
276 f = x[1][0] - x[0][0];
277 g = x[2][0] - x[0][0];
279 matr[0] = f*invW[0][0] + g*invW[1][0] + t1*invW[2][0];
280 matr[1] = f*invW[0][1] + g*invW[1][1] + t1*invW[2][1];
281 matr[2] = f*invW[0][2] + g*invW[1][2] + t1*invW[2][2];
283 f = x[1][1] - x[0][1];
284 g = x[2][1] - x[0][1];
286 matr[3] = f*invW[0][0] + g*invW[1][0] + t1*invW[2][0];
287 matr[4] = f*invW[0][1] + g*invW[1][1] + t1*invW[2][1];
288 matr[5] = f*invW[0][2] + g*invW[1][2] + t1*invW[2][2];
290 f = x[1][2] - x[0][2];
291 g = x[2][2] - x[0][2];
293 matr[6] = f*invW[0][0] + g*invW[1][0] + t1*invW[2][0];
294 matr[7] = f*invW[0][1] + g*invW[1][1] + t1*invW[2][1];
295 matr[8] = f*invW[0][2] + g*invW[1][2] + t1*invW[2][2];
298 aux[ 0] = matr[0]*matr[0];
299 aux[ 1] = matr[0]*matr[1];
300 aux[ 2] = matr[0]*matr[2];
301 aux[ 3] = matr[0]*matr[3];
302 aux[ 4] = matr[0]*matr[4];
303 aux[ 5] = matr[0]*matr[5];
304 aux[ 6] = matr[0]*matr[6];
305 aux[ 7] = matr[0]*matr[7];
306 aux[ 8] = matr[0]*matr[8];
307 aux[ 9] = matr[1]*matr[1];
308 aux[10] = matr[1]*matr[2];
309 aux[11] = matr[1]*matr[3];
310 aux[12] = matr[1]*matr[4];
311 aux[13] = matr[1]*matr[5];
312 aux[14] = matr[1]*matr[6];
313 aux[15] = matr[1]*matr[7];
314 aux[16] = matr[1]*matr[8];
315 aux[17] = matr[2]*matr[2];
316 aux[18] = matr[2]*matr[3];
317 aux[19] = matr[2]*matr[4];
318 aux[20] = matr[2]*matr[5];
319 aux[21] = matr[2]*matr[6];
320 aux[22] = matr[2]*matr[7];
321 aux[23] = matr[2]*matr[8];
322 aux[24] = matr[3]*matr[3];
323 aux[25] = matr[3]*matr[4];
324 aux[26] = matr[3]*matr[5];
325 aux[27] = matr[3]*matr[6];
326 aux[28] = matr[3]*matr[7];
327 aux[29] = matr[3]*matr[8];
328 aux[30] = matr[4]*matr[4];
329 aux[31] = matr[4]*matr[5];
330 aux[32] = matr[4]*matr[6];
331 aux[33] = matr[4]*matr[7];
332 aux[34] = matr[4]*matr[8];
333 aux[35] = matr[5]*matr[5];
334 aux[36] = matr[5]*matr[6];
335 aux[37] = matr[5]*matr[7];
336 aux[38] = matr[5]*matr[8];
337 aux[39] = matr[6]*matr[6];
338 aux[40] = matr[6]*matr[7];
339 aux[41] = matr[6]*matr[8];
340 aux[42] = matr[7]*matr[7];
341 aux[43] = matr[7]*matr[8];
342 aux[44] = matr[8]*matr[8];
345 dg[0] = aux[34] - aux[37];
346 dg[1] = aux[36] - aux[29];
347 dg[2] = aux[28] - aux[32];
348 t1 = matr[0]*dg[0] + matr[1]*dg[1] + matr[2]*dg[2];
349 t2 = t1*t1 + 4.0*delta*delta;
352 if (g <
MSQ_MIN) { obj = g;
return false; }
354 fmat[0] = aux[ 0] + aux[ 9] + aux[17] - 1.0;
355 fmat[1] = aux[ 3] + aux[12] + aux[20];
356 fmat[2] = aux[ 6] + aux[15] + aux[23];
358 fmat[3] = aux[24] + aux[30] + aux[35] - 1.0;
359 fmat[4] = aux[27] + aux[33] + aux[38];
361 fmat[5] = aux[39] + aux[42] + aux[44] - 1.0;
363 f = fmat[0]*fmat[0] + 2.0*fmat[1]*fmat[1] + 2.0*fmat[2]*fmat[2] +
364 fmat[3]*fmat[3] + 2.0*fmat[4]*fmat[4] +
371 obj = a *
pow(f, b) *
pow(g, c);
376 f = b * obj / f * 4.0;
377 g = c * obj / g * t4;
379 df[0] = fmat[0]*matr[0] + fmat[1]*matr[3] + fmat[2]*matr[6];
380 df[1] = fmat[0]*matr[1] + fmat[1]*matr[4] + fmat[2]*matr[7];
381 df[2] = fmat[0]*matr[2] + fmat[1]*matr[5] + fmat[2]*matr[8];
383 df[3] = fmat[1]*matr[0] + fmat[3]*matr[3] + fmat[4]*matr[6];
384 df[4] = fmat[1]*matr[1] + fmat[3]*matr[4] + fmat[4]*matr[7];
385 df[5] = fmat[1]*matr[2] + fmat[3]*matr[5] + fmat[4]*matr[8];
387 df[6] = fmat[2]*matr[0] + fmat[4]*matr[3] + fmat[5]*matr[6];
388 df[7] = fmat[2]*matr[1] + fmat[4]*matr[4] + fmat[5]*matr[7];
389 df[8] = fmat[2]*matr[2] + fmat[4]*matr[5] + fmat[5]*matr[8];
391 dg[3] = aux[22] - aux[16];
392 dg[4] = aux[ 8] - aux[21];
393 dg[5] = aux[14] - aux[ 7];
395 dg[6] = aux[13] - aux[19];
396 dg[7] = aux[18] - aux[ 5];
397 dg[8] = aux[ 4] - aux[11];
399 adj_m[0] = df[0]*f + dg[0]*g;
400 adj_m[1] = df[1]*f + dg[1]*g;
401 adj_m[2] = df[2]*f + dg[2]*g;
402 adj_m[3] = df[3]*f + dg[3]*g;
403 adj_m[4] = df[4]*f + dg[4]*g;
404 adj_m[5] = df[5]*f + dg[5]*g;
405 adj_m[6] = df[6]*f + dg[6]*g;
406 adj_m[7] = df[7]*f + dg[7]*g;
407 adj_m[8] = df[8]*f + dg[8]*g;
409 loc0 = invW[0][0]*adj_m[0];
410 loc1 = invW[1][0]*adj_m[0];
411 g_obj[0][0] = -loc0 - loc1;
415 loc0 = invW[0][1]*adj_m[1];
416 loc1 = invW[1][1]*adj_m[1];
417 g_obj[0][0] -= loc0 + loc1;
421 loc0 = invW[0][2]*adj_m[2];
422 loc1 = invW[1][2]*adj_m[2];
423 g_obj[0][0] -= loc0 + loc1;
427 loc0 = invW[0][0]*adj_m[3];
428 loc1 = invW[1][0]*adj_m[3];
429 g_obj[0][1] = -loc0 - loc1;
433 loc0 = invW[0][1]*adj_m[4];
434 loc1 = invW[1][1]*adj_m[4];
435 g_obj[0][1] -= loc0 + loc1;
439 loc0 = invW[0][2]*adj_m[5];
440 loc1 = invW[1][2]*adj_m[5];
441 g_obj[0][1] -= loc0 + loc1;
445 loc0 = invW[0][0]*adj_m[6];
446 loc1 = invW[1][0]*adj_m[6];
447 g_obj[0][2] = -loc0 - loc1;
451 loc0 = invW[0][1]*adj_m[7];
452 loc1 = invW[1][1]*adj_m[7];
453 g_obj[0][2] -= loc0 + loc1;
457 loc0 = invW[0][2]*adj_m[8];
458 loc1 = invW[1][2]*adj_m[8];
459 g_obj[0][2] -= loc0 + loc1;
465 ftmat[0] = aux[ 0] + aux[24] + aux[39];
466 ftmat[1] = aux[ 1] + aux[25] + aux[40];
467 ftmat[2] = aux[ 2] + aux[26] + aux[41];
469 ftmat[3] = aux[ 9] + aux[30] + aux[42];
470 ftmat[4] = aux[10] + aux[31] + aux[43];
472 ftmat[5] = aux[17] + aux[35] + aux[44];
476 cross = f * c / loc4 * t4;
477 f = f * (b - 1) / loc3 * 4.0;
478 g = g *((c - 1) * t4 + 4.0*delta*delta / t2) / loc4;
482 loc3 = df[0]*f + dg[0]*
cross;
483 loc4 = dg[0]*g + df[0]*
cross;
485 J_A[0] = loc3*df[0] + loc4*dg[0];
486 J_A[1] = loc3*df[1] + loc4*dg[1];
487 J_A[2] = loc3*df[2] + loc4*dg[2];
488 J_B[0] = loc3*df[3] + loc4*dg[3];
489 J_B[1] = loc3*df[4] + loc4*dg[4];
490 J_B[2] = loc3*df[5] + loc4*dg[5];
491 J_C[0] = loc3*df[6] + loc4*dg[6];
492 J_C[1] = loc3*df[7] + loc4*dg[7];
493 J_C[2] = loc3*df[8] + loc4*dg[8];
495 loc3 = df[1]*f + dg[1]*
cross;
496 loc4 = dg[1]*g + df[1]*
cross;
498 J_A[3] = loc3*df[1] + loc4*dg[1];
499 J_A[4] = loc3*df[2] + loc4*dg[2];
500 J_B[3] = loc3*df[3] + loc4*dg[3];
501 J_B[4] = loc3*df[4] + loc4*dg[4];
502 J_B[5] = loc3*df[5] + loc4*dg[5];
503 J_C[3] = loc3*df[6] + loc4*dg[6];
504 J_C[4] = loc3*df[7] + loc4*dg[7];
505 J_C[5] = loc3*df[8] + loc4*dg[8];
507 loc3 = df[2]*f + dg[2]*
cross;
508 loc4 = dg[2]*g + df[2]*
cross;
510 J_A[5] = loc3*df[2] + loc4*dg[2];
511 J_B[6] = loc3*df[3] + loc4*dg[3];
512 J_B[7] = loc3*df[4] + loc4*dg[4];
513 J_B[8] = loc3*df[5] + loc4*dg[5];
514 J_C[6] = loc3*df[6] + loc4*dg[6];
515 J_C[7] = loc3*df[7] + loc4*dg[7];
516 J_C[8] = loc3*df[8] + loc4*dg[8];
519 J_A[0] += loc0*(fmat[0] + ftmat[0] + aux[ 0]);
520 J_A[1] += loc0*( ftmat[1] + aux[ 1]);
521 J_A[2] += loc0*( ftmat[2] + aux[ 2]);
523 J_A[3] += loc0*(fmat[0] + ftmat[3] + aux[ 9]);
524 J_A[4] += loc0*( ftmat[4] + aux[10]);
526 J_A[5] += loc0*(fmat[0] + ftmat[5] + aux[17]);
528 loc2 = invW[0][0]+invW[1][0];
529 loc3 = invW[0][1]+invW[1][1];
530 loc4 = invW[0][2]+invW[1][2];
532 A[0] = -J_A[0]*loc2 - J_A[1]*loc3 - J_A[2]*loc4;
533 A[1] = J_A[0]*invW[0][0] + J_A[1]*invW[0][1] + J_A[2]*invW[0][2];
534 A[2] = J_A[0]*invW[1][0] + J_A[1]*invW[1][1] + J_A[2]*invW[1][2];
536 A[4] = -J_A[1]*loc2 - J_A[3]*loc3 - J_A[4]*loc4;
537 A[5] = J_A[1]*invW[0][0] + J_A[3]*invW[0][1] + J_A[4]*invW[0][2];
538 A[6] = J_A[1]*invW[1][0] + J_A[3]*invW[1][1] + J_A[4]*invW[1][2];
540 A[8] = -J_A[2]*loc2 - J_A[4]*loc3 - J_A[5]*loc4;
541 A[9] = J_A[2]*invW[0][0] + J_A[4]*invW[0][1] + J_A[5]*invW[0][2];
542 A[10] = J_A[2]*invW[1][0] + J_A[4]*invW[1][1] + J_A[5]*invW[1][2];
544 h_obj[0][0][0] = -A[0]*loc2 - A[4]*loc3 - A[8]*loc4;
545 h_obj[1][0][0] = A[0]*invW[0][0] + A[4]*invW[0][1] + A[8]*invW[0][2];
546 h_obj[2][0][0] = A[0]*invW[1][0] + A[4]*invW[1][1] + A[8]*invW[1][2];
548 h_obj[3][0][0] = A[1]*invW[0][0] + A[5]*invW[0][1] + A[9]*invW[0][2];
549 h_obj[4][0][0] = A[1]*invW[1][0] + A[5]*invW[1][1] + A[9]*invW[1][2];
551 h_obj[5][0][0] = A[2]*invW[1][0] + A[6]*invW[1][1] + A[10]*invW[1][2];
554 J_B[0] += loc0*(fmat[1] + aux[3]);
555 J_B[1] += loc0*aux[11];
556 J_B[2] += loc0*aux[18];
558 J_B[3] += loc0*aux[ 4];
559 J_B[4] += loc0*(fmat[1] + aux[12]);
560 J_B[5] += loc0*aux[19];
562 J_B[6] += loc0*aux[ 5];
563 J_B[7] += loc0*aux[13];
564 J_B[8] += loc0*(fmat[1] + aux[20]);
578 loc2 = invW[0][0]+invW[1][0];
579 loc3 = invW[0][1]+invW[1][1];
580 loc4 = invW[0][2]+invW[1][2];
582 A[0] = -J_B[0]*loc2 - J_B[1]*loc3 - J_B[2]*loc4;
583 A[1] = J_B[0]*invW[0][0] + J_B[1]*invW[0][1] + J_B[2]*invW[0][2];
584 A[2] = J_B[0]*invW[1][0] + J_B[1]*invW[1][1] + J_B[2]*invW[1][2];
586 A[4] = -J_B[3]*loc2 - J_B[4]*loc3 - J_B[5]*loc4;
587 A[5] = J_B[3]*invW[0][0] + J_B[4]*invW[0][1] + J_B[5]*invW[0][2];
588 A[6] = J_B[3]*invW[1][0] + J_B[4]*invW[1][1] + J_B[5]*invW[1][2];
590 A[8] = -J_B[6]*loc2 - J_B[7]*loc3 - J_B[8]*loc4;
591 A[9] = J_B[6]*invW[0][0] + J_B[7]*invW[0][1] + J_B[8]*invW[0][2];
592 A[10] = J_B[6]*invW[1][0] + J_B[7]*invW[1][1] + J_B[8]*invW[1][2];
594 h_obj[0][0][1] = -A[0]*loc2 - A[4]*loc3 - A[8]*loc4;
595 h_obj[1][1][0] = A[0]*invW[0][0] + A[4]*invW[0][1] + A[8]*invW[0][2];
596 h_obj[2][1][0] = A[0]*invW[1][0] + A[4]*invW[1][1] + A[8]*invW[1][2];
598 h_obj[1][0][1] = -A[1]*loc2 - A[5]*loc3 - A[9]*loc4;
599 h_obj[3][0][1] = A[1]*invW[0][0] + A[5]*invW[0][1] + A[9]*invW[0][2];
600 h_obj[4][1][0] = A[1]*invW[1][0] + A[5]*invW[1][1] + A[9]*invW[1][2];
602 h_obj[2][0][1] = -A[2]*loc2 - A[6]*loc3 - A[10]*loc4;
603 h_obj[4][0][1] = A[2]*invW[0][0] + A[6]*invW[0][1] + A[10]*invW[0][2];
604 h_obj[5][0][1] = A[2]*invW[1][0] + A[6]*invW[1][1] + A[10]*invW[1][2];
607 J_C[0] += loc0*(fmat[2] + aux[6]);
608 J_C[1] += loc0*aux[14];
609 J_C[2] += loc0*aux[21];
611 J_C[3] += loc0*aux[ 7];
612 J_C[4] += loc0*(fmat[2] + aux[15]);
613 J_C[5] += loc0*aux[22];
615 J_C[6] += loc0*aux[ 8];
616 J_C[7] += loc0*aux[16];
617 J_C[8] += loc0*(fmat[2] + aux[23]);
631 loc2 = invW[0][0]+invW[1][0];
632 loc3 = invW[0][1]+invW[1][1];
633 loc4 = invW[0][2]+invW[1][2];
635 A[0] = -J_C[0]*loc2 - J_C[1]*loc3 - J_C[2]*loc4;
636 A[1] = J_C[0]*invW[0][0] + J_C[1]*invW[0][1] + J_C[2]*invW[0][2];
637 A[2] = J_C[0]*invW[1][0] + J_C[1]*invW[1][1] + J_C[2]*invW[1][2];
639 A[4] = -J_C[3]*loc2 - J_C[4]*loc3 - J_C[5]*loc4;
640 A[5] = J_C[3]*invW[0][0] + J_C[4]*invW[0][1] + J_C[5]*invW[0][2];
641 A[6] = J_C[3]*invW[1][0] + J_C[4]*invW[1][1] + J_C[5]*invW[1][2];
643 A[8] = -J_C[6]*loc2 - J_C[7]*loc3 - J_C[8]*loc4;
644 A[9] = J_C[6]*invW[0][0] + J_C[7]*invW[0][1] + J_C[8]*invW[0][2];
645 A[10] = J_C[6]*invW[1][0] + J_C[7]*invW[1][1] + J_C[8]*invW[1][2];
647 h_obj[0][0][2] = -A[0]*loc2 - A[4]*loc3 - A[8]*loc4;
648 h_obj[1][2][0] = A[0]*invW[0][0] + A[4]*invW[0][1] + A[8]*invW[0][2];
649 h_obj[2][2][0] = A[0]*invW[1][0] + A[4]*invW[1][1] + A[8]*invW[1][2];
651 h_obj[1][0][2] = -A[1]*loc2 - A[5]*loc3 - A[9]*loc4;
652 h_obj[3][0][2] = A[1]*invW[0][0] + A[5]*invW[0][1] + A[9]*invW[0][2];
653 h_obj[4][2][0] = A[1]*invW[1][0] + A[5]*invW[1][1] + A[9]*invW[1][2];
655 h_obj[2][0][2] = -A[2]*loc2 - A[6]*loc3 - A[10]*loc4;
656 h_obj[4][0][2] = A[2]*invW[0][0] + A[6]*invW[0][1] + A[10]*invW[0][2];
657 h_obj[5][0][2] = A[2]*invW[1][0] + A[6]*invW[1][1] + A[10]*invW[1][2];
660 loc3 = df[3]*f + dg[3]*
cross;
661 loc4 = dg[3]*g + df[3]*
cross;
663 J_A[0] = loc3*df[3] + loc4*dg[3];
664 J_A[1] = loc3*df[4] + loc4*dg[4];
665 J_A[2] = loc3*df[5] + loc4*dg[5];
666 J_B[0] = loc3*df[6] + loc4*dg[6];
667 J_B[1] = loc3*df[7] + loc4*dg[7];
668 J_B[2] = loc3*df[8] + loc4*dg[8];
670 loc3 = df[4]*f + dg[4]*
cross;
671 loc4 = dg[4]*g + df[4]*
cross;
673 J_A[3] = loc3*df[4] + loc4*dg[4];
674 J_A[4] = loc3*df[5] + loc4*dg[5];
675 J_B[3] = loc3*df[6] + loc4*dg[6];
676 J_B[4] = loc3*df[7] + loc4*dg[7];
677 J_B[5] = loc3*df[8] + loc4*dg[8];
679 loc3 = df[5]*f + dg[5]*
cross;
680 loc4 = dg[5]*g + df[5]*
cross;
682 J_A[5] = loc3*df[5] + loc4*dg[5];
683 J_B[6] = loc3*df[6] + loc4*dg[6];
684 J_B[7] = loc3*df[7] + loc4*dg[7];
685 J_B[8] = loc3*df[8] + loc4*dg[8];
688 J_A[0] += loc0*(fmat[3] + ftmat[0] + aux[24]);
689 J_A[1] += loc0*( ftmat[1] + aux[25]);
690 J_A[2] += loc0*( ftmat[2] + aux[26]);
692 J_A[3] += loc0*(fmat[3] + ftmat[3] + aux[30]);
693 J_A[4] += loc0*( ftmat[4] + aux[31]);
695 J_A[5] += loc0*(fmat[3] + ftmat[5] + aux[35]);
697 loc2 = invW[0][0]+invW[1][0];
698 loc3 = invW[0][1]+invW[1][1];
699 loc4 = invW[0][2]+invW[1][2];
701 A[0] = -J_A[0]*loc2 - J_A[1]*loc3 - J_A[2]*loc4;
702 A[1] = J_A[0]*invW[0][0] + J_A[1]*invW[0][1] + J_A[2]*invW[0][2];
703 A[2] = J_A[0]*invW[1][0] + J_A[1]*invW[1][1] + J_A[2]*invW[1][2];
705 A[4] = -J_A[1]*loc2 - J_A[3]*loc3 - J_A[4]*loc4;
706 A[5] = J_A[1]*invW[0][0] + J_A[3]*invW[0][1] + J_A[4]*invW[0][2];
707 A[6] = J_A[1]*invW[1][0] + J_A[3]*invW[1][1] + J_A[4]*invW[1][2];
709 A[8] = -J_A[2]*loc2 - J_A[4]*loc3 - J_A[5]*loc4;
710 A[9] = J_A[2]*invW[0][0] + J_A[4]*invW[0][1] + J_A[5]*invW[0][2];
711 A[10] = J_A[2]*invW[1][0] + J_A[4]*invW[1][1] + J_A[5]*invW[1][2];
713 h_obj[0][1][1] = -A[0]*loc2 - A[4]*loc3 - A[8]*loc4;
714 h_obj[1][1][1] = A[0]*invW[0][0] + A[4]*invW[0][1] + A[8]*invW[0][2];
715 h_obj[2][1][1] = A[0]*invW[1][0] + A[4]*invW[1][1] + A[8]*invW[1][2];
717 h_obj[3][1][1] = A[1]*invW[0][0] + A[5]*invW[0][1] + A[9]*invW[0][2];
718 h_obj[4][1][1] = A[1]*invW[1][0] + A[5]*invW[1][1] + A[9]*invW[1][2];
720 h_obj[5][1][1] = A[2]*invW[1][0] + A[6]*invW[1][1] + A[10]*invW[1][2];
723 J_B[0] += loc0*(fmat[4] + aux[27]);
724 J_B[1] += loc0*aux[32];
725 J_B[2] += loc0*aux[36];
727 J_B[3] += loc0*aux[28];
728 J_B[4] += loc0*(fmat[4] + aux[33]);
729 J_B[5] += loc0*aux[37];
731 J_B[6] += loc0*aux[29];
732 J_B[7] += loc0*aux[34];
733 J_B[8] += loc0*(fmat[4] + aux[38]);
747 loc2 = invW[0][0]+invW[1][0];
748 loc3 = invW[0][1]+invW[1][1];
749 loc4 = invW[0][2]+invW[1][2];
751 A[0] = -J_B[0]*loc2 - J_B[1]*loc3 - J_B[2]*loc4;
752 A[1] = J_B[0]*invW[0][0] + J_B[1]*invW[0][1] + J_B[2]*invW[0][2];
753 A[2] = J_B[0]*invW[1][0] + J_B[1]*invW[1][1] + J_B[2]*invW[1][2];
755 A[4] = -J_B[3]*loc2 - J_B[4]*loc3 - J_B[5]*loc4;
756 A[5] = J_B[3]*invW[0][0] + J_B[4]*invW[0][1] + J_B[5]*invW[0][2];
757 A[6] = J_B[3]*invW[1][0] + J_B[4]*invW[1][1] + J_B[5]*invW[1][2];
759 A[8] = -J_B[6]*loc2 - J_B[7]*loc3 - J_B[8]*loc4;
760 A[9] = J_B[6]*invW[0][0] + J_B[7]*invW[0][1] + J_B[8]*invW[0][2];
761 A[10] = J_B[6]*invW[1][0] + J_B[7]*invW[1][1] + J_B[8]*invW[1][2];
763 h_obj[0][1][2] = -A[0]*loc2 - A[4]*loc3 - A[8]*loc4;
764 h_obj[1][2][1] = A[0]*invW[0][0] + A[4]*invW[0][1] + A[8]*invW[0][2];
765 h_obj[2][2][1] = A[0]*invW[1][0] + A[4]*invW[1][1] + A[8]*invW[1][2];
767 h_obj[1][1][2] = -A[1]*loc2 - A[5]*loc3 - A[9]*loc4;
768 h_obj[3][1][2] = A[1]*invW[0][0] + A[5]*invW[0][1] + A[9]*invW[0][2];
769 h_obj[4][2][1] = A[1]*invW[1][0] + A[5]*invW[1][1] + A[9]*invW[1][2];
771 h_obj[2][1][2] = -A[2]*loc2 - A[6]*loc3 - A[10]*loc4;
772 h_obj[4][1][2] = A[2]*invW[0][0] + A[6]*invW[0][1] + A[10]*invW[0][2];
773 h_obj[5][1][2] = A[2]*invW[1][0] + A[6]*invW[1][1] + A[10]*invW[1][2];
776 loc3 = df[6]*f + dg[6]*
cross;
777 loc4 = dg[6]*g + df[6]*
cross;
779 J_A[0] = loc3*df[6] + loc4*dg[6];
780 J_A[1] = loc3*df[7] + loc4*dg[7];
781 J_A[2] = loc3*df[8] + loc4*dg[8];
783 loc3 = df[7]*f + dg[7]*
cross;
784 loc4 = dg[7]*g + df[7]*
cross;
786 J_A[3] = loc3*df[7] + loc4*dg[7];
787 J_A[4] = loc3*df[8] + loc4*dg[8];
789 loc3 = df[8]*f + dg[8]*
cross;
790 loc4 = dg[8]*g + df[8]*
cross;
792 J_A[5] = loc3*df[8] + loc4*dg[8];
795 J_A[0] += loc0*(fmat[5] + ftmat[0] + aux[39]);
796 J_A[1] += loc0*( ftmat[1] + aux[40]);
797 J_A[2] += loc0*( ftmat[2] + aux[41]);
799 J_A[3] += loc0*(fmat[5] + ftmat[3] + aux[42]);
800 J_A[4] += loc0*( ftmat[4] + aux[43]);
802 J_A[5] += loc0*(fmat[5] + ftmat[5] + aux[44]);
804 loc2 = invW[0][0]+invW[1][0];
805 loc3 = invW[0][1]+invW[1][1];
806 loc4 = invW[0][2]+invW[1][2];
808 A[0] = -J_A[0]*loc2 - J_A[1]*loc3 - J_A[2]*loc4;
809 A[1] = J_A[0]*invW[0][0] + J_A[1]*invW[0][1] + J_A[2]*invW[0][2];
810 A[2] = J_A[0]*invW[1][0] + J_A[1]*invW[1][1] + J_A[2]*invW[1][2];
812 A[4] = -J_A[1]*loc2 - J_A[3]*loc3 - J_A[4]*loc4;
813 A[5] = J_A[1]*invW[0][0] + J_A[3]*invW[0][1] + J_A[4]*invW[0][2];
814 A[6] = J_A[1]*invW[1][0] + J_A[3]*invW[1][1] + J_A[4]*invW[1][2];
816 A[8] = -J_A[2]*loc2 - J_A[4]*loc3 - J_A[5]*loc4;
817 A[9] = J_A[2]*invW[0][0] + J_A[4]*invW[0][1] + J_A[5]*invW[0][2];
818 A[10] = J_A[2]*invW[1][0] + J_A[4]*invW[1][1] + J_A[5]*invW[1][2];
820 h_obj[0][2][2] = -A[0]*loc2 - A[4]*loc3 - A[8]*loc4;
821 h_obj[1][2][2] = A[0]*invW[0][0] + A[4]*invW[0][1] + A[8]*invW[0][2];
822 h_obj[2][2][2] = A[0]*invW[1][0] + A[4]*invW[1][1] + A[8]*invW[1][2];
824 h_obj[3][2][2] = A[1]*invW[0][0] + A[5]*invW[0][1] + A[9]*invW[0][2];
825 h_obj[4][2][2] = A[1]*invW[1][0] + A[5]*invW[1][1] + A[9]*invW[1][2];
827 h_obj[5][2][2] = A[2]*invW[1][0] + A[6]*invW[1][1] + A[10]*invW[1][2];
841 static double matr[9], f, t1, t2;
842 static double fmat[6], g;
845 f = x[1][0] - x[0][0];
846 g = x[2][0] - x[0][0];
847 t1 = x[3][0] - x[0][0];
848 matr[0] = f*invW[0][0] + g*invW[1][0] + t1*invW[2][0];
849 matr[1] = f*invW[0][1] + g*invW[1][1] + t1*invW[2][1];
850 matr[2] = f*invW[0][2] + g*invW[1][2] + t1*invW[2][2];
852 f = x[1][1] - x[0][1];
853 g = x[2][1] - x[0][1];
854 t1 = x[3][1] - x[0][1];
855 matr[3] = f*invW[0][0] + g*invW[1][0] + t1*invW[2][0];
856 matr[4] = f*invW[0][1] + g*invW[1][1] + t1*invW[2][1];
857 matr[5] = f*invW[0][2] + g*invW[1][2] + t1*invW[2][2];
859 f = x[1][2] - x[0][2];
860 g = x[2][2] - x[0][2];
861 t1 = x[3][2] - x[0][2];
862 matr[6] = f*invW[0][0] + g*invW[1][0] + t1*invW[2][0];
863 matr[7] = f*invW[0][1] + g*invW[1][1] + t1*invW[2][1];
864 matr[8] = f*invW[0][2] + g*invW[1][2] + t1*invW[2][2];
867 t1 = matr[0]*(matr[4]*matr[8] - matr[5]*matr[7]) +
868 matr[1]*(matr[5]*matr[6] - matr[3]*matr[8]) +
869 matr[2]*(matr[3]*matr[7] - matr[4]*matr[6]);
870 t2 =
sqrt(t1*t1 + 4.0*delta*delta);
872 if (g <
MSQ_MIN) { obj = g;
return false; }
875 fmat[0] = matr[0]*matr[0] + matr[1]*matr[1] + matr[2]*matr[2] - 1.0;
876 fmat[1] = matr[0]*matr[3] + matr[1]*matr[4] + matr[2]*matr[5];
877 fmat[2] = matr[0]*matr[6] + matr[1]*matr[7] + matr[2]*matr[8];
879 fmat[3] = matr[3]*matr[3] + matr[4]*matr[4] + matr[5]*matr[5] - 1.0;
880 fmat[4] = matr[3]*matr[6] + matr[4]*matr[7] + matr[5]*matr[8];
882 fmat[5] = matr[6]*matr[6] + matr[7]*matr[7] + matr[8]*matr[8] - 1.0;
884 f = fmat[0]*fmat[0] + 2.0*fmat[1]*fmat[1] + 2.0*fmat[2]*fmat[2] +
885 fmat[3]*fmat[3] + 2.0*fmat[4]*fmat[4] +
889 obj = a *
pow(f, b) *
pow(g, c);
898 static double matr[9], f, t1, t2;
899 static double fmat[6], g;
900 static double adj_m[9], df[9], loc1, loc2, loc3;
903 f = x[1][0] - x[0][0];
904 g = x[2][0] - x[0][0];
905 t1 = x[3][0] - x[0][0];
906 matr[0] = f*invW[0][0] + g*invW[1][0] + t1*invW[2][0];
907 matr[1] = f*invW[0][1] + g*invW[1][1] + t1*invW[2][1];
908 matr[2] = f*invW[0][2] + g*invW[1][2] + t1*invW[2][2];
910 f = x[1][1] - x[0][1];
911 g = x[2][1] - x[0][1];
912 t1 = x[3][1] - x[0][1];
913 matr[3] = f*invW[0][0] + g*invW[1][0] + t1*invW[2][0];
914 matr[4] = f*invW[0][1] + g*invW[1][1] + t1*invW[2][1];
915 matr[5] = f*invW[0][2] + g*invW[1][2] + t1*invW[2][2];
917 f = x[1][2] - x[0][2];
918 g = x[2][2] - x[0][2];
919 t1 = x[3][2] - x[0][2];
920 matr[6] = f*invW[0][0] + g*invW[1][0] + t1*invW[2][0];
921 matr[7] = f*invW[0][1] + g*invW[1][1] + t1*invW[2][1];
922 matr[8] = f*invW[0][2] + g*invW[1][2] + t1*invW[2][2];
925 loc1 = matr[4]*matr[8] - matr[5]*matr[7];
926 loc2 = matr[5]*matr[6] - matr[3]*matr[8];
927 loc3 = matr[3]*matr[7] - matr[4]*matr[6];
928 t1 = matr[0]*loc1 + matr[1]*loc2 + matr[2]*loc3;
929 t2 =
sqrt(t1*t1 + 4.0*delta*delta);
931 if (g <
MSQ_MIN) { obj = g;
return false; }
934 fmat[0] = matr[0]*matr[0] + matr[1]*matr[1] + matr[2]*matr[2] - 1.0;
935 fmat[1] = matr[0]*matr[3] + matr[1]*matr[4] + matr[2]*matr[5];
936 fmat[2] = matr[0]*matr[6] + matr[1]*matr[7] + matr[2]*matr[8];
938 fmat[3] = matr[3]*matr[3] + matr[4]*matr[4] + matr[5]*matr[5] - 1.0;
939 fmat[4] = matr[3]*matr[6] + matr[4]*matr[7] + matr[5]*matr[8];
941 fmat[5] = matr[6]*matr[6] + matr[7]*matr[7] + matr[8]*matr[8] - 1.0;
943 f = fmat[0]*fmat[0] + 2.0*fmat[1]*fmat[1] + 2.0*fmat[2]*fmat[2] +
944 fmat[3]*fmat[3] + 2.0*fmat[4]*fmat[4] +
953 obj = a * f *
pow(g, c);
954 f = a *
pow(g, c) * 2.0;
955 g = c * obj / g * (1 + t1 / t2);
958 obj = a * f * f *
pow(g, c);
959 f = a * f *
pow(g, c) * 4.0;
960 g = c * obj / g * (1 + t1 / t2);
969 obj = a *
pow(f, b) *
pow(g, c);
970 f = b * obj / f * 2.0;
971 g = c * obj / g * (1 + t1 / t2);
975 printf(
"b = %5.4e not allowed in RI_DFT\n", (
double)b);
979 df[0] = fmat[0]*matr[0] + fmat[1]*matr[3] + fmat[2]*matr[6];
980 df[1] = fmat[0]*matr[1] + fmat[1]*matr[4] + fmat[2]*matr[7];
981 df[2] = fmat[0]*matr[2] + fmat[1]*matr[5] + fmat[2]*matr[8];
983 df[3] = fmat[1]*matr[0] + fmat[3]*matr[3] + fmat[4]*matr[6];
984 df[4] = fmat[1]*matr[1] + fmat[3]*matr[4] + fmat[4]*matr[7];
985 df[5] = fmat[1]*matr[2] + fmat[3]*matr[5] + fmat[4]*matr[8];
987 df[6] = fmat[2]*matr[0] + fmat[4]*matr[3] + fmat[5]*matr[6];
988 df[7] = fmat[2]*matr[1] + fmat[4]*matr[4] + fmat[5]*matr[7];
989 df[8] = fmat[2]*matr[2] + fmat[4]*matr[5] + fmat[5]*matr[8];
991 adj_m[0] = df[0]*f + loc1*g;
992 adj_m[1] = df[1]*f + loc2*g;
993 adj_m[2] = df[2]*f + loc3*g;
999 adj_m[3] = df[3]*f + loc3*matr[7] - loc2*matr[8];
1000 adj_m[4] = df[4]*f + loc1*matr[8] - loc3*matr[6];
1001 adj_m[5] = df[5]*f + loc2*matr[6] - loc1*matr[7];
1003 adj_m[6] = df[6]*f + loc2*matr[5] - loc3*matr[4];
1004 adj_m[7] = df[7]*f + loc3*matr[3] - loc1*matr[5];
1005 adj_m[8] = df[8]*f + loc1*matr[4] - loc2*matr[3];
1007 loc1 = invW[0][0]*adj_m[0];
1008 loc2 = invW[1][0]*adj_m[0];
1009 loc3 = invW[2][0]*adj_m[0];
1010 g_obj[0][0] = -loc1 - loc2 - loc3;
1015 loc1 = invW[0][1]*adj_m[1];
1016 loc2 = invW[1][1]*adj_m[1];
1017 loc3 = invW[2][1]*adj_m[1];
1018 g_obj[0][0] -= loc1 + loc2 + loc3;
1019 g_obj[1][0] += loc1;
1020 g_obj[2][0] += loc2;
1021 g_obj[3][0] += loc3;
1023 loc1 = invW[0][2]*adj_m[2];
1024 loc2 = invW[1][2]*adj_m[2];
1025 loc3 = invW[2][2]*adj_m[2];
1026 g_obj[0][0] -= loc1 + loc2 + loc3;
1027 g_obj[1][0] += loc1;
1028 g_obj[2][0] += loc2;
1029 g_obj[3][0] += loc3;
1031 loc1 = invW[0][0]*adj_m[3];
1032 loc2 = invW[1][0]*adj_m[3];
1033 loc3 = invW[2][0]*adj_m[3];
1034 g_obj[0][1] = -loc1 - loc2 - loc3;
1039 loc1 = invW[0][1]*adj_m[4];
1040 loc2 = invW[1][1]*adj_m[4];
1041 loc3 = invW[2][1]*adj_m[4];
1042 g_obj[0][1] -= loc1 + loc2 + loc3;
1043 g_obj[1][1] += loc1;
1044 g_obj[2][1] += loc2;
1045 g_obj[3][1] += loc3;
1047 loc1 = invW[0][2]*adj_m[5];
1048 loc2 = invW[1][2]*adj_m[5];
1049 loc3 = invW[2][2]*adj_m[5];
1050 g_obj[0][1] -= loc1 + loc2 + loc3;
1051 g_obj[1][1] += loc1;
1052 g_obj[2][1] += loc2;
1053 g_obj[3][1] += loc3;
1055 loc1 = invW[0][0]*adj_m[6];
1056 loc2 = invW[1][0]*adj_m[6];
1057 loc3 = invW[2][0]*adj_m[6];
1058 g_obj[0][2] = -loc1 - loc2 - loc3;
1063 loc1 = invW[0][1]*adj_m[7];
1064 loc2 = invW[1][1]*adj_m[7];
1065 loc3 = invW[2][1]*adj_m[7];
1066 g_obj[0][2] -= loc1 + loc2 + loc3;
1067 g_obj[1][2] += loc1;
1068 g_obj[2][2] += loc2;
1069 g_obj[3][2] += loc3;
1071 loc1 = invW[0][2]*adj_m[8];
1072 loc2 = invW[1][2]*adj_m[8];
1073 loc3 = invW[2][2]*adj_m[8];
1074 g_obj[0][2] -= loc1 + loc2 + loc3;
1075 g_obj[1][2] += loc1;
1076 g_obj[2][2] += loc2;
1077 g_obj[3][2] += loc3;
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];
1793 const double id[] = {1., 0., 0., 0., 1., 0., 0., 0., 1.};
1796 for (
size_t i=0;
i<num_T; ++
i) {
1803 dft[
i] /=
pow(h, 4.0/3.0);
1833 const int tetInd[4][4] = {{0, 1, 2, 3}, {1, 2, 0, 3},
1834 {2, 0, 1, 3}, {3, 2, 1, 0}};
1835 const int hexInd[8][4] = {{0, 1, 3, 4}, {1, 2, 0, 5},
1836 {2, 3, 1, 6}, {3, 0, 2, 7},
1837 {4, 7, 5, 0}, {5, 4, 6, 1},
1838 {6, 5, 7, 2}, {7, 6, 4, 3}};
1849 for (i = 0; i < 3; ++
i) {
1850 for (j = 0; j < 3; ++
j) {
1857 mNormal = (vertices[v_i[tetInd[
i][1]]] - vertices[v_i[tetInd[
i][0]]]) *
1858 (vertices[v_i[tetInd[i][2]]] - vertices[v_i[tetInd[i][0]]]);
1866 if (!mValid)
return false;
1875 for (i = 0; i < 4; ++
i) {
1876 for (j = 0; j < 3; ++
j) {
1882 mNormal = (vertices[v_i[hexInd[
i][1]]] - vertices[v_i[hexInd[
i][0]]]) *
1883 (vertices[v_i[hexInd[i][2]]] - vertices[v_i[hexInd[i][0]]]);
1890 if (!mValid)
return false;
1899 for (i = 0; i < 4; ++
i) {
1900 for (j = 0; j < 4; ++
j) {
1907 if (!mValid)
return false;
1916 for (i = 0; i < 8; ++
i) {
1917 for (j = 0; j < 4; ++
j) {
1924 if (!mValid)
return false;
1963 const int tetInd[4][4] = {{0, 1, 2, 3}, {1, 2, 0, 3},
1964 {2, 0, 1, 3}, {3, 2, 1, 0}};
1965 const int hexInd[8][4] = {{0, 1, 3, 4}, {1, 2, 0, 5},
1966 {2, 3, 1, 6}, {3, 0, 2, 7},
1967 {4, 7, 5, 0}, {5, 4, 6, 1},
1968 {6, 5, 7, 2}, {7, 6, 4, 3}};
1990 for (i = 0; i < 3; ++
i) {
1994 for (i = 0; i < 3; ++
i) {
1995 for (j = 0; j < 3; ++
j) {
2007 if (!mValid)
return false;
2010 for (j = 0; j < 3; ++
j) {
2016 for (i = 0; i < 3; ++
i) {
2024 for (i = 0; i < 3; ++
i) {
2025 for (j = 0; j < nfv; ++
j) {
2026 if (vertices + v_i[i] == fv[j]) {
2047 for (i = 0; i < 4; ++
i) {
2051 for (i = 0; i < 4; ++
i) {
2052 for (j = 0; j < 3; ++
j) {
2063 if (!mValid)
return false;
2066 for (j = 0; j < 3; ++
j) {
2072 for (i = 0; i < 4; ++
i) {
2080 for (i = 0; i < 4; ++
i) {
2081 for (j = 0; j < nfv; ++
j) {
2082 if (vertices + v_i[i] == fv[j]) {
2093 for (i = 0; i < 4; ++
i) {
2097 for (i = 0; i < 4; ++
i) {
2098 for (j = 0; j < 4; ++
j) {
2105 if (!mValid)
return false;
2108 for (j = 0; j < 4; ++
j) {
2114 for (i = 0; i < 4; ++
i) {
2122 for (i = 0; i < 4; ++
i) {
2123 for (
size_t k = 0;
k < nv; ++
k) {
2124 if (vertices + v_i[i] == fv[
k]) {
2133 for (i = 0; i < 8; ++
i) {
2137 for (i = 0; i < 8; ++
i) {
2138 for (j = 0; j < 4; ++
j) {
2145 if (!mValid)
return false;
2148 for (j = 0; j < 4; ++
j) {
2154 for (i = 0; i < 8; ++
i) {
2162 for (i = 0; i < 8; ++
i) {
2163 for (j = 0; j < nfv; ++
j) {
2164 if (vertices + v_i[i] == fv[j]) {
2204 const int tetInd[4][4] = {{0, 1, 2, 3}, {1, 2, 0, 3},
2205 {2, 0, 1, 3}, {3, 2, 1, 0}};
2206 const int hexInd[8][4] = {{0, 1, 3, 4}, {1, 2, 0, 5},
2207 {2, 3, 1, 6}, {3, 0, 2, 7},
2208 {4, 7, 5, 0}, {5, 4, 6, 1},
2209 {6, 5, 7, 2}, {7, 6, 4, 3}};
2233 for (i = 0; i < 3; ++
i) {
2237 for (i = 0; i < 6; ++
i) {
2242 for (i = 0; i < 3; ++
i) {
2243 for (j = 0; j < 3; ++
j) {
2255 if (!mValid)
return false;
2259 for (j = 0; j < 3; ++
j) {
2264 for (j = 0; j < 3; ++
j) {
2265 for (k = j; k < 3; ++
k) {
2270 loc = 3*row - (row*(row+1)/2) + col;
2274 loc = 3*col - (col*(col+1)/2) + row;
2283 for (i = 0; i < 3; ++
i) {
2287 for (i = 0; i < 6; ++
i) {
2293 for (i = 0; i < 3; ++
i) {
2294 if (vertices + v_i[i] == fv[j]) {
2334 for (i = 0; i < 4; ++
i) {
2338 for (i = 0; i < 10; ++
i) {
2343 for (i = 0; i < 4; ++
i) {
2344 for (j = 0; j < 3; ++
j) {
2355 if (!mValid)
return false;
2359 for (j = 0; j < 3; ++
j) {
2364 for (j = 0; j < 3; ++
j) {
2365 for (k = j; k < 3; ++
k) {
2370 loc = 4*row - (row*(row+1)/2) + col;
2374 loc = 4*col - (col*(col+1)/2) + row;
2383 for (i = 0; i < 4; ++
i) {
2387 for (i = 0; i < 10; ++
i) {
2393 for (i = 0; i < 4; ++
i) {
2394 if (vertices + v_i[i] == fv[j]) {
2428 for (i = 0; i < 4; ++
i) {
2432 for (i = 0; i < 10; ++
i) {
2437 for (i = 0; i < 4; ++
i) {
2438 for (j = 0; j < 4; ++
j) {
2446 if (!mValid)
return false;
2450 for (j = 0; j < 4; ++
j) {
2455 for (j = 0; j < 4; ++
j) {
2456 for (k = j; k < 4; ++
k) {
2461 loc = 4*row - (row*(row+1)/2) + col;
2465 loc = 4*col - (col*(col+1)/2) + row;
2474 for (i = 0; i < 4; ++
i) {
2478 for (i = 0; i < 10; ++
i) {
2484 for (i = 0; i < 4; ++
i) {
2485 if (vertices + v_i[i] == fv[j]) {
2517 for (i = 0; i < 8; ++
i) {
2521 for (i = 0; i < 36; ++
i) {
2526 for (i = 0; i < 8; ++
i) {
2527 for (j = 0; j < 4; ++
j) {
2535 if (!mValid)
return false;
2539 for (j = 0; j < 4; ++
j) {
2544 for (j = 0; j < 4; ++
j) {
2545 for (k = j; k < 4; ++
k) {
2550 loc = 8*row - (row*(row+1)/2) + col;
2554 loc = 8*col - (col*(col+1)/2) + row;
2563 for (i = 0; i < 8; ++
i) {
2567 for (i = 0; i < 36; ++
i) {
2573 for (i = 0; i < 8; ++
i) {
2574 if (vertices + v_i[i] == fv[j]) {
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
static const double MSQ_ONE_THIRD
bool compute_element_numerical_gradient(PatchData &pd, MsqMeshEntity *element, MsqVertex *free_vtces[], Vector3D grad_vec[], int num_free_vtx, double &metric_value, MsqError &err)
Non-virtual function which numerically computes the gradient of a QualityMetric of a given element fo...
void zero()
Sets all entries to zero (more efficient than assignement).
NVec< 3, T > cross(const NVec< 3, T > &u, const NVec< 3, T > &v)
bool compute_element_numerical_hessian(PatchData &pd, MsqMeshEntity *element, MsqVertex *free_vtces[], Vector3D grad_vec[], Matrix3D hessian[], int num_free_vtx, double &metric_value, MsqError &err)
CornerTag< TargetMatrix > targetMatrices
Target matrix data.
Used to hold the error state and return it to the application.
Matrix3D transpose(const Matrix3D &A)
requested functionality is not (yet) implemented
MsqMeshEntity is the Mesquite object that stores information about the elements in the mesh...
Vector3D is the object that effeciently stores information about about three-deminsional vectors...
const int MSQ_MAX_NUM_VERT_PER_ENT
bool compute_element_analytical_gradient(PatchData &pd, MsqMeshEntity *e, MsqVertex *fv[], Vector3D g[], int nfv, double &m, MsqError &err)
Virtual function that computes the gradient of the QualityMetric analytically. The base class impleme...
double Frobenius_2(const Matrix3D &A)
Return the square of the Frobenius norm of A, i.e. sum (diag (A' * A))
bool compute_element_analytical_hessian(PatchData &pd, MsqMeshEntity *e, MsqVertex *fv[], Vector3D g[], Matrix3D h[], int nfv, double &m, MsqError &err)
msq_stdc::size_t vertex_count() const
Returns the number of vertices in this element, based on its element type.
double get_barrier_delta(MsqError &err)
Returns delta based on the minimum and maximum corner determinant over all elements in the patch This...
#define MSQ_CHKERR(err)
Mesquite's Error Checking macro.
size_t get_element_index(MsqMeshEntity *element)
3*3 Matric class, row-oriented, 0-based [i][j] indexing.
double weighted_average_metrics(const double coef[], const double metric_values[], const int &num_values, MsqError &err)
takes an array of coefficients and an array of metrics (both of length num_value) and averages the co...
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
void compute_T_matrices(MsqMeshEntity &elem, PatchData &pd, Matrix3D T[], size_t num_T, double c_k[], MsqError &err)
For a given element, compute each corner matrix A, and given a target corner matrix W...
bool m_fcn_ridft3(double &obj, const Vector3D x[4], const Matrix3D &invW, const double a, const Exponent b, const Exponent c, const double delta)
bool g_fcn_ridft2(double &obj, Vector3D g_obj[3], const Vector3D x[3], const Vector3D &n, const Matrix3D &invW, const double a, const Exponent b, const Exponent c, const double delta)
double det(const Matrix3D &A)
void fill_lower_triangle()
const MsqVertex * get_vertex_array(MsqError &err) const
Returns a pointer to the start of the vertex array.
bool evaluate_element(PatchData &pd, MsqMeshEntity *e, double &m, MsqError &err)
Evaluate the metric for an element.
void get_domain_normal_at_vertex(size_t vertex_index, bool normalize, Vector3D &surf_norm, MsqError &err)
Class containing the target corner matrices for the context based smoothing.
EntityTopology get_element_type() const
Returns element type.
const msq_stdc::size_t * get_vertex_index_array() const
Very efficient retrieval of vertices indexes (corresponding to the PatchData vertex array)...
void inv(Matrix3D &Ainv, const Matrix3D &A)
bool get_barrier_function(PatchData &pd, const double &tau, double &h, MsqError &err)
bool h_fcn_ridft2(double &obj, Vector3D g_obj[3], Matrix3D h_obj[6], const Vector3D x[3], const Vector3D &n, const Matrix3D &invW, const double a, const Exponent b, const Exponent c, const double delta)
MsqVertex is the Mesquite object that stores information about the vertices in the mesh...
double pow(double value, const Exponent &exp)
bool m_fcn_ridft2(double &obj, const Vector3D x[3], const Vector3D &n, const Matrix3D &invW, const double a, const Exponent b, const Exponent c, const double delta)
bool h_fcn_ridft3(double &obj, Vector3D g_obj[4], Matrix3D h_obj[10], const Vector3D x[4], const Matrix3D &invW, const double a, const Exponent b, const Exponent c, const double delta)
static const double MSQ_3RT_2_OVER_6RT_3
bool g_fcn_ridft3(double &obj, Vector3D g_obj[4], const Vector3D x[4], const Matrix3D &invW, const double a, const Exponent b, const Exponent c, const double delta)