20#ifndef ROOT_Math_CramerInversion_icc
21#define ROOT_Math_CramerInversion_icc
24#error "Do not use CramerInversion.icc directly. #include \"Math/Dinv.h\" instead."
43template <
class MatrixRep>
46 typedef typename MatrixRep::value_type
Scalar;
52 const Scalar c00 = rhs[4] * rhs[8] - rhs[5] * rhs[7];
53 const Scalar c01 = rhs[5] * rhs[6] - rhs[3] * rhs[8];
54 const Scalar c02 = rhs[3] * rhs[7] - rhs[4] * rhs[6];
55 const Scalar c10 = rhs[7] * rhs[2] - rhs[8] * rhs[1];
56 const Scalar c11 = rhs[8] * rhs[0] - rhs[6] * rhs[2];
57 const Scalar c12 = rhs[6] * rhs[1] - rhs[7] * rhs[0];
58 const Scalar c20 = rhs[1] * rhs[5] - rhs[2] * rhs[4];
59 const Scalar c21 = rhs[2] * rhs[3] - rhs[0] * rhs[5];
60 const Scalar c22 = rhs[0] * rhs[4] - rhs[1] * rhs[3];
62 const Scalar t0 = std::abs(rhs[0]);
64 const Scalar t2 = std::abs(rhs[6]);
70 det = c12*c01-c11*c02;
73 det = c11*c22-c12*c21;
75 }
else if (t2 >=
t1) {
77 det = c12*c01-c11*c02;
80 det = c02*c21-c01*c22;
83 if ( det == 0 || tmp == 0) {
134template <
class MatrixRep>
137 typedef typename MatrixRep::value_type
Scalar;
166 const Scalar det3_012_012 = rhs[
F00]*det2_12_12 - rhs[
F01]*det2_12_02
167 + rhs[
F02]*det2_12_01;
168 const Scalar det3_012_013 = rhs[
F00]*det2_12_13 - rhs[
F01]*det2_12_03
169 + rhs[
F03]*det2_12_01;
170 const Scalar det3_012_023 = rhs[
F00]*det2_12_23 - rhs[
F02]*det2_12_03
171 + rhs[
F03]*det2_12_02;
172 const Scalar det3_012_123 = rhs[
F01]*det2_12_23 - rhs[
F02]*det2_12_13
173 + rhs[
F03]*det2_12_12;
174 const Scalar det3_013_012 = rhs[
F00]*det2_13_12 - rhs[
F01]*det2_13_02
175 + rhs[
F02]*det2_13_01;
176 const Scalar det3_013_013 = rhs[
F00]*det2_13_13 - rhs[
F01]*det2_13_03
177 + rhs[
F03]*det2_13_01;
178 const Scalar det3_013_023 = rhs[
F00]*det2_13_23 - rhs[
F02]*det2_13_03
179 + rhs[
F03]*det2_13_02;
180 const Scalar det3_013_123 = rhs[
F01]*det2_13_23 - rhs[
F02]*det2_13_13
181 + rhs[
F03]*det2_13_12;
182 const Scalar det3_023_012 = rhs[
F00]*det2_23_12 - rhs[
F01]*det2_23_02
183 + rhs[
F02]*det2_23_01;
184 const Scalar det3_023_013 = rhs[
F00]*det2_23_13 - rhs[
F01]*det2_23_03
185 + rhs[
F03]*det2_23_01;
186 const Scalar det3_023_023 = rhs[
F00]*det2_23_23 - rhs[
F02]*det2_23_03
187 + rhs[
F03]*det2_23_02;
188 const Scalar det3_023_123 = rhs[
F01]*det2_23_23 - rhs[
F02]*det2_23_13
189 + rhs[
F03]*det2_23_12;
190 const Scalar det3_123_012 = rhs[
F10]*det2_23_12 - rhs[
F11]*det2_23_02
191 + rhs[
F12]*det2_23_01;
192 const Scalar det3_123_013 = rhs[
F10]*det2_23_13 - rhs[
F11]*det2_23_03
193 + rhs[
F13]*det2_23_01;
194 const Scalar det3_123_023 = rhs[
F10]*det2_23_23 - rhs[
F12]*det2_23_03
195 + rhs[
F13]*det2_23_02;
196 const Scalar det3_123_123 = rhs[
F11]*det2_23_23 - rhs[
F12]*det2_23_13
197 + rhs[
F13]*det2_23_12;
201 const Scalar det = rhs[
F00]*det3_123_123 - rhs[
F01]*det3_123_023
202 + rhs[
F02]*det3_123_013 - rhs[
F03]*det3_123_012;
212 const Scalar oneOverDet = 1.0f / det;
213 const Scalar mn1OverDet = - oneOverDet;
215 rhs[
F00] = det3_123_123 * oneOverDet;
216 rhs[
F01] = det3_023_123 * mn1OverDet;
217 rhs[
F02] = det3_013_123 * oneOverDet;
218 rhs[
F03] = det3_012_123 * mn1OverDet;
220 rhs[
F10] = det3_123_023 * mn1OverDet;
221 rhs[
F11] = det3_023_023 * oneOverDet;
222 rhs[
F12] = det3_013_023 * mn1OverDet;
223 rhs[
F13] = det3_012_023 * oneOverDet;
225 rhs[
F20] = det3_123_013 * oneOverDet;
226 rhs[
F21] = det3_023_013 * mn1OverDet;
227 rhs[
F22] = det3_013_013 * oneOverDet;
228 rhs[
F23] = det3_012_013 * mn1OverDet;
230 rhs[
F30] = det3_123_012 * mn1OverDet;
231 rhs[
F31] = det3_023_012 * oneOverDet;
232 rhs[
F32] = det3_013_012 * mn1OverDet;
233 rhs[
F33] = det3_012_012 * oneOverDet;
276template <
class MatrixRep>
279 typedef typename MatrixRep::value_type
Scalar;
321 const Scalar det3_123_012 = rhs[
M10]*det2_23_12 - rhs[
M11]*det2_23_02 + rhs[
M12]*det2_23_01;
322 const Scalar det3_123_013 = rhs[
M10]*det2_23_13 - rhs[
M11]*det2_23_03 + rhs[
M13]*det2_23_01;
323 const Scalar det3_123_014 = rhs[
M10]*det2_23_14 - rhs[
M11]*det2_23_04 + rhs[
M14]*det2_23_01;
324 const Scalar det3_123_023 = rhs[
M10]*det2_23_23 - rhs[
M12]*det2_23_03 + rhs[
M13]*det2_23_02;
325 const Scalar det3_123_024 = rhs[
M10]*det2_23_24 - rhs[
M12]*det2_23_04 + rhs[
M14]*det2_23_02;
326 const Scalar det3_123_034 = rhs[
M10]*det2_23_34 - rhs[
M13]*det2_23_04 + rhs[
M14]*det2_23_03;
327 const Scalar det3_123_123 = rhs[
M11]*det2_23_23 - rhs[
M12]*det2_23_13 + rhs[
M13]*det2_23_12;
328 const Scalar det3_123_124 = rhs[
M11]*det2_23_24 - rhs[
M12]*det2_23_14 + rhs[
M14]*det2_23_12;
329 const Scalar det3_123_134 = rhs[
M11]*det2_23_34 - rhs[
M13]*det2_23_14 + rhs[
M14]*det2_23_13;
330 const Scalar det3_123_234 = rhs[
M12]*det2_23_34 - rhs[
M13]*det2_23_24 + rhs[
M14]*det2_23_23;
331 const Scalar det3_124_012 = rhs[
M10]*det2_24_12 - rhs[
M11]*det2_24_02 + rhs[
M12]*det2_24_01;
332 const Scalar det3_124_013 = rhs[
M10]*det2_24_13 - rhs[
M11]*det2_24_03 + rhs[
M13]*det2_24_01;
333 const Scalar det3_124_014 = rhs[
M10]*det2_24_14 - rhs[
M11]*det2_24_04 + rhs[
M14]*det2_24_01;
334 const Scalar det3_124_023 = rhs[
M10]*det2_24_23 - rhs[
M12]*det2_24_03 + rhs[
M13]*det2_24_02;
335 const Scalar det3_124_024 = rhs[
M10]*det2_24_24 - rhs[
M12]*det2_24_04 + rhs[
M14]*det2_24_02;
336 const Scalar det3_124_034 = rhs[
M10]*det2_24_34 - rhs[
M13]*det2_24_04 + rhs[
M14]*det2_24_03;
337 const Scalar det3_124_123 = rhs[
M11]*det2_24_23 - rhs[
M12]*det2_24_13 + rhs[
M13]*det2_24_12;
338 const Scalar det3_124_124 = rhs[
M11]*det2_24_24 - rhs[
M12]*det2_24_14 + rhs[
M14]*det2_24_12;
339 const Scalar det3_124_134 = rhs[
M11]*det2_24_34 - rhs[
M13]*det2_24_14 + rhs[
M14]*det2_24_13;
340 const Scalar det3_124_234 = rhs[
M12]*det2_24_34 - rhs[
M13]*det2_24_24 + rhs[
M14]*det2_24_23;
341 const Scalar det3_134_012 = rhs[
M10]*det2_34_12 - rhs[
M11]*det2_34_02 + rhs[
M12]*det2_34_01;
342 const Scalar det3_134_013 = rhs[
M10]*det2_34_13 - rhs[
M11]*det2_34_03 + rhs[
M13]*det2_34_01;
343 const Scalar det3_134_014 = rhs[
M10]*det2_34_14 - rhs[
M11]*det2_34_04 + rhs[
M14]*det2_34_01;
344 const Scalar det3_134_023 = rhs[
M10]*det2_34_23 - rhs[
M12]*det2_34_03 + rhs[
M13]*det2_34_02;
345 const Scalar det3_134_024 = rhs[
M10]*det2_34_24 - rhs[
M12]*det2_34_04 + rhs[
M14]*det2_34_02;
346 const Scalar det3_134_034 = rhs[
M10]*det2_34_34 - rhs[
M13]*det2_34_04 + rhs[
M14]*det2_34_03;
347 const Scalar det3_134_123 = rhs[
M11]*det2_34_23 - rhs[
M12]*det2_34_13 + rhs[
M13]*det2_34_12;
348 const Scalar det3_134_124 = rhs[
M11]*det2_34_24 - rhs[
M12]*det2_34_14 + rhs[
M14]*det2_34_12;
349 const Scalar det3_134_134 = rhs[
M11]*det2_34_34 - rhs[
M13]*det2_34_14 + rhs[
M14]*det2_34_13;
350 const Scalar det3_134_234 = rhs[
M12]*det2_34_34 - rhs[
M13]*det2_34_24 + rhs[
M14]*det2_34_23;
351 const Scalar det3_234_012 = rhs[
M20]*det2_34_12 - rhs[
M21]*det2_34_02 + rhs[
M22]*det2_34_01;
352 const Scalar det3_234_013 = rhs[
M20]*det2_34_13 - rhs[
M21]*det2_34_03 + rhs[
M23]*det2_34_01;
353 const Scalar det3_234_014 = rhs[
M20]*det2_34_14 - rhs[
M21]*det2_34_04 + rhs[
M24]*det2_34_01;
354 const Scalar det3_234_023 = rhs[
M20]*det2_34_23 - rhs[
M22]*det2_34_03 + rhs[
M23]*det2_34_02;
355 const Scalar det3_234_024 = rhs[
M20]*det2_34_24 - rhs[
M22]*det2_34_04 + rhs[
M24]*det2_34_02;
356 const Scalar det3_234_034 = rhs[
M20]*det2_34_34 - rhs[
M23]*det2_34_04 + rhs[
M24]*det2_34_03;
357 const Scalar det3_234_123 = rhs[
M21]*det2_34_23 - rhs[
M22]*det2_34_13 + rhs[
M23]*det2_34_12;
358 const Scalar det3_234_124 = rhs[
M21]*det2_34_24 - rhs[
M22]*det2_34_14 + rhs[
M24]*det2_34_12;
359 const Scalar det3_234_134 = rhs[
M21]*det2_34_34 - rhs[
M23]*det2_34_14 + rhs[
M24]*det2_34_13;
360 const Scalar det3_234_234 = rhs[
M22]*det2_34_34 - rhs[
M23]*det2_34_24 + rhs[
M24]*det2_34_23;
364 const Scalar det4_0123_0123 = rhs[
M00]*det3_123_123 - rhs[
M01]*det3_123_023
365 + rhs[
M02]*det3_123_013 - rhs[
M03]*det3_123_012;
366 const Scalar det4_0123_0124 = rhs[
M00]*det3_123_124 - rhs[
M01]*det3_123_024
367 + rhs[
M02]*det3_123_014 - rhs[
M04]*det3_123_012;
368 const Scalar det4_0123_0134 = rhs[
M00]*det3_123_134 - rhs[
M01]*det3_123_034
369 + rhs[
M03]*det3_123_014 - rhs[
M04]*det3_123_013;
370 const Scalar det4_0123_0234 = rhs[
M00]*det3_123_234 - rhs[
M02]*det3_123_034
371 + rhs[
M03]*det3_123_024 - rhs[
M04]*det3_123_023;
372 const Scalar det4_0123_1234 = rhs[
M01]*det3_123_234 - rhs[
M02]*det3_123_134
373 + rhs[
M03]*det3_123_124 - rhs[
M04]*det3_123_123;
374 const Scalar det4_0124_0123 = rhs[
M00]*det3_124_123 - rhs[
M01]*det3_124_023
375 + rhs[
M02]*det3_124_013 - rhs[
M03]*det3_124_012;
376 const Scalar det4_0124_0124 = rhs[
M00]*det3_124_124 - rhs[
M01]*det3_124_024
377 + rhs[
M02]*det3_124_014 - rhs[
M04]*det3_124_012;
378 const Scalar det4_0124_0134 = rhs[
M00]*det3_124_134 - rhs[
M01]*det3_124_034
379 + rhs[
M03]*det3_124_014 - rhs[
M04]*det3_124_013;
380 const Scalar det4_0124_0234 = rhs[
M00]*det3_124_234 - rhs[
M02]*det3_124_034
381 + rhs[
M03]*det3_124_024 - rhs[
M04]*det3_124_023;
382 const Scalar det4_0124_1234 = rhs[
M01]*det3_124_234 - rhs[
M02]*det3_124_134
383 + rhs[
M03]*det3_124_124 - rhs[
M04]*det3_124_123;
384 const Scalar det4_0134_0123 = rhs[
M00]*det3_134_123 - rhs[
M01]*det3_134_023
385 + rhs[
M02]*det3_134_013 - rhs[
M03]*det3_134_012;
386 const Scalar det4_0134_0124 = rhs[
M00]*det3_134_124 - rhs[
M01]*det3_134_024
387 + rhs[
M02]*det3_134_014 - rhs[
M04]*det3_134_012;
388 const Scalar det4_0134_0134 = rhs[
M00]*det3_134_134 - rhs[
M01]*det3_134_034
389 + rhs[
M03]*det3_134_014 - rhs[
M04]*det3_134_013;
390 const Scalar det4_0134_0234 = rhs[
M00]*det3_134_234 - rhs[
M02]*det3_134_034
391 + rhs[
M03]*det3_134_024 - rhs[
M04]*det3_134_023;
392 const Scalar det4_0134_1234 = rhs[
M01]*det3_134_234 - rhs[
M02]*det3_134_134
393 + rhs[
M03]*det3_134_124 - rhs[
M04]*det3_134_123;
394 const Scalar det4_0234_0123 = rhs[
M00]*det3_234_123 - rhs[
M01]*det3_234_023
395 + rhs[
M02]*det3_234_013 - rhs[
M03]*det3_234_012;
396 const Scalar det4_0234_0124 = rhs[
M00]*det3_234_124 - rhs[
M01]*det3_234_024
397 + rhs[
M02]*det3_234_014 - rhs[
M04]*det3_234_012;
398 const Scalar det4_0234_0134 = rhs[
M00]*det3_234_134 - rhs[
M01]*det3_234_034
399 + rhs[
M03]*det3_234_014 - rhs[
M04]*det3_234_013;
400 const Scalar det4_0234_0234 = rhs[
M00]*det3_234_234 - rhs[
M02]*det3_234_034
401 + rhs[
M03]*det3_234_024 - rhs[
M04]*det3_234_023;
402 const Scalar det4_0234_1234 = rhs[
M01]*det3_234_234 - rhs[
M02]*det3_234_134
403 + rhs[
M03]*det3_234_124 - rhs[
M04]*det3_234_123;
404 const Scalar det4_1234_0123 = rhs[
M10]*det3_234_123 - rhs[
M11]*det3_234_023
405 + rhs[
M12]*det3_234_013 - rhs[
M13]*det3_234_012;
406 const Scalar det4_1234_0124 = rhs[
M10]*det3_234_124 - rhs[
M11]*det3_234_024
407 + rhs[
M12]*det3_234_014 - rhs[
M14]*det3_234_012;
408 const Scalar det4_1234_0134 = rhs[
M10]*det3_234_134 - rhs[
M11]*det3_234_034
409 + rhs[
M13]*det3_234_014 - rhs[
M14]*det3_234_013;
410 const Scalar det4_1234_0234 = rhs[
M10]*det3_234_234 - rhs[
M12]*det3_234_034
411 + rhs[
M13]*det3_234_024 - rhs[
M14]*det3_234_023;
412 const Scalar det4_1234_1234 = rhs[
M11]*det3_234_234 - rhs[
M12]*det3_234_134
413 + rhs[
M13]*det3_234_124 - rhs[
M14]*det3_234_123;
417 const Scalar det = rhs[
M00]*det4_1234_1234 - rhs[
M01]*det4_1234_0234 + rhs[
M02]*det4_1234_0134
418 - rhs[
M03]*det4_1234_0124 + rhs[
M04]*det4_1234_0123;
429 const Scalar oneOverDet = 1.0f / det;
430 const Scalar mn1OverDet = - oneOverDet;
432 rhs[
M00] = det4_1234_1234 * oneOverDet;
433 rhs[
M01] = det4_0234_1234 * mn1OverDet;
434 rhs[
M02] = det4_0134_1234 * oneOverDet;
435 rhs[
M03] = det4_0124_1234 * mn1OverDet;
436 rhs[
M04] = det4_0123_1234 * oneOverDet;
438 rhs[
M10] = det4_1234_0234 * mn1OverDet;
439 rhs[
M11] = det4_0234_0234 * oneOverDet;
440 rhs[
M12] = det4_0134_0234 * mn1OverDet;
441 rhs[
M13] = det4_0124_0234 * oneOverDet;
442 rhs[
M14] = det4_0123_0234 * mn1OverDet;
444 rhs[
M20] = det4_1234_0134 * oneOverDet;
445 rhs[
M21] = det4_0234_0134 * mn1OverDet;
446 rhs[
M22] = det4_0134_0134 * oneOverDet;
447 rhs[
M23] = det4_0124_0134 * mn1OverDet;
448 rhs[
M24] = det4_0123_0134 * oneOverDet;
450 rhs[
M30] = det4_1234_0124 * mn1OverDet;
451 rhs[
M31] = det4_0234_0124 * oneOverDet;
452 rhs[
M32] = det4_0134_0124 * mn1OverDet;
453 rhs[
M33] = det4_0124_0124 * oneOverDet;
454 rhs[
M34] = det4_0123_0124 * mn1OverDet;
456 rhs[
M40] = det4_1234_0123 * oneOverDet;
457 rhs[
M41] = det4_0234_0123 * mn1OverDet;
458 rhs[
M42] = det4_0134_0123 * oneOverDet;
459 rhs[
M43] = det4_0124_0123 * mn1OverDet;
460 rhs[
M44] = det4_0123_0123 * oneOverDet;
static bool Dinv(MatrixRep &rhs)
Namespace for new Math classes and functions.
Rotation3D::Scalar Scalar
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...