27 double helper_1 = helper_0[2];
28 double helper_2 = helper_0[11];
29 double helper_3 = helper_0[0];
30 double helper_4 = helper_0[3];
31 double helper_5 = helper_0[9];
33 0.577350269189626 * helper_3 - 1.15470053837925 * helper_4 + 0.577350269189626 * helper_5;
34 double helper_7 = helper_0[1];
35 double helper_8 = helper_0[4];
36 double helper_9 = helper_0[7];
37 double helper_10 = helper_0[10];
38 double helper_11 = 0.408248290463863 * helper_10 + 0.408248290463863 * helper_7 +
39 0.408248290463863 * helper_8 - 1.22474487139159 * helper_9;
41 0.577350269189626 * helper_10 + 0.577350269189626 * helper_7 - 1.15470053837925 * helper_8;
42 double helper_13 = helper_0[6];
43 double helper_14 = -1.22474487139159 * helper_13 + 0.408248290463863 * helper_3 +
44 0.408248290463863 * helper_4 + 0.408248290463863 * helper_5;
45 double helper_15 = helper_0[5];
46 double helper_16 = helper_0[8];
47 double helper_17 = 0.408248290463863 * helper_1 + 0.408248290463863 * helper_15 -
48 1.22474487139159 * helper_16 + 0.408248290463863 * helper_2;
50 0.577350269189626 * helper_1 - 1.15470053837925 * helper_15 + 0.577350269189626 * helper_2;
51 double helper_19 = 0.5 * helper_13 + 0.5 * helper_4;
52 double helper_20 = 0.5 * helper_8 + 0.5 * helper_9;
53 double helper_21 = 0.5 * helper_15 + 0.5 * helper_16;
54 double helper_22 = (helper_1 - helper_2) * (helper_11 * helper_6 - helper_12 * helper_14) -
55 (-helper_10 + helper_7) * (-helper_14 * helper_18 + helper_17 * helper_6) +
56 (helper_3 - helper_5) * (-helper_11 * helper_18 + helper_12 * helper_17);
58 -(helper_1 * (-1.5 * helper_1 + 0.5 * helper_2 + helper_21) +
59 helper_10 * (-1.5 * helper_10 + helper_20 + 0.5 * helper_7) +
60 helper_13 * (-1.5 * helper_13 + 0.5 * helper_3 + 0.5 * helper_4 + 0.5 * helper_5) +
61 helper_15 * (0.5 * helper_1 - 1.5 * helper_15 + 0.5 * helper_16 + 0.5 * helper_2) +
62 helper_16 * (0.5 * helper_1 + 0.5 * helper_15 - 1.5 * helper_16 + 0.5 * helper_2) +
63 helper_2 * (0.5 * helper_1 - 1.5 * helper_2 + helper_21) +
64 helper_3 * (helper_19 - 1.5 * helper_3 + 0.5 * helper_5) +
65 helper_4 * (0.5 * helper_13 + 0.5 * helper_3 - 1.5 * helper_4 + 0.5 * helper_5) +
66 helper_5 * (helper_19 + 0.5 * helper_3 - 1.5 * helper_5) +
67 helper_7 * (0.5 * helper_10 + helper_20 - 1.5 * helper_7) +
68 helper_8 * (0.5 * helper_10 + 0.5 * helper_7 - 1.5 * helper_8 + 0.5 * helper_9) +
69 helper_9 * (0.5 * helper_10 + 0.5 * helper_7 + 0.5 * helper_8 - 1.5 * helper_9)) /
70 std::cbrt(helper_22 * helper_22);
90 double helper_1 = helper_0[1];
91 double helper_2 = helper_0[10];
92 double helper_3 = helper_1 - helper_2;
93 double helper_4 = helper_0[0];
94 double helper_5 = helper_0[3];
95 double helper_6 = helper_0[9];
97 0.577350269189626 * helper_4 - 1.15470053837925 * helper_5 + 0.577350269189626 * helper_6;
98 double helper_8 = helper_0[2];
99 double helper_9 = 0.408248290463863 * helper_8;
100 double helper_10 = helper_0[5];
101 double helper_11 = 0.408248290463863 * helper_10;
102 double helper_12 = helper_0[8];
103 double helper_13 = 1.22474487139159 * helper_12;
104 double helper_14 = helper_0[11];
105 double helper_15 = 0.408248290463863 * helper_14;
106 double helper_16 = helper_11 - helper_13 + helper_15 + helper_9;
107 double helper_17 = 0.577350269189626 * helper_8;
108 double helper_18 = 1.15470053837925 * helper_10;
109 double helper_19 = 0.577350269189626 * helper_14;
110 double helper_20 = helper_17 - helper_18 + helper_19;
111 double helper_21 = helper_0[6];
112 double helper_22 = -1.22474487139159 * helper_21 + 0.408248290463863 * helper_4 +
113 0.408248290463863 * helper_5 + 0.408248290463863 * helper_6;
114 double helper_23 = helper_16 * helper_7 - helper_20 * helper_22;
115 double helper_24 = -helper_14 + helper_8;
116 double helper_25 = 0.408248290463863 * helper_1;
117 double helper_26 = helper_0[4];
118 double helper_27 = 0.408248290463863 * helper_26;
119 double helper_28 = helper_0[7];
120 double helper_29 = 1.22474487139159 * helper_28;
121 double helper_30 = 0.408248290463863 * helper_2;
122 double helper_31 = helper_25 + helper_27 - helper_29 + helper_30;
123 double helper_32 = helper_31 * helper_7;
124 double helper_33 = 0.577350269189626 * helper_1;
125 double helper_34 = 1.15470053837925 * helper_26;
126 double helper_35 = 0.577350269189626 * helper_2;
127 double helper_36 = helper_33 - helper_34 + helper_35;
128 double helper_37 = helper_22 * helper_36;
129 double helper_38 = helper_4 - helper_6;
130 double helper_39 = helper_23 * helper_3 - helper_24 * (helper_32 - helper_37) -
131 helper_38 * (helper_16 * helper_36 - helper_20 * helper_31);
132 double helper_40 =
pow(
pow(helper_39, 2), -0.333333333333333);
133 double helper_41 = 0.707106781186548 * helper_10 - 0.707106781186548 * helper_12;
134 double helper_42 = 0.707106781186548 * helper_26 - 0.707106781186548 * helper_28;
135 double helper_43 = 0.5 * helper_21 + 0.5 * helper_5;
136 double helper_44 = 0.5 * helper_26 + 0.5 * helper_28;
137 double helper_45 = 0.5 * helper_10 + 0.5 * helper_12;
140 (helper_1 * (-1.5 * helper_1 + 0.5 * helper_2 + helper_44) +
141 helper_10 * (-1.5 * helper_10 + 0.5 * helper_12 + 0.5 * helper_14 + 0.5 * helper_8) +
142 helper_12 * (0.5 * helper_10 - 1.5 * helper_12 + 0.5 * helper_14 + 0.5 * helper_8) +
143 helper_14 * (-1.5 * helper_14 + helper_45 + 0.5 * helper_8) +
144 helper_2 * (0.5 * helper_1 - 1.5 * helper_2 + helper_44) +
145 helper_21 * (-1.5 * helper_21 + 0.5 * helper_4 + 0.5 * helper_5 + 0.5 * helper_6) +
146 helper_26 * (0.5 * helper_1 + 0.5 * helper_2 - 1.5 * helper_26 + 0.5 * helper_28) +
147 helper_28 * (0.5 * helper_1 + 0.5 * helper_2 + 0.5 * helper_26 - 1.5 * helper_28) +
148 helper_4 * (-1.5 * helper_4 + helper_43 + 0.5 * helper_6) +
149 helper_5 * (0.5 * helper_21 + 0.5 * helper_4 - 1.5 * helper_5 + 0.5 * helper_6) +
150 helper_6 * (0.5 * helper_4 + helper_43 - 1.5 * helper_6) +
151 helper_8 * (0.5 * helper_14 + helper_45 - 1.5 * helper_8)) /
153 double helper_47 = -0.707106781186548 * helper_21 + 0.707106781186548 * helper_5;
154 result_0[0] = -helper_40 * (1.0 * helper_21 - 3.0 * helper_4 +
155 helper_46 * (helper_41 * (-helper_1 + helper_2) -
156 helper_42 * (helper_14 - helper_8) -
157 (-helper_17 + helper_18 - helper_19) *
158 (-helper_25 - helper_27 + helper_29 - helper_30) +
159 (-helper_33 + helper_34 - helper_35) *
160 (-helper_11 + helper_13 - helper_15 - helper_9)) +
161 1.0 * helper_5 + 1.0 * helper_6);
163 helper_40 * (3.0 * helper_1 - 1.0 * helper_2 - 1.0 * helper_26 - 1.0 * helper_28 +
164 helper_46 * (helper_23 + helper_24 * helper_47 - helper_38 * helper_41));
167 (-1.0 * helper_10 - 1.0 * helper_12 - 1.0 * helper_14 +
168 helper_46 * (-helper_3 * helper_47 - helper_32 + helper_37 + helper_38 * helper_42) +
185 helper_0[10] = T[10];
186 helper_0[11] = T[11];
187 double helper_1 = helper_0[2];
188 double helper_2 = helper_0[11];
189 double helper_3 = helper_1 - helper_2;
190 double helper_4 = helper_0[0];
191 double helper_5 = 0.577350269189626 * helper_4;
192 double helper_6 = helper_0[3];
193 double helper_7 = 1.15470053837925 * helper_6;
194 double helper_8 = helper_0[9];
195 double helper_9 = 0.577350269189626 * helper_8;
196 double helper_10 = helper_5 - helper_7 + helper_9;
197 double helper_11 = helper_0[1];
198 double helper_12 = 0.408248290463863 * helper_11;
199 double helper_13 = helper_0[4];
200 double helper_14 = 0.408248290463863 * helper_13;
201 double helper_15 = helper_0[7];
202 double helper_16 = 1.22474487139159 * helper_15;
203 double helper_17 = helper_0[10];
204 double helper_18 = 0.408248290463863 * helper_17;
205 double helper_19 = helper_12 + helper_14 - helper_16 + helper_18;
206 double helper_20 = helper_10 * helper_19;
207 double helper_21 = 0.577350269189626 * helper_11;
208 double helper_22 = 1.15470053837925 * helper_13;
209 double helper_23 = 0.577350269189626 * helper_17;
210 double helper_24 = helper_21 - helper_22 + helper_23;
211 double helper_25 = 0.408248290463863 * helper_4;
212 double helper_26 = 0.408248290463863 * helper_6;
213 double helper_27 = helper_0[6];
214 double helper_28 = 1.22474487139159 * helper_27;
215 double helper_29 = 0.408248290463863 * helper_8;
216 double helper_30 = helper_25 + helper_26 - helper_28 + helper_29;
217 double helper_31 = helper_24 * helper_30;
218 double helper_32 = helper_3 * (helper_20 - helper_31);
219 double helper_33 = helper_4 - helper_8;
220 double helper_34 = 0.408248290463863 * helper_1;
221 double helper_35 = helper_0[5];
222 double helper_36 = 0.408248290463863 * helper_35;
223 double helper_37 = helper_0[8];
224 double helper_38 = 1.22474487139159 * helper_37;
225 double helper_39 = 0.408248290463863 * helper_2;
226 double helper_40 = helper_34 + helper_36 - helper_38 + helper_39;
227 double helper_41 = helper_24 * helper_40;
228 double helper_42 = 0.577350269189626 * helper_1;
229 double helper_43 = 1.15470053837925 * helper_35;
230 double helper_44 = 0.577350269189626 * helper_2;
231 double helper_45 = helper_42 - helper_43 + helper_44;
232 double helper_46 = helper_19 * helper_45;
233 double helper_47 = helper_41 - helper_46;
234 double helper_48 = helper_33 * helper_47;
235 double helper_49 = helper_11 - helper_17;
236 double helper_50 = helper_10 * helper_40;
237 double helper_51 = helper_30 * helper_45;
238 double helper_52 = helper_50 - helper_51;
239 double helper_53 = helper_49 * helper_52;
240 double helper_54 = helper_32 + helper_48 - helper_53;
241 double helper_55 =
pow(helper_54, 2);
242 double helper_56 =
pow(helper_55, -0.333333333333333);
243 double helper_57 = 1.0 * helper_27 - 3.0 * helper_4 + 1.0 * helper_6 + 1.0 * helper_8;
244 double helper_58 = 0.707106781186548 * helper_13;
245 double helper_59 = 0.707106781186548 * helper_15;
246 double helper_60 = helper_58 - helper_59;
247 double helper_61 = helper_3 * helper_60;
248 double helper_62 = 0.707106781186548 * helper_35 - 0.707106781186548 * helper_37;
249 double helper_63 = helper_49 * helper_62;
250 double helper_64 = helper_47 + helper_61 - helper_63;
251 double helper_65 = 1.33333333333333 / helper_54;
252 double helper_66 = 1.0 / helper_55;
253 double helper_67 = 0.5 * helper_27 + 0.5 * helper_6;
254 double helper_68 = -1.5 * helper_4 + helper_67 + 0.5 * helper_8;
255 double helper_69 = 0.5 * helper_4 + helper_67 - 1.5 * helper_8;
256 double helper_70 = -1.5 * helper_27 + 0.5 * helper_4 + 0.5 * helper_6 + 0.5 * helper_8;
257 double helper_71 = 0.5 * helper_27 + 0.5 * helper_4 - 1.5 * helper_6 + 0.5 * helper_8;
258 double helper_72 = 0.5 * helper_13 + 0.5 * helper_15;
259 double helper_73 = -1.5 * helper_11 + 0.5 * helper_17 + helper_72;
260 double helper_74 = 0.5 * helper_11 - 1.5 * helper_17 + helper_72;
261 double helper_75 = 0.5 * helper_11 + 0.5 * helper_13 - 1.5 * helper_15 + 0.5 * helper_17;
262 double helper_76 = 0.5 * helper_11 - 1.5 * helper_13 + 0.5 * helper_15 + 0.5 * helper_17;
263 double helper_77 = 0.5 * helper_35 + 0.5 * helper_37;
264 double helper_78 = -1.5 * helper_1 + 0.5 * helper_2 + helper_77;
265 double helper_79 = 0.5 * helper_1 - 1.5 * helper_2 + helper_77;
266 double helper_80 = 0.5 * helper_1 + 0.5 * helper_2 + 0.5 * helper_35 - 1.5 * helper_37;
267 double helper_81 = 0.5 * helper_1 + 0.5 * helper_2 - 1.5 * helper_35 + 0.5 * helper_37;
268 double helper_82 = helper_1 * helper_78 + helper_11 * helper_73 + helper_13 * helper_76 +
269 helper_15 * helper_75 + helper_17 * helper_74 + helper_2 * helper_79 +
270 helper_27 * helper_70 + helper_35 * helper_81 + helper_37 * helper_80 +
271 helper_4 * helper_68 + helper_6 * helper_71 + helper_69 * helper_8;
272 double helper_83 = 0.444444444444444 * helper_66 * helper_82;
273 double helper_84 = helper_66 * helper_82;
274 double helper_85 = -helper_32 - helper_48 + helper_53;
275 double helper_86 = 1.0 / helper_85;
276 double helper_87 = helper_86 *
pow(
pow(helper_85, 2), -0.333333333333333);
277 double helper_88 = 0.707106781186548 * helper_6;
278 double helper_89 = 0.707106781186548 * helper_27;
279 double helper_90 = helper_88 - helper_89;
281 0.666666666666667 * helper_10 * helper_40 + 0.666666666666667 * helper_3 * helper_90 -
282 0.666666666666667 * helper_30 * helper_45 - 0.666666666666667 * helper_33 * helper_62;
283 double helper_92 = -3.0 * helper_11 + 1.0 * helper_13 + 1.0 * helper_15 + 1.0 * helper_17;
284 double helper_93 = -helper_11 + helper_17;
285 double helper_94 = -helper_1 + helper_2;
286 double helper_95 = -helper_21 + helper_22 - helper_23;
287 double helper_96 = -helper_34 - helper_36 + helper_38 - helper_39;
288 double helper_97 = -helper_42 + helper_43 - helper_44;
289 double helper_98 = -helper_12 - helper_14 + helper_16 - helper_18;
291 -0.666666666666667 * helper_60 * helper_94 + 0.666666666666667 * helper_62 * helper_93 +
292 0.666666666666667 * helper_95 * helper_96 - 0.666666666666667 * helper_97 * helper_98;
293 double helper_100 = helper_3 * helper_90;
294 double helper_101 = helper_33 * helper_62;
295 double helper_102 = helper_100 - helper_101 + helper_52;
296 double helper_103 = -helper_60 * helper_94 + helper_62 * helper_93 + helper_95 * helper_96 -
297 helper_97 * helper_98;
298 double helper_104 = 0.444444444444444 * helper_102 * helper_103 * helper_82 * helper_86 +
299 helper_57 * helper_91 - helper_92 * helper_99;
301 1.85037170770859e-17 * helper_1 * helper_78 + 1.85037170770859e-17 * helper_11 * helper_73 +
302 1.85037170770859e-17 * helper_13 * helper_76 +
303 1.85037170770859e-17 * helper_15 * helper_75 +
304 1.85037170770859e-17 * helper_17 * helper_74 + 1.85037170770859e-17 * helper_2 * helper_79 +
305 1.85037170770859e-17 * helper_27 * helper_70 +
306 1.85037170770859e-17 * helper_35 * helper_81 +
307 1.85037170770859e-17 * helper_37 * helper_80 + 1.85037170770859e-17 * helper_4 * helper_68 +
308 1.85037170770859e-17 * helper_6 * helper_71 + 1.85037170770859e-17 * helper_69 * helper_8;
309 double helper_106 = helper_64 * helper_82 * helper_86;
311 -0.666666666666667 * helper_10 * helper_19 + 0.666666666666667 * helper_24 * helper_30 +
312 0.666666666666667 * helper_33 * helper_60 - 0.666666666666667 * helper_49 * helper_90;
313 double helper_108 = -3.0 * helper_1 + 1.0 * helper_2 + 1.0 * helper_35 + 1.0 * helper_37;
314 double helper_109 = -helper_20 + helper_31 + helper_33 * helper_60 - helper_49 * helper_90;
315 double helper_110 = 0.444444444444444 * helper_109 * helper_82 * helper_86;
316 double helper_111 = helper_103 * helper_110 + helper_107 * helper_57 - helper_108 * helper_99;
317 double helper_112 = -helper_4 + helper_8;
318 double helper_113 = -helper_88 + helper_89;
319 double helper_114 = -helper_5 + helper_7 - helper_9;
320 double helper_115 = -helper_25 - helper_26 + helper_28 - helper_29;
321 double helper_116 = helper_82 * helper_86 *
322 (helper_112 * helper_62 + helper_113 * helper_94 + helper_114 * helper_96 -
323 helper_115 * helper_97);
324 double helper_117 = -helper_100 + helper_101 - helper_50 + helper_51;
325 double helper_118 = -helper_102 * helper_110 + helper_107 * helper_92 + helper_108 * helper_91;
326 double helper_119 = helper_82 * helper_86 *
327 (helper_112 * (-helper_58 + helper_59) - helper_113 * helper_93 -
328 helper_114 * helper_98 + helper_115 * helper_95);
330 helper_56 * (helper_57 * helper_64 * helper_65 -
pow(helper_64, 2) * helper_83 +
331 0.666666666666667 * helper_64 * helper_84 *
332 (-helper_41 + helper_46 - helper_61 + helper_63) +
334 result_0(0, 1) = helper_87 * (helper_104 - helper_105 * helper_35 + helper_106 * helper_91);
335 result_0(0, 2) = helper_87 * (helper_106 * helper_107 + helper_111);
336 result_0(1, 0) = helper_87 * (helper_104 + helper_116 * helper_99);
338 helper_56 * (-
pow(helper_117, 2) * helper_83 + helper_117 * helper_65 * helper_92 +
339 helper_117 * helper_84 * helper_91 + 3.0);
340 result_0(1, 2) = helper_87 * (-helper_105 * helper_6 - helper_107 * helper_116 + helper_118);
341 result_0(2, 0) = helper_87 * (-helper_105 * helper_13 + helper_111 + helper_119 * helper_99);
342 result_0(2, 1) = helper_87 * (helper_118 - helper_119 * helper_91);
343 result_0(2, 2) = helper_56 * (-helper_108 * helper_109 * helper_65 -
344 1.11111111111111 *
pow(helper_109, 2) * helper_84 + 3.0);
381 std::array<Rational, 12> r_T;
382 for (
int j = 0; j < 12; j++) {
389 ((-r_T[1 + 2] + r_T[1 + 5]) * r_T[1 + 1] + r_T[1 + 2] * r_T[1 + 7] +
390 (r_T[1 + -1] - r_T[1 + 5]) * r_T[1 + 4] - r_T[1 + -1] * r_T[1 + 7]) *
392 ((r_T[1 + 2] - r_T[1 + 5]) * r_T[1 + 0] - r_T[1 + 2] * r_T[1 + 6] +
393 (-r_T[1 + -1] + r_T[1 + 5]) * r_T[1 + 3] + r_T[1 + -1] * r_T[1 + 6]) *
395 (-r_T[1 + 2] * r_T[1 + 7] + (-r_T[1 + 8] + r_T[1 + 5]) * r_T[1 + 4] +
396 r_T[1 + 8] * r_T[1 + 7]) *
398 (r_T[1 + 2] * r_T[1 + 6] + (r_T[1 + 8] - r_T[1 + 5]) * r_T[1 + 3] -
399 r_T[1 + 8] * r_T[1 + 6]) *
401 (r_T[1 + 3] * r_T[1 + 7] - r_T[1 + 4] * r_T[1 + 6]) * (r_T[1 + -1] - r_T[1 + 8]);
403 if (tmp == 0)
return std::numeric_limits<double>::infinity();
407 pow(r_T[1 + 9] * r_T[1 + 9] +
408 (-twothird * r_T[1 + 0] - twothird * r_T[1 + 3] - twothird * r_T[1 + 6]) *
410 r_T[1 + 10] * r_T[1 + 10] +
411 (-twothird * r_T[1 + 1] - twothird * r_T[1 + 4] - twothird * r_T[1 + 7]) *
413 r_T[1 + 0] * r_T[1 + 0] +
414 (-twothird * r_T[1 + 3] - twothird * r_T[1 + 6]) * r_T[1 + 0] +
415 r_T[1 + 1] * r_T[1 + 1] +
416 (-twothird * r_T[1 + 4] - twothird * r_T[1 + 7]) * r_T[1 + 1] +
417 r_T[1 + 2] * r_T[1 + 2] +
418 (-twothird * r_T[1 + -1] - twothird * r_T[1 + 8] - twothird * r_T[1 + 5]) *
420 r_T[1 + 3] * r_T[1 + 3] - twothird * r_T[1 + 3] * r_T[1 + 6] +
421 r_T[1 + 4] * r_T[1 + 4] - twothird * r_T[1 + 4] * r_T[1 + 7] +
422 r_T[1 + 5] * r_T[1 + 5] +
423 (-twothird * r_T[1 + -1] - twothird * r_T[1 + 8]) * r_T[1 + 5] -
424 twothird * r_T[1 + -1] * r_T[1 + 8] + r_T[1 + -1] * r_T[1 + -1] +
425 r_T[1 + 8] * r_T[1 + 8] + r_T[1 + 6] * r_T[1 + 6] + r_T[1 + 7] * r_T[1 + 7],
428 return std::cbrt(res_r.to_double());
444 double helper_1 = helper_0[0];
445 double helper_2 = helper_0[2];
446 double helper_3 = helper_0[1];
447 double helper_4 = helper_0[3];
448 double helper_5 = helper_0[5];
449 double helper_6 = helper_0[4];
450 double helper_7 = 0.666666666666667 * helper_6;
451 double helper_8 = 0.666666666666667 * helper_5;
453 ((helper_1 - helper_2) * (0.577350269189626 * helper_3 + 0.577350269189626 * helper_4 -
454 1.15470053837925 * helper_5) -
455 (helper_3 - helper_4) * (0.577350269189626 * helper_1 + 0.577350269189626 * helper_2 -
456 1.15470053837925 * helper_6));
462 return -(helper_1 * (-1.33333333333333 * helper_1 + 0.666666666666667 * helper_2 + helper_7) +
463 helper_2 * (0.666666666666667 * helper_1 - 1.33333333333333 * helper_2 + helper_7) +
464 helper_3 * (-1.33333333333333 * helper_3 + 0.666666666666667 * helper_4 + helper_8) +
465 helper_4 * (0.666666666666667 * helper_3 - 1.33333333333333 * helper_4 + helper_8) +
466 helper_5 * (0.666666666666667 * helper_3 + 0.666666666666667 * helper_4 -
467 1.33333333333333 * helper_5) +
468 helper_6 * (0.666666666666667 * helper_1 + 0.666666666666667 * helper_2 -
469 1.33333333333333 * helper_6)) /
475 static const double sqrt3 = sqrt(3);
481 if (res > 1e8 || res <= 0) {
482 std::array<Rational, 6> r_T;
483 for (
int j = 0; j < 6; j++) {
487 const auto tmp = r_T[0] * r_T[3] - r_T[0] * r_T[5] - r_T[1] * r_T[2] + r_T[1] * r_T[4] +
488 r_T[2] * r_T[5] - r_T[3] * r_T[4];
490 if (tmp <= 0)
return std::numeric_limits<double>::infinity();
492 const auto res_r = two_third * sqrt3 *
493 (r_T[0] * r_T[0] - r_T[0] * r_T[2] - r_T[0] * r_T[4] + r_T[1] * r_T[1] -
494 r_T[1] * r_T[3] - r_T[1] * r_T[5] + r_T[2] * r_T[2] - r_T[2] * r_T[4] +
495 r_T[3] * r_T[3] - r_T[3] * r_T[5] + r_T[4] * r_T[4] + r_T[5] * r_T[5]) /
512 double helper_1 = helper_0[0];
513 double helper_2 = helper_0[2];
514 double helper_3 = helper_0[1];
515 double helper_4 = helper_0[3];
516 double helper_5 = helper_0[5];
517 double helper_6 = helper_0[4];
520 ((helper_1 - helper_2) * (0.577350269189626 * helper_3 + 0.577350269189626 * helper_4 -
521 1.15470053837925 * helper_5) -
522 (helper_3 - helper_4) * (0.577350269189626 * helper_1 + 0.577350269189626 * helper_2 -
523 1.15470053837925 * helper_6));
524 double helper_8 = -1.33333333333333 * helper_6;
525 double helper_9 = 0.666666666666667 * helper_6;
526 double helper_10 = 0.666666666666667 * helper_5;
527 double helper_11 = 1.33333333333333 * helper_5;
529 1.15470053837925 * helper_7 *
530 (helper_1 * (-1.33333333333333 * helper_1 + 0.666666666666667 * helper_2 + helper_9) +
531 helper_2 * (0.666666666666667 * helper_1 - 1.33333333333333 * helper_2 + helper_9) +
532 helper_3 * (helper_10 - 1.33333333333333 * helper_3 + 0.666666666666667 * helper_4) +
533 helper_4 * (helper_10 + 0.666666666666667 * helper_3 - 1.33333333333333 * helper_4) +
534 helper_5 * (-helper_11 + 0.666666666666667 * helper_3 + 0.666666666666667 * helper_4) +
535 helper_6 * (0.666666666666667 * helper_1 + 0.666666666666667 * helper_2 + helper_8));
536 result_0(0) = helper_7 * (2.66666666666667 * helper_1 + helper_12 * (helper_4 - helper_5) -
537 1.33333333333333 * helper_2 + helper_8);
538 result_0(1) = -helper_7 * (helper_11 + helper_12 * (helper_2 - helper_6) -
539 2.66666666666667 * helper_3 + 1.33333333333333 * helper_4);
551 double helper_1 = helper_0[0];
552 double helper_2 = helper_0[2];
553 double helper_3 = helper_0[1];
554 double helper_4 = helper_0[3];
555 double helper_5 = helper_0[5];
556 double helper_6 = helper_0[4];
558 (helper_1 - helper_2) * (0.577350269189626 * helper_3 + 0.577350269189626 * helper_4 -
559 1.15470053837925 * helper_5) -
560 (helper_3 - helper_4) * (0.577350269189626 * helper_1 + 0.577350269189626 * helper_2 -
561 1.15470053837925 * helper_6);
562 double helper_8 = 1.0 / helper_7;
563 double helper_9 = helper_4 - helper_5;
564 double helper_10 = 1.33333333333333 * helper_6;
565 double helper_11 = -2.66666666666667 * helper_1 + helper_10 + 1.33333333333333 * helper_2;
566 double helper_12 = 2.3094010767585 * helper_8;
567 double helper_13 =
pow(helper_7, -2);
568 double helper_14 = 0.666666666666667 * helper_6;
569 double helper_15 = 0.666666666666667 * helper_5;
570 double helper_16 = 1.33333333333333 * helper_5;
572 helper_1 * (-1.33333333333333 * helper_1 + helper_14 + 0.666666666666667 * helper_2) +
573 helper_2 * (0.666666666666667 * helper_1 + helper_14 - 1.33333333333333 * helper_2) +
574 helper_3 * (helper_15 - 1.33333333333333 * helper_3 + 0.666666666666667 * helper_4) +
575 helper_4 * (helper_15 + 0.666666666666667 * helper_3 - 1.33333333333333 * helper_4) +
576 helper_5 * (-helper_16 + 0.666666666666667 * helper_3 + 0.666666666666667 * helper_4) +
577 helper_6 * (0.666666666666667 * helper_1 - helper_10 + 0.666666666666667 * helper_2);
578 double helper_18 = 2.66666666666667 * helper_13 * helper_17;
579 double helper_19 = helper_2 - helper_6;
580 double helper_20 = helper_16 - 2.66666666666667 * helper_3 + 1.33333333333333 * helper_4;
581 double helper_21 = helper_13 * (-1.15470053837925 * helper_11 * helper_19 +
582 2.66666666666667 * helper_17 * helper_19 * helper_8 * helper_9 +
583 1.15470053837925 * helper_20 * helper_9);
584 result_0(0) = helper_8 * (helper_11 * helper_12 * helper_9 - helper_18 *
pow(helper_9, 2) +
586 result_0(1) = helper_21;
587 result_0(2) = helper_21;
588 result_0(3) = helper_8 * (-helper_12 * helper_19 * helper_20 - helper_18 *
pow(helper_19, 2) +
592 template <
int64_t NV,
int64_t DIM>
597 std::array<double, NV * DIM> res;
598 assert(data.size() == NV);
600 const size_t start = index < 0 ? 0 : index;
602 for (
size_t i = 0; i < NV; ++i) {
603 const size_t ii = (i + start) % NV;
604 assert(data[ii].size() == DIM);
606 for (
size_t j = 0; j < DIM; ++j) {
607 res[DIM * i + j] = data[ii][j];
614 template <
int64_t NV,
int64_t DIM>
615 std::array<Rational, NV * DIM>
unbox(
619 std::array<Rational, NV * DIM> res;
620 assert(data.size() == NV);
622 const size_t start = index < 0 ? 0 : index;
624 for (
size_t i = 0; i < NV; ++i) {
625 const size_t ii = (i + start) % NV;
626 assert(data[ii].size() == DIM);
628 for (
size_t j = 0; j < DIM; ++j) {
629 res[DIM * i + j] = data[ii][j];
637 template <
int64_t NV,
int64_t DIM>
640 const std::optional<simplex::Simplex>& variable_simplex)
const
653 variable_simplex.has_value() ? variable_simplex->
tuple() : std::optional<Tuple>());
655 return unbox<NV, DIM>(attrs, index);
665 variable_simplex.has_value() ? variable_simplex->
tuple() : std::optional<Tuple>());
667 const auto coord_rational = unbox<NV, DIM>(attrs, index);
668 std::array<double, coord_rational.size()> coord;
670 for (
int i = 0; i < coord_rational.size(); ++i) {
671 coord[i] = coord_rational[i].to_double();
678 throw std::runtime_error(
"AMIP coordinate handle with invalid type");
689 static constexpr
double NaN = std::numeric_limits<double>::quiet_NaN();
697 throw std::runtime_error(
"AMIPS wrong simplex type");
716 throw std::runtime_error(
"AMIPS wrong simplex type");
725 Tet_AMIPS_hessian(get_raw_coordinates<4, 3>(domain_simplex, variable_simplex), res);
729 Tri_AMIPS_hessian(get_raw_coordinates<3, 2>(domain_simplex, variable_simplex), res);
732 throw std::runtime_error(
"AMIPS wrong simplex type");
const attribute::Accessor< T, Mesh, D > create_const_accessor(const attribute::MeshAttributeHandle &handle) const
A CachingAccessor that uses tuples for accessing attributes instead of indices.
Eigen::VectorXd get_gradient(const simplex::Simplex &domain_simplex, const simplex::Simplex &variable_simplex) const override
std::array< double, NV *DIM > get_raw_coordinates(const simplex::Simplex &domain_simplex, const std::optional< simplex::Simplex > &variable_simplex={}) const
AMIPS(const Mesh &mesh, const attribute::MeshAttributeHandle &attribute_handle)
Construct a new AMIPS function.
Eigen::MatrixXd get_hessian(const simplex::Simplex &domain_simplex, const simplex::Simplex &variable_simplex) const override
double get_value(const simplex::Simplex &domain_simplex) const override
This function is defined over a simplex (normally a triangle or tetrahedron).
const attribute::MeshAttributeHandle & attribute_handle() const
int64_t embedded_dimension() const
const Mesh & mesh() const
const PrimitiveType m_primitive_type
const Tuple & tuple() const
PrimitiveType primitive_type() const
typename internal::VectorResult< T, R >::ConstMapType ConstMapResult
std::tuple< std::vector< std::decay_t< typename attribute::ConstMapResult< T > > >, int64_t > get_simplex_attributes(const Mesh &mesh, const wmtk::attribute::Accessor< T > &accessor, const PrimitiveType primitive_type, const simplex::Simplex &simplex_in, const std::optional< wmtk::Tuple > &vertex_marker)
get attributes from a simplex
double Tri_AMIPS_energy_aux(const std::array< double, 6 > &T)
void Tet_AMIPS_jacobian(const std::array< double, 12 > &T, Eigen::Vector3d &result_0)
double Tet_AMIPS_energy_aux(const std::array< double, 12 > &T)
void Tri_AMIPS_hessian(const std::array< double, 6 > &T, Eigen::Matrix2d &result_0)
void Tri_AMIPS_jacobian(const std::array< double, 6 > &T, Eigen::Vector2d &result_0)
double Tet_AMIPS_energy(const std::array< double, 12 > &T)
void Tet_AMIPS_hessian(const std::array< double, 12 > &T, Eigen::Matrix3d &result_0)
double Tri_AMIPS_energy(const std::array< double, 6 > &T)
std::array< double, NV *DIM > unbox(const std::vector< std::decay_t< typename attribute::ConstMapResult< double >>> &data, const int64_t index)
int wmtk_orient2d(double p0x, double p0y, double p1x, double p1y, double p2x, double p2y)
Rational abs(const Rational &r0)
Vector< double, 3 > Vector3d
Rational pow(const Rational &x, int p)