38 #ifndef MeanRatioFunctions_hpp
39 #define MeanRatioFunctions_hpp
43 #include "Vector3D.hpp"
44 #include "Matrix3D.hpp"
45 #include "Exponent.hpp"
115 #define isqrt3 5.77350269189625797959429519858e-01
116 #define tisqrt3 1.15470053837925159591885903972e+00
117 #define isqrt6 4.08248290463863052509822647505e-01
118 #define tisqrt6 1.22474487139158915752946794252e+00
132 const double a,
const Exponent& b,
const Exponent& c)
138 matr[0] = x[1][0] - x[0][0];
139 matr[1] = (2.0*x[2][0] - x[1][0] - x[0][0])*
isqrt3;
142 matr[3] = x[1][1] - x[0][1];
143 matr[4] = (2.0*x[2][1] - x[1][1] - x[0][1])*
isqrt3;
146 matr[6] = x[1][2] - x[0][2];
147 matr[7] = (2.0*x[2][2] - x[1][2] - x[0][2])*
isqrt3;
151 g = matr[0]*(matr[4]*matr[8] - matr[5]*matr[7]) +
152 matr[3]*(matr[2]*matr[7] - matr[1]*matr[8]) +
153 matr[6]*(matr[1]*matr[5] - matr[2]*matr[4]);
154 if (g <
MSQ_MIN) { obj = g;
return false; }
157 f = matr[0]*matr[0] + matr[1]*matr[1] +
158 matr[3]*matr[3] + matr[4]*matr[4] +
159 matr[6]*matr[6] + matr[7]*matr[7];
162 obj = a *
pow(f, b) *
pow(g, c);
172 const double a,
const Exponent& b,
const Exponent& c)
176 double loc1, loc2, loc3;
179 matr[0] = x[1][0] - x[0][0];
180 matr[1] = (2.0*x[2][0] - x[1][0] - x[0][0])*
isqrt3;
183 matr[3] = x[1][1] - x[0][1];
184 matr[4] = (2.0*x[2][1] - x[1][1] - x[0][1])*
isqrt3;
187 matr[6] = x[1][2] - x[0][2];
188 matr[7] = (2.0*x[2][2] - x[1][2] - x[0][2])*
isqrt3;
192 loc1 = matr[4]*matr[8] - matr[5]*matr[7];
193 loc2 = matr[2]*matr[7] - matr[1]*matr[8];
194 loc3 = matr[1]*matr[5] - matr[2]*matr[4];
195 g = matr[0]*loc1 + matr[3]*loc2 + matr[6]*loc3;
196 if (g <
MSQ_MIN) { obj = g;
return false; }
199 f = matr[0]*matr[0] + matr[1]*matr[1] +
200 matr[3]*matr[3] + matr[4]*matr[4] +
201 matr[6]*matr[6] + matr[7]*matr[7];
204 obj = a *
pow(f, b) *
pow(g, c);
211 adj_m[0] = matr[0]*f + loc1*g;
212 adj_m[3] = matr[3]*f + loc2*g;
213 adj_m[6] = matr[6]*f + loc3*g;
219 adj_m[1] = matr[1]*f + loc3*matr[5] - loc2*matr[8];
220 adj_m[4] = matr[4]*f + loc1*matr[8] - loc3*matr[2];
221 adj_m[7] = matr[7]*f + loc2*matr[2] - loc1*matr[5];
224 g_obj[0][0] = -adj_m[0] - loc1;
225 g_obj[1][0] = adj_m[0] - loc1;
226 g_obj[2][0] = 2.0*loc1;
229 g_obj[0][1] = -adj_m[3] - loc1;
230 g_obj[1][1] = adj_m[3] - loc1;
231 g_obj[2][1] = 2.0*loc1;
234 g_obj[0][2] = -adj_m[6] - loc1;
235 g_obj[1][2] = adj_m[6] - loc1;
236 g_obj[2][2] = 2.0*loc1;
246 const double a,
const Exponent& b,
const Exponent& c)
251 double loc0, loc1, loc2, loc3, loc4;
252 double A[12], J_A[6], J_B[9], J_C[9],
cross;
255 matr[0] = x[1][0] - x[0][0];
256 matr[1] = (2.0*x[2][0] - x[1][0] - x[0][0])*
isqrt3;
259 matr[3] = x[1][1] - x[0][1];
260 matr[4] = (2.0*x[2][1] - x[1][1] - x[0][1])*
isqrt3;
263 matr[6] = x[1][2] - x[0][2];
264 matr[7] = (2.0*x[2][2] - x[1][2] - x[0][2])*
isqrt3;
268 dg[0] = matr[4]*matr[8] - matr[5]*matr[7];
269 dg[3] = matr[2]*matr[7] - matr[1]*matr[8];
270 dg[6] = matr[1]*matr[5] - matr[2]*matr[4];
271 g = matr[0]*dg[0] + matr[3]*dg[3] + matr[6]*dg[6];
272 if (g <
MSQ_MIN) { obj = g;
return false; }
275 f = matr[0]*matr[0] + matr[1]*matr[1] +
276 matr[3]*matr[3] + matr[4]*matr[4] +
277 matr[6]*matr[6] + matr[7]*matr[7];
283 obj = a *
pow(f, b) *
pow(g, c);
290 dg[1] = matr[5]*matr[6] - matr[3]*matr[8];
291 dg[4] = matr[0]*matr[8] - matr[2]*matr[6];
292 dg[7] = matr[2]*matr[3] - matr[0]*matr[5];
294 adj_m[0] = matr[0]*f + dg[0]*g;
295 adj_m[1] = matr[1]*f + dg[1]*g;
296 adj_m[3] = matr[3]*f + dg[3]*g;
297 adj_m[4] = matr[4]*f + dg[4]*g;
298 adj_m[6] = matr[6]*f + dg[6]*g;
299 adj_m[7] = matr[7]*f + dg[7]*g;
302 g_obj[0][0] = -adj_m[0] - loc1;
303 g_obj[1][0] = adj_m[0] - loc1;
304 g_obj[2][0] = 2.0*loc1;
307 g_obj[0][1] = -adj_m[3] - loc1;
308 g_obj[1][1] = adj_m[3] - loc1;
309 g_obj[2][1] = 2.0*loc1;
312 g_obj[0][2] = -adj_m[6] - loc1;
313 g_obj[1][2] = adj_m[6] - loc1;
314 g_obj[2][2] = 2.0*loc1;
319 cross = f * c / loc4;
320 f = f * (b-1) / loc3;
321 g = g * (c-1) / loc4;
325 loc3 = matr[0]*f + dg[0]*
cross;
326 loc4 = dg[0]*g + matr[0]*
cross;
328 J_A[0] = loc0 + loc3*matr[0] + loc4*dg[0];
329 J_A[1] = loc3*matr[1] + loc4*dg[1];
330 J_B[0] = loc3*matr[3] + loc4*dg[3];
331 J_B[1] = loc3*matr[4] + loc4*dg[4];
332 J_C[0] = loc3*matr[6] + loc4*dg[6];
333 J_C[1] = loc3*matr[7] + loc4*dg[7];
335 loc3 = matr[1]*f + dg[1]*
cross;
336 loc4 = dg[1]*g + matr[1]*
cross;
338 J_A[3] = loc0 + loc3*matr[1] + loc4*dg[1];
339 J_B[3] = loc3*matr[3] + loc4*dg[3];
340 J_B[4] = loc3*matr[4] + loc4*dg[4];
341 J_C[3] = loc3*matr[6] + loc4*dg[6];
342 J_C[4] = loc3*matr[7] + loc4*dg[7];
346 A[0] = -J_A[0] - loc2;
347 A[1] = J_A[0] - loc2;
350 A[4] = -J_A[1] - loc2;
351 A[5] = J_A[1] - loc2;
355 h_obj[0][0][0] = -A[0] - loc2;
356 h_obj[1][0][0] = A[0] - loc2;
357 h_obj[2][0][0] = 2.0*loc2;
360 h_obj[3][0][0] = A[1] - loc2;
361 h_obj[4][0][0] = 2.0*loc2;
371 A[0] = -J_B[0] - loc2;
372 A[1] = J_B[0] - loc2;
376 A[4] = -J_B[1] - loc2;
377 A[5] = J_B[1] - loc2;
381 h_obj[0][0][1] = -A[0] - loc2;
382 h_obj[1][0][1] = A[0] - loc2;
383 h_obj[2][0][1] = 2.0*loc2;
386 h_obj[1][1][0] = -A[1] - loc2;
387 h_obj[3][0][1] = A[1] - loc2;
388 h_obj[4][0][1] = 2.0*loc2;
391 h_obj[2][1][0] = -A[2] - loc2;
392 h_obj[4][1][0] = A[2] - loc2;
393 h_obj[5][0][1] = 2.0*loc2;
401 A[0] = -J_C[0] - loc2;
402 A[1] = J_C[0] - loc2;
406 A[4] = -J_C[1] - loc2;
407 A[5] = J_C[1] - loc2;
411 h_obj[0][0][2] = -A[0] - loc2;
412 h_obj[1][0][2] = A[0] - loc2;
413 h_obj[2][0][2] = 2.0*loc2;
416 h_obj[1][2][0] = -A[1] - loc2;
417 h_obj[3][0][2] = A[1] - loc2;
418 h_obj[4][0][2] = 2.0*loc2;
421 h_obj[2][2][0] = -A[2] - loc2;
422 h_obj[4][2][0] = A[2] - loc2;
423 h_obj[5][0][2] = 2.0*loc2;
426 loc3 = matr[3]*f + dg[3]*
cross;
427 loc4 = dg[3]*g + matr[3]*
cross;
429 J_A[0] = loc0 + loc3*matr[3] + loc4*dg[3];
430 J_A[1] = loc3*matr[4] + loc4*dg[4];
431 J_B[0] = loc3*matr[6] + loc4*dg[6];
432 J_B[1] = loc3*matr[7] + loc4*dg[7];
434 loc3 = matr[4]*f + dg[4]*
cross;
435 loc4 = dg[4]*g + matr[4]*
cross;
437 J_A[3] = loc0 + loc3*matr[4] + loc4*dg[4];
438 J_B[3] = loc3*matr[6] + loc4*dg[6];
439 J_B[4] = loc3*matr[7] + loc4*dg[7];
443 A[0] = -J_A[0] - loc2;
444 A[1] = J_A[0] - loc2;
447 A[4] = -J_A[1] - loc2;
448 A[5] = J_A[1] - loc2;
452 h_obj[0][1][1] = -A[0] - loc2;
453 h_obj[1][1][1] = A[0] - loc2;
454 h_obj[2][1][1] = 2.0*loc2;
457 h_obj[3][1][1] = A[1] - loc2;
458 h_obj[4][1][1] = 2.0*loc2;
468 A[0] = -J_B[0] - loc2;
469 A[1] = J_B[0] - loc2;
473 A[4] = -J_B[1] - loc2;
474 A[5] = J_B[1] - loc2;
478 h_obj[0][1][2] = -A[0] - loc2;
479 h_obj[1][1][2] = A[0] - loc2;
480 h_obj[2][1][2] = 2.0*loc2;
483 h_obj[1][2][1] = -A[1] - loc2;
484 h_obj[3][1][2] = A[1] - loc2;
485 h_obj[4][1][2] = 2.0*loc2;
488 h_obj[2][2][1] = -A[2] - loc2;
489 h_obj[4][2][1] = A[2] - loc2;
490 h_obj[5][1][2] = 2.0*loc2;
493 loc3 = matr[6]*f + dg[6]*
cross;
494 loc4 = dg[6]*g + matr[6]*
cross;
496 J_A[0] = loc0 + loc3*matr[6] + loc4*dg[6];
497 J_A[1] = loc3*matr[7] + loc4*dg[7];
499 loc3 = matr[7]*f + dg[7]*
cross;
500 loc4 = dg[7]*g + matr[7]*
cross;
502 J_A[3] = loc0 + loc3*matr[7] + loc4*dg[7];
506 A[0] = -J_A[0] - loc2;
507 A[1] = J_A[0] - loc2;
510 A[4] = -J_A[1] - loc2;
511 A[5] = J_A[1] - loc2;
515 h_obj[0][2][2] = -A[0] - loc2;
516 h_obj[1][2][2] = A[0] - loc2;
517 h_obj[2][2][2] = 2.0*loc2;
520 h_obj[3][2][2] = A[1] - loc2;
521 h_obj[4][2][2] = 2.0*loc2;
526 h_obj[0].fill_lower_triangle();
527 h_obj[3].fill_lower_triangle();
528 h_obj[5].fill_lower_triangle();
544 const double a,
const Exponent& b,
const Exponent& c,
552 matr[0] = d[0]*(x[1][0] - x[0][0]);
553 matr[1] = d[1]*(x[2][0] - x[0][0]);
556 matr[3] = d[0]*(x[1][1] - x[0][1]);
557 matr[4] = d[1]*(x[2][1] - x[0][1]);
560 matr[6] = d[0]*(x[1][2] - x[0][2]);
561 matr[7] = d[1]*(x[2][2] - x[0][2]);
565 g = matr[0]*(matr[4]*matr[8] - matr[5]*matr[7]) +
566 matr[3]*(matr[2]*matr[7] - matr[1]*matr[8]) +
567 matr[6]*(matr[1]*matr[5] - matr[2]*matr[4]);
568 if (g <
MSQ_MIN) { obj = g;
return false; }
571 f = matr[0]*matr[0] + matr[1]*matr[1] +
572 matr[3]*matr[3] + matr[4]*matr[4] +
573 matr[6]*matr[6] + matr[7]*matr[7];
576 obj = a *
pow(f, b) *
pow(g, c);
586 const double a,
const Exponent& b,
const Exponent& c,
591 double loc1, loc2, loc3;
594 matr[0] = d[0]*(x[1][0] - x[0][0]);
595 matr[1] = d[1]*(x[2][0] - x[0][0]);
598 matr[3] = d[0]*(x[1][1] - x[0][1]);
599 matr[4] = d[1]*(x[2][1] - x[0][1]);
602 matr[6] = d[0]*(x[1][2] - x[0][2]);
603 matr[7] = d[1]*(x[2][2] - x[0][2]);
607 loc1 = matr[4]*matr[8] - matr[5]*matr[7];
608 loc2 = matr[2]*matr[7] - matr[1]*matr[8];
609 loc3 = matr[1]*matr[5] - matr[2]*matr[4];
610 g = matr[0]*loc1 + matr[3]*loc2 + matr[6]*loc3;
611 if (g <
MSQ_MIN) { obj = g;
return false; }
614 f = matr[0]*matr[0] + matr[1]*matr[1] +
615 matr[3]*matr[3] + matr[4]*matr[4] +
616 matr[6]*matr[6] + matr[7]*matr[7];
619 obj = a *
pow(f, b) *
pow(g, c);
626 adj_m[0] = d[0]*(matr[0]*f + loc1*g);
627 adj_m[3] = d[0]*(matr[3]*f + loc2*g);
628 adj_m[6] = d[0]*(matr[6]*f + loc3*g);
634 adj_m[1] = d[1]*(matr[1]*f + loc3*matr[5] - loc2*matr[8]);
635 adj_m[4] = d[1]*(matr[4]*f + loc1*matr[8] - loc3*matr[2]);
636 adj_m[7] = d[1]*(matr[7]*f + loc2*matr[2] - loc1*matr[5]);
638 g_obj[0][0] = -adj_m[0] - adj_m[1];
639 g_obj[1][0] = adj_m[0];
640 g_obj[2][0] = adj_m[1];
642 g_obj[0][1] = -adj_m[3] - adj_m[4];
643 g_obj[1][1] = adj_m[3];
644 g_obj[2][1] = adj_m[4];
646 g_obj[0][2] = -adj_m[6] - adj_m[7];
647 g_obj[1][2] = adj_m[6];
648 g_obj[2][2] = adj_m[7];
658 const double a,
const Exponent& b,
const Exponent& c,
664 double loc0, loc1, loc2, loc3, loc4;
665 double A[12], J_A[6], J_B[9], J_C[9],
cross;
667 const double scale[3] = {
668 d[0]*d[0], d[0]*d[1],
673 matr[0] = d[0]*(x[1][0] - x[0][0]);
674 matr[1] = d[1]*(x[2][0] - x[0][0]);
677 matr[3] = d[0]*(x[1][1] - x[0][1]);
678 matr[4] = d[1]*(x[2][1] - x[0][1]);
681 matr[6] = d[0]*(x[1][2] - x[0][2]);
682 matr[7] = d[1]*(x[2][2] - x[0][2]);
686 dg[0] = matr[4]*matr[8] - matr[5]*matr[7];
687 dg[3] = matr[2]*matr[7] - matr[1]*matr[8];
688 dg[6] = matr[1]*matr[5] - matr[2]*matr[4];
689 g = matr[0]*dg[0] + matr[3]*dg[3] + matr[6]*dg[6];
690 if (g <
MSQ_MIN) { obj = g;
return false; }
693 f = matr[0]*matr[0] + matr[1]*matr[1] +
694 matr[3]*matr[3] + matr[4]*matr[4] +
695 matr[6]*matr[6] + matr[7]*matr[7];
701 obj = a *
pow(f, b) *
pow(g, c);
708 dg[1] = matr[5]*matr[6] - matr[3]*matr[8];
709 dg[4] = matr[0]*matr[8] - matr[2]*matr[6];
710 dg[7] = matr[2]*matr[3] - matr[0]*matr[5];
712 adj_m[0] = d[0]*(matr[0]*f + dg[0]*g);
713 adj_m[1] = d[1]*(matr[1]*f + dg[1]*g);
714 adj_m[3] = d[0]*(matr[3]*f + dg[3]*g);
715 adj_m[4] = d[1]*(matr[4]*f + dg[4]*g);
716 adj_m[6] = d[0]*(matr[6]*f + dg[6]*g);
717 adj_m[7] = d[1]*(matr[7]*f + dg[7]*g);
719 g_obj[0][0] = -adj_m[0] - adj_m[1];
720 g_obj[1][0] = adj_m[0];
721 g_obj[2][0] = adj_m[1];
723 g_obj[0][1] = -adj_m[3] - adj_m[4];
724 g_obj[1][1] = adj_m[3];
725 g_obj[2][1] = adj_m[4];
727 g_obj[0][2] = -adj_m[6] - adj_m[7];
728 g_obj[1][2] = adj_m[6];
729 g_obj[2][2] = adj_m[7];
734 cross = f * c / loc4;
735 f = f * (b-1) / loc3;
736 g = g * (c-1) / loc4;
740 loc3 = matr[0]*f + dg[0]*
cross;
741 loc4 = dg[0]*g + matr[0]*
cross;
743 J_A[0] = loc0 + loc3*matr[0] + loc4*dg[0];
744 J_A[1] = loc3*matr[1] + loc4*dg[1];
745 J_B[0] = loc3*matr[3] + loc4*dg[3];
746 J_B[1] = loc3*matr[4] + loc4*dg[4];
747 J_C[0] = loc3*matr[6] + loc4*dg[6];
748 J_C[1] = loc3*matr[7] + loc4*dg[7];
750 loc3 = matr[1]*f + dg[1]*
cross;
751 loc4 = dg[1]*g + matr[1]*
cross;
753 J_A[3] = loc0 + loc3*matr[1] + loc4*dg[1];
754 J_B[3] = loc3*matr[3] + loc4*dg[3];
755 J_B[4] = loc3*matr[4] + loc4*dg[4];
756 J_C[3] = loc3*matr[6] + loc4*dg[6];
757 J_C[4] = loc3*matr[7] + loc4*dg[7];
764 A[0] = -J_A[0] - J_A[1];
765 A[4] = -J_A[1] - J_A[3];
767 h_obj[0][0][0] = -A[0] - A[4];
768 h_obj[1][0][0] = A[0];
769 h_obj[2][0][0] = A[4];
771 h_obj[3][0][0] = J_A[0];
772 h_obj[4][0][0] = J_A[1];
774 h_obj[5][0][0] = J_A[3];
786 A[0] = -J_B[0] - J_B[3];
787 A[4] = -J_B[1] - J_B[4];
789 h_obj[0][0][1] = -A[0] - A[4];
790 h_obj[1][0][1] = A[0];
791 h_obj[2][0][1] = A[4];
793 h_obj[1][1][0] = -J_B[0] - J_B[1];
794 h_obj[3][0][1] = J_B[0];
795 h_obj[4][0][1] = J_B[1];
797 h_obj[2][1][0] = -J_B[3] - J_B[4];
798 h_obj[4][1][0] = J_B[3];
799 h_obj[5][0][1] = J_B[4];
811 A[0] = -J_C[0] - J_C[3];
812 A[4] = -J_C[1] - J_C[4];
814 h_obj[0][0][2] = -A[0] - A[4];
815 h_obj[1][0][2] = A[0];
816 h_obj[2][0][2] = A[4];
818 h_obj[1][2][0] = -J_C[0] - J_C[1];
819 h_obj[3][0][2] = J_C[0];
820 h_obj[4][0][2] = J_C[1];
822 h_obj[2][2][0] = -J_C[3] - J_C[4];
823 h_obj[4][2][0] = J_C[3];
824 h_obj[5][0][2] = J_C[4];
827 loc3 = matr[3]*f + dg[3]*
cross;
828 loc4 = dg[3]*g + matr[3]*
cross;
830 J_A[0] = loc0 + loc3*matr[3] + loc4*dg[3];
831 J_A[1] = loc3*matr[4] + loc4*dg[4];
832 J_B[0] = loc3*matr[6] + loc4*dg[6];
833 J_B[1] = loc3*matr[7] + loc4*dg[7];
835 loc3 = matr[4]*f + dg[4]*
cross;
836 loc4 = dg[4]*g + matr[4]*
cross;
838 J_A[3] = loc0 + loc3*matr[4] + loc4*dg[4];
839 J_B[3] = loc3*matr[6] + loc4*dg[6];
840 J_B[4] = loc3*matr[7] + loc4*dg[7];
847 A[0] = -J_A[0] - J_A[1];
848 A[4] = -J_A[1] - J_A[3];
850 h_obj[0][1][1] = -A[0] - A[4];
851 h_obj[1][1][1] = A[0];
852 h_obj[2][1][1] = A[4];
854 h_obj[3][1][1] = J_A[0];
855 h_obj[4][1][1] = J_A[1];
857 h_obj[5][1][1] = J_A[3];
869 A[0] = -J_B[0] - J_B[3];
870 A[4] = -J_B[1] - J_B[4];
872 h_obj[0][1][2] = -A[0] - A[4];
873 h_obj[1][1][2] = A[0];
874 h_obj[2][1][2] = A[4];
876 h_obj[1][2][1] = -J_B[0] - J_B[1];
877 h_obj[3][1][2] = J_B[0];
878 h_obj[4][1][2] = J_B[1];
880 h_obj[2][2][1] = -J_B[3] - J_B[4];
881 h_obj[4][2][1] = J_B[3];
882 h_obj[5][1][2] = J_B[4];
885 loc3 = matr[6]*f + dg[6]*
cross;
886 loc4 = dg[6]*g + matr[6]*
cross;
888 J_A[0] = loc0 + loc3*matr[6] + loc4*dg[6];
889 J_A[1] = loc3*matr[7] + loc4*dg[7];
891 loc3 = matr[7]*f + dg[7]*
cross;
892 loc4 = dg[7]*g + matr[7]*
cross;
894 J_A[3] = loc0 + loc3*matr[7] + loc4*dg[7];
901 A[0] = -J_A[0] - J_A[1];
902 A[4] = -J_A[1] - J_A[3];
904 h_obj[0][2][2] = -A[0] - A[4];
905 h_obj[1][2][2] = A[0];
906 h_obj[2][2][2] = A[4];
908 h_obj[3][2][2] = J_A[0];
909 h_obj[4][2][2] = J_A[1];
911 h_obj[5][2][2] = J_A[3];
914 h_obj[0].fill_lower_triangle();
915 h_obj[3].fill_lower_triangle();
916 h_obj[5].fill_lower_triangle();
932 const double a,
const Exponent& b,
const Exponent& c)
938 f = x[1][0] + x[0][0];
939 matr[0] = x[1][0] - x[0][0];
940 matr[1] = (2.0*x[2][0] - f)*
isqrt3;
941 matr[2] = (3.0*x[3][0] - x[2][0] - f)*
isqrt6;
943 f = x[1][1] + x[0][1];
944 matr[3] = x[1][1] - x[0][1];
945 matr[4] = (2.0*x[2][1] - f)*
isqrt3;
946 matr[5] = (3.0*x[3][1] - x[2][1] - f)*
isqrt6;
948 f = x[1][2] + x[0][2];
949 matr[6] = x[1][2] - x[0][2];
950 matr[7] = (2.0*x[2][2] - f)*
isqrt3;
951 matr[8] = (3.0*x[3][2] - x[2][2] - f)*
isqrt6;
954 g = matr[0]*(matr[4]*matr[8] - matr[5]*matr[7]) +
955 matr[1]*(matr[5]*matr[6] - matr[3]*matr[8]) +
956 matr[2]*(matr[3]*matr[7] - matr[4]*matr[6]);
957 if (g <
MSQ_MIN) { obj = g;
return false; }
960 f = matr[0]*matr[0] + matr[1]*matr[1] + matr[2]*matr[2] +
961 matr[3]*matr[3] + matr[4]*matr[4] + matr[5]*matr[5] +
962 matr[6]*matr[6] + matr[7]*matr[7] + matr[8]*matr[8];
965 obj = a *
pow(f, b) *
pow(g, c);
974 const double a,
const Exponent& b,
const Exponent& c)
978 double loc1, loc2, loc3;
981 f = x[1][0] + x[0][0];
982 matr[0] = x[1][0] - x[0][0];
983 matr[1] = (2.0*x[2][0] - f)*
isqrt3;
984 matr[2] = (3.0*x[3][0] - x[2][0] - f)*
isqrt6;
986 f = x[1][1] + x[0][1];
987 matr[3] = x[1][1] - x[0][1];
988 matr[4] = (2.0*x[2][1] - f)*
isqrt3;
989 matr[5] = (3.0*x[3][1] - x[2][1] - f)*
isqrt6;
991 f = x[1][2] + x[0][2];
992 matr[6] = x[1][2] - x[0][2];
993 matr[7] = (2.0*x[2][2] - f)*
isqrt3;
994 matr[8] = (3.0*x[3][2] - x[2][2] - f)*
isqrt6;
997 loc1 = matr[4]*matr[8] - matr[5]*matr[7];
998 loc2 = matr[5]*matr[6] - matr[3]*matr[8];
999 loc3 = matr[3]*matr[7] - matr[4]*matr[6];
1000 g = matr[0]*loc1 + matr[1]*loc2 + matr[2]*loc3;
1001 if (g <
MSQ_MIN) { obj = g;
return false; }
1004 f = matr[0]*matr[0] + matr[1]*matr[1] + matr[2]*matr[2] +
1005 matr[3]*matr[3] + matr[4]*matr[4] + matr[5]*matr[5] +
1006 matr[6]*matr[6] + matr[7]*matr[7] + matr[8]*matr[8];
1009 obj = a *
pow(f, b) *
pow(g, c);
1016 adj_m[0] = matr[0]*f + loc1*g;
1017 adj_m[1] = matr[1]*f + loc2*g;
1018 adj_m[2] = matr[2]*f + loc3*g;
1024 adj_m[3] = matr[3]*f + loc3*matr[7] - loc2*matr[8];
1025 adj_m[4] = matr[4]*f + loc1*matr[8] - loc3*matr[6];
1026 adj_m[5] = matr[5]*f + loc2*matr[6] - loc1*matr[7];
1028 adj_m[6] = matr[6]*f + loc2*matr[5] - loc3*matr[4];
1029 adj_m[7] = matr[7]*f + loc3*matr[3] - loc1*matr[5];
1030 adj_m[8] = matr[8]*f + loc1*matr[4] - loc2*matr[3];
1035 g_obj[0][0] = -adj_m[0] - loc3;
1036 g_obj[1][0] = adj_m[0] - loc3;
1037 g_obj[2][0] = 2.0*loc1 - loc2;
1038 g_obj[3][0] = 3.0*loc2;
1043 g_obj[0][1] = -adj_m[3] - loc3;
1044 g_obj[1][1] = adj_m[3] - loc3;
1045 g_obj[2][1] = 2.0*loc1 - loc2;
1046 g_obj[3][1] = 3.0*loc2;
1051 g_obj[0][2] = -adj_m[6] - loc3;
1052 g_obj[1][2] = adj_m[6] - loc3;
1053 g_obj[2][2] = 2.0*loc1 - loc2;
1054 g_obj[3][2] = 3.0*loc2;
1064 const double a,
const Exponent& b,
const Exponent& c)
1071 double dg[9], loc0, loc1, loc2, loc3, loc4;
1072 double A[12], J_A[6], J_B[9], J_C[9],
cross;
1075 f = x[1][0] + x[0][0];
1076 matr[0] = x[1][0] - x[0][0];
1077 matr[1] = (2.0*x[2][0] - f)*
isqrt3;
1078 matr[2] = (3.0*x[3][0] - x[2][0] - f)*
isqrt6;
1080 f = x[1][1] + x[0][1];
1081 matr[3] = x[1][1] - x[0][1];
1082 matr[4] = (2.0*x[2][1] - f)*
isqrt3;
1083 matr[5] = (3.0*x[3][1] - x[2][1] - f)*
isqrt6;
1085 f = x[1][2] + x[0][2];
1086 matr[6] = x[1][2] - x[0][2];
1087 matr[7] = (2.0*x[2][2] - f)*
isqrt3;
1088 matr[8] = (3.0*x[3][2] - x[2][2] - f)*
isqrt6;
1091 dg[0] = matr[4]*matr[8] - matr[5]*matr[7];
1092 dg[1] = matr[5]*matr[6] - matr[3]*matr[8];
1093 dg[2] = matr[3]*matr[7] - matr[4]*matr[6];
1094 g = matr[0]*dg[0] + matr[1]*dg[1] + matr[2]*dg[2];
1095 if (g <
MSQ_MIN) { obj = g;
return false; }
1098 f = matr[0]*matr[0] + matr[1]*matr[1] + matr[2]*matr[2] +
1099 matr[3]*matr[3] + matr[4]*matr[4] + matr[5]*matr[5] +
1100 matr[6]*matr[6] + matr[7]*matr[7] + matr[8]*matr[8];
1106 obj = a *
pow(f, b) *
pow(g, c);
1113 dg[3] = matr[2]*matr[7] - matr[1]*matr[8];
1114 dg[4] = matr[0]*matr[8] - matr[2]*matr[6];
1115 dg[5] = matr[1]*matr[6] - matr[0]*matr[7];
1116 dg[6] = matr[1]*matr[5] - matr[2]*matr[4];
1117 dg[7] = matr[2]*matr[3] - matr[0]*matr[5];
1118 dg[8] = matr[0]*matr[4] - matr[1]*matr[3];
1120 adj_m[0] = matr[0]*f + dg[0]*g;
1121 adj_m[1] = matr[1]*f + dg[1]*g;
1122 adj_m[2] = matr[2]*f + dg[2]*g;
1123 adj_m[3] = matr[3]*f + dg[3]*g;
1124 adj_m[4] = matr[4]*f + dg[4]*g;
1125 adj_m[5] = matr[5]*f + dg[5]*g;
1126 adj_m[6] = matr[6]*f + dg[6]*g;
1127 adj_m[7] = matr[7]*f + dg[7]*g;
1128 adj_m[8] = matr[8]*f + dg[8]*g;
1133 g_obj[0][0] = -adj_m[0] - loc2;
1134 g_obj[1][0] = adj_m[0] - loc2;
1135 g_obj[2][0] = 2.0*loc0 - loc1;
1136 g_obj[3][0] = 3.0*loc1;
1141 g_obj[0][1] = -adj_m[3] - loc2;
1142 g_obj[1][1] = adj_m[3] - loc2;
1143 g_obj[2][1] = 2.0*loc0 - loc1;
1144 g_obj[3][1] = 3.0*loc1;
1149 g_obj[0][2] = -adj_m[6] - loc2;
1150 g_obj[1][2] = adj_m[6] - loc2;
1151 g_obj[2][2] = 2.0*loc0 - loc1;
1152 g_obj[3][2] = 3.0*loc1;
1157 cross = f * c / loc4;
1158 f = f * (b-1) / loc3;
1159 g = g * (c-1) / loc4;
1163 loc3 = matr[0]*f + dg[0]*
cross;
1164 loc4 = dg[0]*g + matr[0]*
cross;
1166 J_A[0] = loc0 + loc3*matr[0] + loc4*dg[0];
1167 J_A[1] = loc3*matr[1] + loc4*dg[1];
1168 J_A[2] = loc3*matr[2] + loc4*dg[2];
1169 J_B[0] = loc3*matr[3] + loc4*dg[3];
1170 J_B[1] = loc3*matr[4] + loc4*dg[4];
1171 J_B[2] = loc3*matr[5] + loc4*dg[5];
1172 J_C[0] = loc3*matr[6] + loc4*dg[6];
1173 J_C[1] = loc3*matr[7] + loc4*dg[7];
1174 J_C[2] = loc3*matr[8] + loc4*dg[8];
1176 loc3 = matr[1]*f + dg[1]*
cross;
1177 loc4 = dg[1]*g + matr[1]*
cross;
1179 J_A[3] = loc0 + loc3*matr[1] + loc4*dg[1];
1180 J_A[4] = loc3*matr[2] + loc4*dg[2];
1181 J_B[3] = loc3*matr[3] + loc4*dg[3];
1182 J_B[4] = loc3*matr[4] + loc4*dg[4];
1183 J_B[5] = loc3*matr[5] + loc4*dg[5];
1184 J_C[3] = loc3*matr[6] + loc4*dg[6];
1185 J_C[4] = loc3*matr[7] + loc4*dg[7];
1186 J_C[5] = loc3*matr[8] + loc4*dg[8];
1188 loc3 = matr[2]*f + dg[2]*
cross;
1189 loc4 = dg[2]*g + matr[2]*
cross;
1191 J_A[5] = loc0 + loc3*matr[2] + loc4*dg[2];
1192 J_B[6] = loc3*matr[3] + loc4*dg[3];
1193 J_B[7] = loc3*matr[4] + loc4*dg[4];
1194 J_B[8] = loc3*matr[5] + loc4*dg[5];
1195 J_C[6] = loc3*matr[6] + loc4*dg[6];
1196 J_C[7] = loc3*matr[7] + loc4*dg[7];
1197 J_C[8] = loc3*matr[8] + loc4*dg[8];
1204 A[0] = -J_A[0] - loc4;
1205 A[1] = J_A[0] - loc4;
1211 A[4] = -J_A[1] - loc4;
1212 A[5] = J_A[1] - loc4;
1213 A[6] = 2.0*loc2 - loc3;
1219 A[8] = -J_A[2] - loc4;
1220 A[9] = J_A[2] - loc4;
1221 A[10] = 2.0*loc2 - loc3;
1228 h_obj[0][0][0] = -A[0] - loc4;
1229 h_obj[1][0][0] = A[0] - loc4;
1230 h_obj[2][0][0] = 2.0*loc2 - loc3;
1231 h_obj[3][0][0] = 3.0*loc3;
1236 h_obj[4][0][0] = A[1] - loc2 - loc3;
1237 h_obj[5][0][0] = 2.0*loc2 - loc3;
1238 h_obj[6][0][0] = 3.0*loc3;
1241 h_obj[7][0][0] =
tisqrt3*A[6] - loc3;
1242 h_obj[8][0][0] = 3.0*loc3;
1244 h_obj[9][0][0] =
tisqrt6*A[11];
1247 loc2 = matr[8]*loc1;
1251 loc2 = matr[7]*loc1;
1255 loc2 = matr[6]*loc1;
1263 A[0] = -J_B[0] - loc4;
1264 A[1] = J_B[0] - loc4;
1265 A[2] = 2.0*loc2 - loc3;
1272 A[4] = -J_B[1] - loc4;
1273 A[5] = J_B[1] - loc4;
1274 A[6] = 2.0*loc2 - loc3;
1281 A[8] = -J_B[2] - loc4;
1282 A[9] = J_B[2] - loc4;
1283 A[10] = 2.0*loc2 - loc3;
1290 h_obj[0][0][1] = -A[0] - loc4;
1291 h_obj[1][0][1] = A[0] - loc4;
1292 h_obj[2][0][1] = 2.0*loc2 - loc3;
1293 h_obj[3][0][1] = 3.0*loc3;
1299 h_obj[1][1][0] = -A[1] - loc4;
1300 h_obj[4][0][1] = A[1] - loc4;
1301 h_obj[5][0][1] = 2.0*loc2 - loc3;
1302 h_obj[6][0][1] = 3.0*loc3;
1308 h_obj[2][1][0] = -A[2] - loc4;
1309 h_obj[5][1][0] = A[2] - loc4;
1310 h_obj[7][0][1] = 2.0*loc2 - loc3;
1311 h_obj[8][0][1] = 3.0*loc3;
1317 h_obj[3][1][0] = -A[3] - loc4;
1318 h_obj[6][1][0] = A[3] - loc4;
1319 h_obj[8][1][0] = 2.0*loc2 - loc3;
1320 h_obj[9][0][1] = 3.0*loc3;
1323 loc2 = matr[5]*loc1;
1327 loc2 = matr[4]*loc1;
1331 loc2 = matr[3]*loc1;
1339 A[0] = -J_C[0] - loc4;
1340 A[1] = J_C[0] - loc4;
1341 A[2] = 2.0*loc2 - loc3;
1348 A[4] = -J_C[1] - loc4;
1349 A[5] = J_C[1] - loc4;
1350 A[6] = 2.0*loc2 - loc3;
1357 A[8] = -J_C[2] - loc4;
1358 A[9] = J_C[2] - loc4;
1359 A[10] = 2.0*loc2 - loc3;
1366 h_obj[0][0][2] = -A[0] - loc4;
1367 h_obj[1][0][2] = A[0] - loc4;
1368 h_obj[2][0][2] = 2.0*loc2 - loc3;
1369 h_obj[3][0][2] = 3.0*loc3;
1375 h_obj[1][2][0] = -A[1] - loc4;
1376 h_obj[4][0][2] = A[1] - loc4;
1377 h_obj[5][0][2] = 2.0*loc2 - loc3;
1378 h_obj[6][0][2] = 3.0*loc3;
1384 h_obj[2][2][0] = -A[2] - loc4;
1385 h_obj[5][2][0] = A[2] - loc4;
1386 h_obj[7][0][2] = 2.0*loc2 - loc3;
1387 h_obj[8][0][2] = 3.0*loc3;
1393 h_obj[3][2][0] = -A[3] - loc4;
1394 h_obj[6][2][0] = A[3] - loc4;
1395 h_obj[8][2][0] = 2.0*loc2 - loc3;
1396 h_obj[9][0][2] = 3.0*loc3;
1399 loc3 = matr[3]*f + dg[3]*
cross;
1400 loc4 = dg[3]*g + matr[3]*
cross;
1402 J_A[0] = loc0 + loc3*matr[3] + loc4*dg[3];
1403 J_A[1] = loc3*matr[4] + loc4*dg[4];
1404 J_A[2] = loc3*matr[5] + loc4*dg[5];
1405 J_B[0] = loc3*matr[6] + loc4*dg[6];
1406 J_B[1] = loc3*matr[7] + loc4*dg[7];
1407 J_B[2] = loc3*matr[8] + loc4*dg[8];
1409 loc3 = matr[4]*f + dg[4]*
cross;
1410 loc4 = dg[4]*g + matr[4]*
cross;
1412 J_A[3] = loc0 + loc3*matr[4] + loc4*dg[4];
1413 J_A[4] = loc3*matr[5] + loc4*dg[5];
1414 J_B[3] = loc3*matr[6] + loc4*dg[6];
1415 J_B[4] = loc3*matr[7] + loc4*dg[7];
1416 J_B[5] = loc3*matr[8] + loc4*dg[8];
1418 loc3 = matr[5]*f + dg[5]*
cross;
1419 loc4 = dg[5]*g + matr[5]*
cross;
1421 J_A[5] = loc0 + loc3*matr[5] + loc4*dg[5];
1422 J_B[6] = loc3*matr[6] + loc4*dg[6];
1423 J_B[7] = loc3*matr[7] + loc4*dg[7];
1424 J_B[8] = loc3*matr[8] + loc4*dg[8];
1431 A[0] = -J_A[0] - loc4;
1432 A[1] = J_A[0] - loc4;
1438 A[4] = -J_A[1] - loc4;
1439 A[5] = J_A[1] - loc4;
1440 A[6] = 2.0*loc2 - loc3;
1446 A[8] = -J_A[2] - loc4;
1447 A[9] = J_A[2] - loc4;
1448 A[10] = 2.0*loc2 - loc3;
1455 h_obj[0][1][1] = -A[0] - loc4;
1456 h_obj[1][1][1] = A[0] - loc4;
1457 h_obj[2][1][1] = 2.0*loc2 - loc3;
1458 h_obj[3][1][1] = 3.0*loc3;
1463 h_obj[4][1][1] = A[1] - loc2 - loc3;
1464 h_obj[5][1][1] = 2.0*loc2 - loc3;
1465 h_obj[6][1][1] = 3.0*loc3;
1468 h_obj[7][1][1] =
tisqrt3*A[6] - loc3;
1469 h_obj[8][1][1] = 3.0*loc3;
1471 h_obj[9][1][1] =
tisqrt6*A[11];
1474 loc2 = matr[2]*loc1;
1478 loc2 = matr[1]*loc1;
1482 loc2 = matr[0]*loc1;
1490 A[0] = -J_B[0] - loc4;
1491 A[1] = J_B[0] - loc4;
1492 A[2] = 2.0*loc2 - loc3;
1499 A[4] = -J_B[1] - loc4;
1500 A[5] = J_B[1] - loc4;
1501 A[6] = 2.0*loc2 - loc3;
1508 A[8] = -J_B[2] - loc4;
1509 A[9] = J_B[2] - loc4;
1510 A[10] = 2.0*loc2 - loc3;
1517 h_obj[0][1][2] = -A[0] - loc4;
1518 h_obj[1][1][2] = A[0] - loc4;
1519 h_obj[2][1][2] = 2.0*loc2 - loc3;
1520 h_obj[3][1][2] = 3.0*loc3;
1526 h_obj[1][2][1] = -A[1] - loc4;
1527 h_obj[4][1][2] = A[1] - loc4;
1528 h_obj[5][1][2] = 2.0*loc2 - loc3;
1529 h_obj[6][1][2] = 3.0*loc3;
1535 h_obj[2][2][1] = -A[2] - loc4;
1536 h_obj[5][2][1] = A[2] - loc4;
1537 h_obj[7][1][2] = 2.0*loc2 - loc3;
1538 h_obj[8][1][2] = 3.0*loc3;
1544 h_obj[3][2][1] = -A[3] - loc4;
1545 h_obj[6][2][1] = A[3] - loc4;
1546 h_obj[8][2][1] = 2.0*loc2 - loc3;
1547 h_obj[9][1][2] = 3.0*loc3;
1550 loc3 = matr[6]*f + dg[6]*
cross;
1551 loc4 = dg[6]*g + matr[6]*
cross;
1553 J_A[0] = loc0 + loc3*matr[6] + loc4*dg[6];
1554 J_A[1] = loc3*matr[7] + loc4*dg[7];
1555 J_A[2] = loc3*matr[8] + loc4*dg[8];
1557 loc3 = matr[7]*f + dg[7]*
cross;
1558 loc4 = dg[7]*g + matr[7]*
cross;
1560 J_A[3] = loc0 + loc3*matr[7] + loc4*dg[7];
1561 J_A[4] = loc3*matr[8] + loc4*dg[8];
1563 loc3 = matr[8]*f + dg[8]*
cross;
1564 loc4 = dg[8]*g + matr[8]*
cross;
1566 J_A[5] = loc0 + loc3*matr[8] + loc4*dg[8];
1573 A[0] = -J_A[0] - loc4;
1574 A[1] = J_A[0] - loc4;
1580 A[4] = -J_A[1] - loc4;
1581 A[5] = J_A[1] - loc4;
1582 A[6] = 2.0*loc2 - loc3;
1588 A[8] = -J_A[2] - loc4;
1589 A[9] = J_A[2] - loc4;
1590 A[10] = 2.0*loc2 - loc3;
1597 h_obj[0][2][2] = -A[0] - loc4;
1598 h_obj[1][2][2] = A[0] - loc4;
1599 h_obj[2][2][2] = 2.0*loc2 - loc3;
1600 h_obj[3][2][2] = 3.0*loc3;
1605 h_obj[4][2][2] = A[1] - loc2 - loc3;
1606 h_obj[5][2][2] = 2.0*loc2 - loc3;
1607 h_obj[6][2][2] = 3.0*loc3;
1610 h_obj[7][2][2] =
tisqrt3*A[6] - loc3;
1611 h_obj[8][2][2] = 3.0*loc3;
1613 h_obj[9][2][2] =
tisqrt6*A[11];
1616 h_obj[0].fill_lower_triangle();
1617 h_obj[4].fill_lower_triangle();
1618 h_obj[7].fill_lower_triangle();
1619 h_obj[9].fill_lower_triangle();
1630 const double a,
const Exponent& b,
const Exponent& c)
1632 double matr[9], f, g;
1633 double loc1, loc2, loc3;
1636 f = x[1][0] + x[0][0];
1637 matr[0] = x[1][0] - x[0][0];
1638 matr[1] = (2.0*x[2][0] - f)*
isqrt3;
1639 matr[2] = (3.0*x[3][0] - x[2][0] - f)*
isqrt6;
1641 f = x[1][1] + x[0][1];
1642 matr[3] = x[1][1] - x[0][1];
1643 matr[4] = (2.0*x[2][1] - f)*
isqrt3;
1644 matr[5] = (3.0*x[3][1] - x[2][1] - f)*
isqrt6;
1646 f = x[1][2] + x[0][2];
1647 matr[6] = x[1][2] - x[0][2];
1648 matr[7] = (2.0*x[2][2] - f)*
isqrt3;
1649 matr[8] = (3.0*x[3][2] - x[2][2] - f)*
isqrt6;
1652 loc1 = matr[4]*matr[8] - matr[5]*matr[7];
1653 loc2 = matr[5]*matr[6] - matr[3]*matr[8];
1654 loc3 = matr[3]*matr[7] - matr[4]*matr[6];
1655 g = matr[0]*loc1 + matr[1]*loc2 + matr[2]*loc3;
1656 if (g <
MSQ_MIN) { obj = g;
return false; }
1659 f = matr[0]*matr[0] + matr[1]*matr[1] + matr[2]*matr[2] +
1660 matr[3]*matr[3] + matr[4]*matr[4] + matr[5]*matr[5] +
1661 matr[6]*matr[6] + matr[7]*matr[7] + matr[8]*matr[8];
1664 obj = a *
pow(f, b) *
pow(g, c);
1671 g_obj[0] =
tisqrt6*(matr[2]*f + loc3*g);
1676 g_obj[1] =
tisqrt6*(matr[5]*f + loc2*matr[6] - loc1*matr[7]);
1677 g_obj[2] =
tisqrt6*(matr[8]*f + loc1*matr[4] - loc2*matr[3]);
1682 const double a,
const Exponent& b,
const Exponent& c)
1694 const double a,
const Exponent& b,
const Exponent& c)
1706 const double a,
const Exponent& b,
const Exponent& c)
1719 const double a,
const Exponent& b,
const Exponent& c)
1721 double matr[9], f, g;
1722 double dg[9], loc0, loc1, loc3, loc4;
1726 f = x[1][0] + x[0][0];
1727 matr[0] = x[1][0] - x[0][0];
1728 matr[1] = (2.0*x[2][0] - f)*
isqrt3;
1729 matr[2] = (3.0*x[3][0] - x[2][0] - f)*
isqrt6;
1731 f = x[1][1] + x[0][1];
1732 matr[3] = x[1][1] - x[0][1];
1733 matr[4] = (2.0*x[2][1] - f)*
isqrt3;
1734 matr[5] = (3.0*x[3][1] - x[2][1] - f)*
isqrt6;
1736 f = x[1][2] + x[0][2];
1737 matr[6] = x[1][2] - x[0][2];
1738 matr[7] = (2.0*x[2][2] - f)*
isqrt3;
1739 matr[8] = (3.0*x[3][2] - x[2][2] - f)*
isqrt6;
1742 dg[0] = matr[4]*matr[8] - matr[5]*matr[7];
1743 dg[1] = matr[5]*matr[6] - matr[3]*matr[8];
1744 dg[2] = matr[3]*matr[7] - matr[4]*matr[6];
1745 g = matr[0]*dg[0] + matr[1]*dg[1] + matr[2]*dg[2];
1746 if (g <
MSQ_MIN) { obj = g;
return false; }
1749 f = matr[0]*matr[0] + matr[1]*matr[1] + matr[2]*matr[2] +
1750 matr[3]*matr[3] + matr[4]*matr[4] + matr[5]*matr[5] +
1751 matr[6]*matr[6] + matr[7]*matr[7] + matr[8]*matr[8];
1757 obj = a *
pow(f, b) *
pow(g, c);
1764 dg[5] = matr[1]*matr[6] - matr[0]*matr[7];
1765 dg[8] = matr[0]*matr[4] - matr[1]*matr[3];
1767 g_obj[0] =
tisqrt6*(matr[2]*f + dg[2]*g);
1768 g_obj[1] =
tisqrt6*(matr[5]*f + dg[5]*g);
1769 g_obj[2] =
tisqrt6*(matr[8]*f + dg[8]*g);
1774 cross = f * c / loc4;
1775 f = f * (b-1) / loc3;
1776 g = g * (c-1) / loc4;
1780 loc3 = matr[2]*f + dg[2]*
cross;
1781 loc4 = dg[2]*g + matr[2]*
cross;
1783 h_obj[0][0] = 1.5*(loc0 + loc3*matr[2] + loc4*dg[2]);
1784 h_obj[0][1] = 1.5*(loc3*matr[5] + loc4*dg[5]);
1785 h_obj[0][2] = 1.5*(loc3*matr[8] + loc4*dg[8]);
1788 loc3 = matr[5]*f + dg[5]*
cross;
1789 loc4 = dg[5]*g + matr[5]*
cross;
1791 h_obj[1][1] = 1.5*(loc0 + loc3*matr[5] + loc4*dg[5]);
1792 h_obj[1][2] = 1.5*(loc3*matr[8] + loc4*dg[8]);
1795 loc3 = matr[8]*f + dg[8]*
cross;
1796 loc4 = dg[8]*g + matr[8]*
cross;
1798 h_obj[2][2] = 1.5*(loc0 + loc3*matr[8] + loc4*dg[8]);
1801 h_obj.fill_lower_triangle();
1807 const double a,
const Exponent& b,
const Exponent& c)
1815 return h_fcn_3e_v3(obj, g_obj, h_obj, my_x, a, b, c);
1820 const double a,
const Exponent& b,
const Exponent& c)
1828 return h_fcn_3e_v3(obj, g_obj, h_obj, my_x, a, b, c);
1833 const double a,
const Exponent& b,
const Exponent& c)
1841 return h_fcn_3e_v3(obj, g_obj, h_obj, my_x, a, b, c);
1856 const double a,
const Exponent& b,
const Exponent& c,
1863 matr[0] = d[0]*(x[1][0] - x[0][0]);
1864 matr[1] = d[1]*(x[2][0] - x[0][0]);
1865 matr[2] = d[2]*(x[3][0] - x[0][0]);
1867 matr[3] = d[0]*(x[1][1] - x[0][1]);
1868 matr[4] = d[1]*(x[2][1] - x[0][1]);
1869 matr[5] = d[2]*(x[3][1] - x[0][1]);
1871 matr[6] = d[0]*(x[1][2] - x[0][2]);
1872 matr[7] = d[1]*(x[2][2] - x[0][2]);
1873 matr[8] = d[2]*(x[3][2] - x[0][2]);
1876 g = matr[0]*(matr[4]*matr[8] - matr[5]*matr[7]) +
1877 matr[1]*(matr[5]*matr[6] - matr[3]*matr[8]) +
1878 matr[2]*(matr[3]*matr[7] - matr[4]*matr[6]);
1879 if (g <
MSQ_MIN) { obj = g;
return false; }
1882 f = matr[0]*matr[0] + matr[1]*matr[1] + matr[2]*matr[2] +
1883 matr[3]*matr[3] + matr[4]*matr[4] + matr[5]*matr[5] +
1884 matr[6]*matr[6] + matr[7]*matr[7] + matr[8]*matr[8];
1887 obj = a *
pow(f, b) *
pow(g, c);
1896 const double a,
const Exponent& b,
const Exponent& c,
1901 double loc1, loc2, loc3;
1904 matr[0] = d[0]*(x[1][0] - x[0][0]);
1905 matr[1] = d[1]*(x[2][0] - x[0][0]);
1906 matr[2] = d[2]*(x[3][0] - x[0][0]);
1908 matr[3] = d[0]*(x[1][1] - x[0][1]);
1909 matr[4] = d[1]*(x[2][1] - x[0][1]);
1910 matr[5] = d[2]*(x[3][1] - x[0][1]);
1912 matr[6] = d[0]*(x[1][2] - x[0][2]);
1913 matr[7] = d[1]*(x[2][2] - x[0][2]);
1914 matr[8] = d[2]*(x[3][2] - x[0][2]);
1917 loc1 = matr[4]*matr[8] - matr[5]*matr[7];
1918 loc2 = matr[5]*matr[6] - matr[3]*matr[8];
1919 loc3 = matr[3]*matr[7] - matr[4]*matr[6];
1920 g = matr[0]*loc1 + matr[1]*loc2 + matr[2]*loc3;
1921 if (g <
MSQ_MIN) { obj = g;
return false; }
1924 f = matr[0]*matr[0] + matr[1]*matr[1] + matr[2]*matr[2] +
1925 matr[3]*matr[3] + matr[4]*matr[4] + matr[5]*matr[5] +
1926 matr[6]*matr[6] + matr[7]*matr[7] + matr[8]*matr[8];
1929 obj = a *
pow(f, b) *
pow(g, c);
1936 adj_m[0] = d[0]*(matr[0]*f + loc1*g);
1937 adj_m[1] = d[1]*(matr[1]*f + loc2*g);
1938 adj_m[2] = d[2]*(matr[2]*f + loc3*g);
1944 adj_m[3] = d[0]*(matr[3]*f + loc3*matr[7] - loc2*matr[8]);
1945 adj_m[4] = d[1]*(matr[4]*f + loc1*matr[8] - loc3*matr[6]);
1946 adj_m[5] = d[2]*(matr[5]*f + loc2*matr[6] - loc1*matr[7]);
1948 adj_m[6] = d[0]*(matr[6]*f + loc2*matr[5] - loc3*matr[4]);
1949 adj_m[7] = d[1]*(matr[7]*f + loc3*matr[3] - loc1*matr[5]);
1950 adj_m[8] = d[2]*(matr[8]*f + loc1*matr[4] - loc2*matr[3]);
1952 g_obj[0][0] = -adj_m[0] - adj_m[1] - adj_m[2];
1953 g_obj[1][0] = adj_m[0];
1954 g_obj[2][0] = adj_m[1];
1955 g_obj[3][0] = adj_m[2];
1957 g_obj[0][1] = -adj_m[3] - adj_m[4] - adj_m[5];
1958 g_obj[1][1] = adj_m[3];
1959 g_obj[2][1] = adj_m[4];
1960 g_obj[3][1] = adj_m[5];
1962 g_obj[0][2] = -adj_m[6] - adj_m[7] - adj_m[8];
1963 g_obj[1][2] = adj_m[6];
1964 g_obj[2][2] = adj_m[7];
1965 g_obj[3][2] = adj_m[8];
1975 const double a,
const Exponent& b,
const Exponent& c,
1980 double dg[9], loc0, loc1, loc2, loc3, loc4;
1981 double A[3], J_A[6], J_B[9], J_C[9],
cross;
1983 const double scale[6] = {
1984 d[0]*d[0], d[0]*d[1], d[0]*d[2],
1985 d[1]*d[1], d[1]*d[2],
1990 matr[0] = d[0]*(x[1][0] - x[0][0]);
1991 matr[1] = d[1]*(x[2][0] - x[0][0]);
1992 matr[2] = d[2]*(x[3][0] - x[0][0]);
1994 matr[3] = d[0]*(x[1][1] - x[0][1]);
1995 matr[4] = d[1]*(x[2][1] - x[0][1]);
1996 matr[5] = d[2]*(x[3][1] - x[0][1]);
1998 matr[6] = d[0]*(x[1][2] - x[0][2]);
1999 matr[7] = d[1]*(x[2][2] - x[0][2]);
2000 matr[8] = d[2]*(x[3][2] - x[0][2]);
2003 dg[0] = matr[4]*matr[8] - matr[5]*matr[7];
2004 dg[1] = matr[5]*matr[6] - matr[3]*matr[8];
2005 dg[2] = matr[3]*matr[7] - matr[4]*matr[6];
2006 g = matr[0]*dg[0] + matr[1]*dg[1] + matr[2]*dg[2];
2007 if (g <
MSQ_MIN) { obj = g;
return false; }
2010 f = matr[0]*matr[0] + matr[1]*matr[1] + matr[2]*matr[2] +
2011 matr[3]*matr[3] + matr[4]*matr[4] + matr[5]*matr[5] +
2012 matr[6]*matr[6] + matr[7]*matr[7] + matr[8]*matr[8];
2018 obj = a *
pow(f, b) *
pow(g, c);
2025 dg[3] = matr[2]*matr[7] - matr[1]*matr[8];
2026 dg[4] = matr[0]*matr[8] - matr[2]*matr[6];
2027 dg[5] = matr[1]*matr[6] - matr[0]*matr[7];
2028 dg[6] = matr[1]*matr[5] - matr[2]*matr[4];
2029 dg[7] = matr[2]*matr[3] - matr[0]*matr[5];
2030 dg[8] = matr[0]*matr[4] - matr[1]*matr[3];
2032 adj_m[0] = d[0]*(matr[0]*f + dg[0]*g);
2033 adj_m[1] = d[1]*(matr[1]*f + dg[1]*g);
2034 adj_m[2] = d[2]*(matr[2]*f + dg[2]*g);
2035 adj_m[3] = d[0]*(matr[3]*f + dg[3]*g);
2036 adj_m[4] = d[1]*(matr[4]*f + dg[4]*g);
2037 adj_m[5] = d[2]*(matr[5]*f + dg[5]*g);
2038 adj_m[6] = d[0]*(matr[6]*f + dg[6]*g);
2039 adj_m[7] = d[1]*(matr[7]*f + dg[7]*g);
2040 adj_m[8] = d[2]*(matr[8]*f + dg[8]*g);
2042 g_obj[0][0] = -adj_m[0] - adj_m[1] - adj_m[2];
2043 g_obj[1][0] = adj_m[0];
2044 g_obj[2][0] = adj_m[1];
2045 g_obj[3][0] = adj_m[2];
2047 g_obj[0][1] = -adj_m[3] - adj_m[4] - adj_m[5];
2048 g_obj[1][1] = adj_m[3];
2049 g_obj[2][1] = adj_m[4];
2050 g_obj[3][1] = adj_m[5];
2052 g_obj[0][2] = -adj_m[6] - adj_m[7] - adj_m[8];
2053 g_obj[1][2] = adj_m[6];
2054 g_obj[2][2] = adj_m[7];
2055 g_obj[3][2] = adj_m[8];
2060 cross = f * c / loc4;
2061 f = f * (b-1) / loc3;
2062 g = g * (c-1) / loc4;
2066 loc3 = matr[0]*f + dg[0]*
cross;
2067 loc4 = dg[0]*g + matr[0]*
cross;
2069 J_A[0] = loc0 + loc3*matr[0] + loc4*dg[0];
2070 J_A[1] = loc3*matr[1] + loc4*dg[1];
2071 J_A[2] = loc3*matr[2] + loc4*dg[2];
2072 J_B[0] = loc3*matr[3] + loc4*dg[3];
2073 J_B[1] = loc3*matr[4] + loc4*dg[4];
2074 J_B[2] = loc3*matr[5] + loc4*dg[5];
2075 J_C[0] = loc3*matr[6] + loc4*dg[6];
2076 J_C[1] = loc3*matr[7] + loc4*dg[7];
2077 J_C[2] = loc3*matr[8] + loc4*dg[8];
2079 loc3 = matr[1]*f + dg[1]*
cross;
2080 loc4 = dg[1]*g + matr[1]*
cross;
2082 J_A[3] = loc0 + loc3*matr[1] + loc4*dg[1];
2083 J_A[4] = loc3*matr[2] + loc4*dg[2];
2084 J_B[3] = loc3*matr[3] + loc4*dg[3];
2085 J_B[4] = loc3*matr[4] + loc4*dg[4];
2086 J_B[5] = loc3*matr[5] + loc4*dg[5];
2087 J_C[3] = loc3*matr[6] + loc4*dg[6];
2088 J_C[4] = loc3*matr[7] + loc4*dg[7];
2089 J_C[5] = loc3*matr[8] + loc4*dg[8];
2091 loc3 = matr[2]*f + dg[2]*
cross;
2092 loc4 = dg[2]*g + matr[2]*
cross;
2094 J_A[5] = loc0 + loc3*matr[2] + loc4*dg[2];
2095 J_B[6] = loc3*matr[3] + loc4*dg[3];
2096 J_B[7] = loc3*matr[4] + loc4*dg[4];
2097 J_B[8] = loc3*matr[5] + loc4*dg[5];
2098 J_C[6] = loc3*matr[6] + loc4*dg[6];
2099 J_C[7] = loc3*matr[7] + loc4*dg[7];
2100 J_C[8] = loc3*matr[8] + loc4*dg[8];
2110 A[0] = -J_A[0] - J_A[1] - J_A[2];
2111 A[1] = -J_A[1] - J_A[3] - J_A[4];
2112 A[2] = -J_A[2] - J_A[4] - J_A[5];
2114 h_obj[0][0][0] = -A[0] - A[1] - A[2];
2115 h_obj[1][0][0] = A[0];
2116 h_obj[2][0][0] = A[1];
2117 h_obj[3][0][0] = A[2];
2119 h_obj[4][0][0] = J_A[0];
2120 h_obj[5][0][0] = J_A[1];
2121 h_obj[6][0][0] = J_A[2];
2123 h_obj[7][0][0] = J_A[3];
2124 h_obj[8][0][0] = J_A[4];
2126 h_obj[9][0][0] = J_A[5];
2129 loc2 = matr[8]*loc1;
2133 loc2 = matr[7]*loc1;
2137 loc2 = matr[6]*loc1;
2151 A[0] = -J_B[0] - J_B[3] - J_B[6];
2152 A[1] = -J_B[1] - J_B[4] - J_B[7];
2153 A[2] = -J_B[2] - J_B[5] - J_B[8];
2155 h_obj[0][0][1] = -A[0] - A[1] - A[2];
2156 h_obj[1][0][1] = A[0];
2157 h_obj[2][0][1] = A[1];
2158 h_obj[3][0][1] = A[2];
2160 h_obj[1][1][0] = -J_B[0] - J_B[1] - J_B[2];
2161 h_obj[4][0][1] = J_B[0];
2162 h_obj[5][0][1] = J_B[1];
2163 h_obj[6][0][1] = J_B[2];
2165 h_obj[2][1][0] = -J_B[3] - J_B[4] - J_B[5];
2166 h_obj[5][1][0] = J_B[3];
2167 h_obj[7][0][1] = J_B[4];
2168 h_obj[8][0][1] = J_B[5];
2170 h_obj[3][1][0] = -J_B[6] - J_B[7] - J_B[8];
2171 h_obj[6][1][0] = J_B[6];
2172 h_obj[8][1][0] = J_B[7];
2173 h_obj[9][0][1] = J_B[8];
2176 loc2 = matr[5]*loc1;
2180 loc2 = matr[4]*loc1;
2184 loc2 = matr[3]*loc1;
2198 A[0] = -J_C[0] - J_C[3] - J_C[6];
2199 A[1] = -J_C[1] - J_C[4] - J_C[7];
2200 A[2] = -J_C[2] - J_C[5] - J_C[8];
2202 h_obj[0][0][2] = -A[0] - A[1] - A[2];
2203 h_obj[1][0][2] = A[0];
2204 h_obj[2][0][2] = A[1];
2205 h_obj[3][0][2] = A[2];
2207 h_obj[1][2][0] = -J_C[0] - J_C[1] - J_C[2];
2208 h_obj[4][0][2] = J_C[0];
2209 h_obj[5][0][2] = J_C[1];
2210 h_obj[6][0][2] = J_C[2];
2212 h_obj[2][2][0] = -J_C[3] - J_C[4] - J_C[5];
2213 h_obj[5][2][0] = J_C[3];
2214 h_obj[7][0][2] = J_C[4];
2215 h_obj[8][0][2] = J_C[5];
2217 h_obj[3][2][0] = -J_C[6] - J_C[7] - J_C[8];
2218 h_obj[6][2][0] = J_C[6];
2219 h_obj[8][2][0] = J_C[7];
2220 h_obj[9][0][2] = J_C[8];
2223 loc3 = matr[3]*f + dg[3]*
cross;
2224 loc4 = dg[3]*g + matr[3]*
cross;
2226 J_A[0] = loc0 + loc3*matr[3] + loc4*dg[3];
2227 J_A[1] = loc3*matr[4] + loc4*dg[4];
2228 J_A[2] = loc3*matr[5] + loc4*dg[5];
2229 J_B[0] = loc3*matr[6] + loc4*dg[6];
2230 J_B[1] = loc3*matr[7] + loc4*dg[7];
2231 J_B[2] = loc3*matr[8] + loc4*dg[8];
2233 loc3 = matr[4]*f + dg[4]*
cross;
2234 loc4 = dg[4]*g + matr[4]*
cross;
2236 J_A[3] = loc0 + loc3*matr[4] + loc4*dg[4];
2237 J_A[4] = loc3*matr[5] + loc4*dg[5];
2238 J_B[3] = loc3*matr[6] + loc4*dg[6];
2239 J_B[4] = loc3*matr[7] + loc4*dg[7];
2240 J_B[5] = loc3*matr[8] + loc4*dg[8];
2242 loc3 = matr[5]*f + dg[5]*
cross;
2243 loc4 = dg[5]*g + matr[5]*
cross;
2245 J_A[5] = loc0 + loc3*matr[5] + loc4*dg[5];
2246 J_B[6] = loc3*matr[6] + loc4*dg[6];
2247 J_B[7] = loc3*matr[7] + loc4*dg[7];
2248 J_B[8] = loc3*matr[8] + loc4*dg[8];
2258 A[0] = -J_A[0] - J_A[1] - J_A[2];
2259 A[1] = -J_A[1] - J_A[3] - J_A[4];
2260 A[2] = -J_A[2] - J_A[4] - J_A[5];
2262 h_obj[0][1][1] = -A[0] - A[1] - A[2];
2263 h_obj[1][1][1] = A[0];
2264 h_obj[2][1][1] = A[1];
2265 h_obj[3][1][1] = A[2];
2267 h_obj[4][1][1] = J_A[0];
2268 h_obj[5][1][1] = J_A[1];
2269 h_obj[6][1][1] = J_A[2];
2271 h_obj[7][1][1] = J_A[3];
2272 h_obj[8][1][1] = J_A[4];
2274 h_obj[9][1][1] = J_A[5];
2277 loc2 = matr[2]*loc1;
2281 loc2 = matr[1]*loc1;
2285 loc2 = matr[0]*loc1;
2299 A[0] = -J_B[0] - J_B[3] - J_B[6];
2300 A[1] = -J_B[1] - J_B[4] - J_B[7];
2301 A[2] = -J_B[2] - J_B[5] - J_B[8];
2303 h_obj[0][1][2] = -A[0] - A[1] - A[2];
2304 h_obj[1][1][2] = A[0];
2305 h_obj[2][1][2] = A[1];
2306 h_obj[3][1][2] = A[2];
2308 h_obj[1][2][1] = -J_B[0] - J_B[1] - J_B[2];
2309 h_obj[4][1][2] = J_B[0];
2310 h_obj[5][1][2] = J_B[1];
2311 h_obj[6][1][2] = J_B[2];
2313 h_obj[2][2][1] = -J_B[3] - J_B[4] - J_B[5];
2314 h_obj[5][2][1] = J_B[3];
2315 h_obj[7][1][2] = J_B[4];
2316 h_obj[8][1][2] = J_B[5];
2318 h_obj[3][2][1] = -J_B[6] - J_B[7] - J_B[8];
2319 h_obj[6][2][1] = J_B[6];
2320 h_obj[8][2][1] = J_B[7];
2321 h_obj[9][1][2] = J_B[8];
2324 loc3 = matr[6]*f + dg[6]*
cross;
2325 loc4 = dg[6]*g + matr[6]*
cross;
2327 J_A[0] = loc0 + loc3*matr[6] + loc4*dg[6];
2328 J_A[1] = loc3*matr[7] + loc4*dg[7];
2329 J_A[2] = loc3*matr[8] + loc4*dg[8];
2331 loc3 = matr[7]*f + dg[7]*
cross;
2332 loc4 = dg[7]*g + matr[7]*
cross;
2334 J_A[3] = loc0 + loc3*matr[7] + loc4*dg[7];
2335 J_A[4] = loc3*matr[8] + loc4*dg[8];
2337 loc3 = matr[8]*f + dg[8]*
cross;
2338 loc4 = dg[8]*g + matr[8]*
cross;
2340 J_A[5] = loc0 + loc3*matr[8] + loc4*dg[8];
2350 A[0] = -J_A[0] - J_A[1] - J_A[2];
2351 A[1] = -J_A[1] - J_A[3] - J_A[4];
2352 A[2] = -J_A[2] - J_A[4] - J_A[5];
2354 h_obj[0][2][2] = -A[0] - A[1] - A[2];
2355 h_obj[1][2][2] = A[0];
2356 h_obj[2][2][2] = A[1];
2357 h_obj[3][2][2] = A[2];
2359 h_obj[4][2][2] = J_A[0];
2360 h_obj[5][2][2] = J_A[1];
2361 h_obj[6][2][2] = J_A[2];
2363 h_obj[7][2][2] = J_A[3];
2364 h_obj[8][2][2] = J_A[4];
2366 h_obj[9][2][2] = J_A[5];
2369 h_obj[0].fill_lower_triangle();
2370 h_obj[4].fill_lower_triangle();
2371 h_obj[7].fill_lower_triangle();
2372 h_obj[9].fill_lower_triangle();
int h_fcn_3i(double &obj, Vector3D g_obj[4], Matrix3D h_obj[10], const Vector3D x[4], const double a, const Exponent &b, const Exponent &c, const Vector3D &d)
bool g_fcn_2i(double &obj, Vector3D g_obj[3], const Vector3D x[3], const Vector3D &n, const double a, const Exponent &b, const Exponent &c, const Vector3D &d)
bool m_fcn_3e(double &obj, const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
bool g_fcn_2e(double &obj, Vector3D g_obj[3], const Vector3D x[3], const Vector3D &n, const double a, const Exponent &b, const Exponent &c)
NVec< 3, T > cross(const NVec< 3, T > &u, const NVec< 3, T > &v)
bool g_fcn_3e(double &obj, Vector3D g_obj[4], const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
bool m_fcn_3i(double &obj, const Vector3D x[4], const double a, const Exponent &b, const Exponent &c, const Vector3D &d)
bool h_fcn_3e_v2(double &obj, Vector3D &g_obj, Matrix3D &h_obj, const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
bool m_fcn_2i(double &obj, const Vector3D x[3], const Vector3D &n, const double a, const Exponent &b, const Exponent &c, const Vector3D &d)
bool g_fcn_3i(double &obj, Vector3D g_obj[4], const Vector3D x[4], const double a, const Exponent &b, const Exponent &c, const Vector3D &d)
bool h_fcn_3e_v3(double &obj, Vector3D &g_obj, Matrix3D &h_obj, const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
bool g_fcn_3e_v0(double &obj, Vector3D &g_obj, const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
NVec< 3, double > Vector3D
bool h_fcn_3e(double &obj, Vector3D g_obj[4], Matrix3D h_obj[10], const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
bool m_fcn_2e(double &obj, const Vector3D x[3], const Vector3D &n, const double a, const Exponent &b, const Exponent &c)
bool g_fcn_3e_v1(double &obj, Vector3D &g_obj, const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
bool h_fcn_3e_v0(double &obj, Vector3D &g_obj, Matrix3D &h_obj, const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
bool h_fcn_2e(double &obj, Vector3D g_obj[3], Matrix3D h_obj[6], const Vector3D x[3], const Vector3D &n, const double a, const Exponent &b, const Exponent &c)
bool h_fcn_3e_v1(double &obj, Vector3D &g_obj, Matrix3D &h_obj, const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
bool h_fcn_2i(double &obj, Vector3D g_obj[3], Matrix3D h_obj[6], const Vector3D x[3], const Vector3D &n, const double a, const Exponent &b, const Exponent &c, const Vector3D &d)
double pow(double value, const Exponent &exp)
bool g_fcn_3e_v3(double &obj, Vector3D &g_obj, const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)
bool g_fcn_3e_v2(double &obj, Vector3D &g_obj, const Vector3D x[4], const double a, const Exponent &b, const Exponent &c)