39#if (defined(__NVCC__) && defined(__CUDA_ARCH__)) \
40 || (defined(__HIPCC__) && defined(__HIP_DEVICE_COMPILE__)) \
41 || defined(SYCL_LANGUAGE_VERSION) \
42 || defined(HAVE_OPENMP_TARGET)
46#if defined(__cplusplus)
54#if defined(DEBUG) && !defined(NDEBUG)
93static constexpr double cs_dbl_epsilon = std::numeric_limits<double>::epsilon();
135#if defined(__cplusplus)
169template <
typename T,
typename U>
175 return ((xb[0] - xa[0])*xc[0]+(xb[1] - xa[1])*xc[1]+(xb[2] - xa[2])*xc[2]);
192template <
typename T,
typename U>
197 double uv = u[0]*v[0] + u[1]*v[1] + u[2]*v[2];
221 T uv = u[0]*v[0] + u[1]*v[1] + u[2]*v[2];
242 return sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
259 return (
t[0][0] +
t[1][1] +
t[2][2]);
282template <
typename T,
typename U,
typename V>
288 return ( n1[0] * (
t[0]*n2[0] +
t[3]*n2[1] +
t[5]*n2[2])
289 + n1[1] * (
t[3]*n2[0] +
t[1]*n2[1] +
t[4]*n2[2])
290 + n1[2] * (
t[5]*n2[0] +
t[4]*n2[1] +
t[2]*n2[2]));
306template <cs_lnum_t str
ide>
313 retval =
t[0]*
t[0] +
t[1]*
t[1] +
t[2]*
t[2];
314 else if (stride == 6)
315 retval =
t[0]*
t[0] +
t[1]*
t[1] +
t[2]*
t[2]
316 + 2*
t[3]*
t[3] + 2*
t[4]*
t[4] + 2*
t[5]*
t[5];
339 cs_real_t v2 = v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
358template <
typename T,
typename U>
367 vout[0] = inv_norm * vin[0];
368 vout[1] = inv_norm * vin[1];
369 vout[2] = inv_norm * vin[2];
387template <
typename T,
typename U,
typename V>
393 mv[0] = m[0][0]*v[0] + m[0][1]*v[1] + m[0][2]*v[2];
394 mv[1] = m[1][0]*v[0] + m[1][1]*v[1] + m[1][2]*v[2];
395 mv[2] = m[2][0]*v[0] + m[2][1]*v[1] + m[2][2]*v[2];
414template <
typename T,
typename U,
typename V>
420 mv[0] = m[0]*v[0] + m[3]*v[1] + m[5]*v[2];
421 mv[1] = m[3]*v[0] + m[1]*v[1] + m[4]*v[2];
422 mv[2] = m[5]*v[0] + m[4]*v[1] + m[2]*v[2];
440template <
typename T,
typename U,
typename V>
447 for (
int i = 0; i < 3; i++)
448 v[i] += v_dot_n * n[i];
467template <
typename T,
typename U,
typename V>
474 = ( n1[0]*
t[0][0]*n2[0] + n1[1]*
t[1][0]*n2[0] + n1[2]*
t[2][0]*n2[0]
475 + n1[0]*
t[0][1]*n2[1] + n1[1]*
t[1][1]*n2[1] + n1[2]*
t[2][1]*n2[1]
476 + n1[0]*
t[0][2]*n2[2] + n1[1]*
t[1][2]*n2[2] + n1[2]*
t[2][2]*n2[2]);
495template <
typename T,
typename U,
typename V>
501 vout[0] = v[0]*(1.-n[0]*n[0])- v[1]* n[1]*n[0] - v[2]* n[2]*n[0];
502 vout[1] = -v[0]* n[0]*n[1] + v[1]*(1.-n[1]*n[1])- v[2]* n[2]*n[1];
503 vout[2] = -v[0]* n[0]*n[2] - v[1]* n[1]*n[2] + v[2]*(1.-n[2]*n[2]);
520template <
typename T,
typename U,
typename V>
526 uv[0] = u[1]*v[2] - u[2]*v[1];
527 uv[1] = u[2]*v[0] - u[0]*v[2];
528 uv[2] = u[0]*v[1] - u[1]*v[0];
540template <cs_lnum_t n,
typename T>
548 for (
size_t i = 0; i < n; i++) {
550 for (
size_t j = 0; j < n; j++) {
557 for (
size_t i = 0; i < n; i++) {
560 for (
size_t j = i+1; j < n; j++) {
568 for (
size_t j = 0; j < n; j++) {
570 T s = p_a[j][i] / p_a[i][i];
571 for (
size_t k = 0;
k < 2*n;
k++) {
572 p_a[j][
k] -= p_a[i][
k] * s;
580 for (
size_t i = 0; i < n; i++) {
581 T s = (T)1. / p_a[i][i];
582 for (
size_t j = 0; j < n; j++) {
583 b[i][j] = p_a[i][n+j] * s;
602 T
t[3][3] = {{a[0], a[3], a[5]},
722 return fmin(xmax, fmax(xmin, x));
730 return fminf(xmax, fmaxf(xmin, x));
783 const int n_iter = (
k > n-
k) ? n-
k :
k;
784 for (
int j = 1; j <= n_iter; j++, n--) {
787 else if (ret % j == 0)
975 v[0] = xb[0] - xa[0];
976 v[1] = xb[1] - xa[1];
977 v[2] = xb[2] - xa[2];
979 return sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
999 return ((xb[0] - xa[0])*xc[0]+(xb[1] - xa[1])*xc[1]+(xb[2] - xa[2])*xc[2]);
1022 return (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
1040 cs_real_t uv = u[0]*v[0] + u[1]*v[1] + u[2]*v[2];
1063 = ( n1[0]*
t[0][0]*n2[0] + n1[1]*
t[1][0]*n2[0] + n1[2]*
t[2][0]*n2[0]
1064 + n1[0]*
t[0][1]*n2[1] + n1[1]*
t[1][1]*n2[1] + n1[2]*
t[2][1]*n2[1]
1065 + n1[0]*
t[0][2]*n2[2] + n1[1]*
t[1][2]*n2[2] + n1[2]*
t[2][2]*n2[2]);
1090 return ( n1[0] * (
t[0]*n2[0] +
t[3]*n2[1] +
t[5]*n2[2])
1091 + n1[1] * (
t[3]*n2[0] +
t[1]*n2[1] +
t[4]*n2[2])
1092 + n1[2] * (
t[5]*n2[0] +
t[4]*n2[1] +
t[2]*n2[2]));
1108 return sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
1124 cs_real_t v2 = v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
1148 vout[0] = inv_norm * vin[0];
1149 vout[1] = inv_norm * vin[1];
1150 vout[2] = inv_norm * vin[2];
1173 cs_real_t inv_norm = ((norm > thres) ? 1. / norm : 1. / thres);
1175 vout[0] = inv_norm * vin[0];
1176 vout[1] = inv_norm * vin[1];
1177 vout[2] = inv_norm * vin[2];
1196 vout[0] = v[0]*(1.-n[0]*n[0])- v[1]* n[1]*n[0] - v[2]* n[2]*n[0];
1197 vout[1] = -v[0]* n[0]*n[1] + v[1]*(1.-n[1]*n[1])- v[2]* n[2]*n[1];
1198 vout[2] = -v[0]* n[0]*n[2] - v[1]* n[1]*n[2] + v[2]*(1.-n[2]*n[2]);
1219 ( n[0] *
t[0][0] * n[0] + n[1] *
t[1][0] * n[0] + n[2] *
t[2][0] * n[0]
1220 + n[0] *
t[0][1] * n[1] + n[1] *
t[1][1] * n[1] + n[2] *
t[2][1] * n[1]
1221 + n[0] *
t[0][2] * n[2] + n[1] *
t[1][2] * n[2] + n[2] *
t[2][2] * n[2]);
1222 for (
int i = 0; i < 3; i++) {
1223 for (
int j = 0; j < 3; j++)
1224 t[i][j] += n_t_n * n[i] * n[j];
1244 mv[0] += m[0][0]*v[0] + m[0][1]*v[1] + m[0][2]*v[2];
1245 mv[1] += m[1][0]*v[0] + m[1][1]*v[1] + m[1][2]*v[2];
1246 mv[2] += m[2][0]*v[0] + m[2][1]*v[1] + m[2][2]*v[2];
1265 mv[0] = m[0][0]*v[0] + m[1][0]*v[1] + m[2][0]*v[2];
1266 mv[1] = m[0][1]*v[0] + m[1][1]*v[1] + m[2][1]*v[2];
1267 mv[2] = m[0][2]*v[0] + m[1][2]*v[1] + m[2][2]*v[2];
1287 mv[0] = m[0]*v[0] + m[3]*v[1] + m[5]*v[2];
1288 mv[1] = m[3]*v[0] + m[1]*v[1] + m[4]*v[2];
1289 mv[2] = m[5]*v[0] + m[4]*v[1] + m[2]*v[2];
1309 mv[0] += m[0] * v[0] + m[3] * v[1] + m[5] * v[2];
1310 mv[1] += m[3] * v[0] + m[1] * v[1] + m[4] * v[2];
1311 mv[2] += m[5] * v[0] + m[4] * v[1] + m[2] * v[2];
1330 return m1[0]*m2[0] + 2.*m1[3]*m2[3] + 2.*m1[5]*m2[5]
1331 + m1[1]*m2[1] + 2.*m1[4]*m2[4]
1348 return (
t[0] +
t[1] +
t[2]);
1367 for (
int i = 0; i < 6; i++) {
1368 for (
int j = 0; j < 6; j++)
1369 mv[i] = m[i][j] * v[j];
1389 for (
int i = 0; i < 6; i++) {
1390 for (
int j = 0; j < 6; j++)
1391 mv[i] += m[i][j] * v[j];
1408 const cs_real_t com0 = m[1][1]*m[2][2] - m[2][1]*m[1][2];
1409 const cs_real_t com1 = m[2][1]*m[0][2] - m[0][1]*m[2][2];
1410 const cs_real_t com2 = m[0][1]*m[1][2] - m[1][1]*m[0][2];
1412 return m[0][0]*com0 + m[1][0]*com1 + m[2][0]*com2;
1428 const cs_real_t com0 = m[1]*m[2] - m[4]*m[4];
1429 const cs_real_t com1 = m[4]*m[5] - m[3]*m[2];
1430 const cs_real_t com2 = m[3]*m[4] - m[1]*m[5];
1432 return m[0]*com0 + m[3]*com1 + m[5]*com2;
1450 uv[0] = (u[0] + v[0]) / 2.0;
1451 uv[1] = (u[1] + v[1]) / 2.0;
1452 uv[2] = (u[2] + v[2]) / 2.0;
1465#if defined(__INTEL_COMPILER)
1466#pragma optimization_level 0
1474 uv[0] = u[1]*v[2] - u[2]*v[1];
1475 uv[1] = u[2]*v[0] - u[0]*v[2];
1476 uv[2] = u[0]*v[1] - u[1]*v[0];
1491#if defined(__INTEL_COMPILER)
1492#pragma optimization_level 0
1500 return (u[1]*v[2] - u[2]*v[1]) * w[0]
1501 + (u[2]*v[0] - u[0]*v[2]) * w[1]
1502 + (u[0]*v[1] - u[1]*v[0]) * w[2];
1558 out[0][0] = in[1][1]*in[2][2] - in[2][1]*in[1][2];
1559 out[0][1] = in[2][1]*in[0][2] - in[0][1]*in[2][2];
1560 out[0][2] = in[0][1]*in[1][2] - in[1][1]*in[0][2];
1562 out[1][0] = in[2][0]*in[1][2] - in[1][0]*in[2][2];
1563 out[1][1] = in[0][0]*in[2][2] - in[2][0]*in[0][2];
1564 out[1][2] = in[1][0]*in[0][2] - in[0][0]*in[1][2];
1566 out[2][0] = in[1][0]*in[2][1] - in[2][0]*in[1][1];
1567 out[2][1] = in[2][0]*in[0][1] - in[0][0]*in[2][1];
1568 out[2][2] = in[0][0]*in[1][1] - in[1][0]*in[0][1];
1570 const double det = in[0][0]*out[0][0]+in[1][0]*out[0][1]+in[2][0]*out[0][2];
1571 const double invdet = 1./det;
1573 out[0][0] *= invdet, out[0][1] *= invdet, out[0][2] *= invdet;
1574 out[1][0] *= invdet, out[1][1] *= invdet, out[1][2] *= invdet;
1575 out[2][0] *= invdet, out[2][1] *= invdet, out[2][2] *= invdet;
1589 cs_real_t a00 = a[1][1]*a[2][2] - a[2][1]*a[1][2];
1590 cs_real_t a01 = a[2][1]*a[0][2] - a[0][1]*a[2][2];
1591 cs_real_t a02 = a[0][1]*a[1][2] - a[1][1]*a[0][2];
1592 cs_real_t a10 = a[2][0]*a[1][2] - a[1][0]*a[2][2];
1593 cs_real_t a11 = a[0][0]*a[2][2] - a[2][0]*a[0][2];
1594 cs_real_t a12 = a[1][0]*a[0][2] - a[0][0]*a[1][2];
1595 cs_real_t a20 = a[1][0]*a[2][1] - a[2][0]*a[1][1];
1596 cs_real_t a21 = a[2][0]*a[0][1] - a[0][0]*a[2][1];
1597 cs_real_t a22 = a[0][0]*a[1][1] - a[1][0]*a[0][1];
1599 double det_inv = 1. / (a[0][0]*a00 + a[1][0]*a01 + a[2][0]*a02);
1601 a[0][0] = a00 * det_inv;
1602 a[0][1] = a01 * det_inv;
1603 a[0][2] = a02 * det_inv;
1604 a[1][0] = a10 * det_inv;
1605 a[1][1] = a11 * det_inv;
1606 a[1][2] = a12 * det_inv;
1607 a[2][0] = a20 * det_inv;
1608 a[2][1] = a21 * det_inv;
1609 a[2][2] = a22 * det_inv;
1624 cs_real_t a00 = a[1][1]*a[2][2] - a[2][1]*a[1][2];
1625 cs_real_t a01 = a[2][1]*a[0][2] - a[0][1]*a[2][2];
1626 cs_real_t a02 = a[0][1]*a[1][2] - a[1][1]*a[0][2];
1627 cs_real_t a11 = a[0][0]*a[2][2] - a[2][0]*a[0][2];
1628 cs_real_t a12 = a[1][0]*a[0][2] - a[0][0]*a[1][2];
1629 cs_real_t a22 = a[0][0]*a[1][1] - a[1][0]*a[0][1];
1631 double det_inv = 1. / (a[0][0]*a00 + a[1][0]*a01 + a[2][0]*a02);
1633 a[0][0] = a00 * det_inv;
1634 a[0][1] = a01 * det_inv;
1635 a[0][2] = a02 * det_inv;
1636 a[1][0] = a01 * det_inv;
1637 a[1][1] = a11 * det_inv;
1638 a[1][2] = a12 * det_inv;
1639 a[2][0] = a02 * det_inv;
1640 a[2][1] = a12 * det_inv;
1641 a[2][2] = a22 * det_inv;
1662 sout[0] = s[1]*s[2] - s[4]*s[4];
1663 sout[1] = s[0]*s[2] - s[5]*s[5];
1664 sout[2] = s[0]*s[1] - s[3]*s[3];
1665 sout[3] = s[4]*s[5] - s[3]*s[2];
1666 sout[4] = s[3]*s[5] - s[0]*s[4];
1667 sout[5] = s[3]*s[4] - s[1]*s[5];
1669 detinv = 1. / (s[0]*sout[0] + s[3]*sout[3] + s[5]*sout[5]);
1694 mout[0][0] = m1[0][0]*m2[0][0] + m1[0][1]*m2[1][0] + m1[0][2]*m2[2][0];
1695 mout[0][1] = m1[0][0]*m2[0][1] + m1[0][1]*m2[1][1] + m1[0][2]*m2[2][1];
1696 mout[0][2] = m1[0][0]*m2[0][2] + m1[0][1]*m2[1][2] + m1[0][2]*m2[2][2];
1698 mout[1][0] = m1[1][0]*m2[0][0] + m1[1][1]*m2[1][0] + m1[1][2]*m2[2][0];
1699 mout[1][1] = m1[1][0]*m2[0][1] + m1[1][1]*m2[1][1] + m1[1][2]*m2[2][1];
1700 mout[1][2] = m1[1][0]*m2[0][2] + m1[1][1]*m2[1][2] + m1[1][2]*m2[2][2];
1702 mout[2][0] = m1[2][0]*m2[0][0] + m1[2][1]*m2[1][0] + m1[2][2]*m2[2][0];
1703 mout[2][1] = m1[2][0]*m2[0][1] + m1[2][1]*m2[1][1] + m1[2][2]*m2[2][1];
1704 mout[2][2] = m1[2][0]*m2[0][2] + m1[2][1]*m2[1][2] + m1[2][2]*m2[2][2];
1725 _m[0][0] = m[0][0]*q[0][0] + m[0][1]*q[1][0] + m[0][2]*q[2][0];
1726 _m[0][1] = m[0][0]*q[0][1] + m[0][1]*q[1][1] + m[0][2]*q[2][1];
1727 _m[0][2] = m[0][0]*q[0][2] + m[0][1]*q[1][2] + m[0][2]*q[2][2];
1729 _m[1][0] = m[1][0]*q[0][0] + m[1][1]*q[1][0] + m[1][2]*q[2][0];
1730 _m[1][1] = m[1][0]*q[0][1] + m[1][1]*q[1][1] + m[1][2]*q[2][1];
1731 _m[1][2] = m[1][0]*q[0][2] + m[1][1]*q[1][2] + m[1][2]*q[2][2];
1733 _m[2][0] = m[2][0]*q[0][0] + m[2][1]*q[1][0] + m[2][2]*q[2][0];
1734 _m[2][1] = m[2][0]*q[0][1] + m[2][1]*q[1][1] + m[2][2]*q[2][1];
1735 _m[2][2] = m[2][0]*q[0][2] + m[2][1]*q[1][2] + m[2][2]*q[2][2];
1738 mout[0][0] = q[0][0]*_m[0][0] + q[1][0]*_m[1][0] + q[2][0]*_m[2][0];
1739 mout[0][1] = q[0][0]*_m[0][1] + q[1][0]*_m[1][1] + q[2][0]*_m[2][1];
1740 mout[0][2] = q[0][0]*_m[0][2] + q[1][0]*_m[1][2] + q[2][0]*_m[2][2];
1742 mout[1][0] = q[0][1]*_m[0][0] + q[1][1]*_m[1][0] + q[2][1]*_m[2][0];
1743 mout[1][1] = q[0][1]*_m[0][1] + q[1][1]*_m[1][1] + q[2][1]*_m[2][1];
1744 mout[1][2] = q[0][1]*_m[0][2] + q[1][1]*_m[1][2] + q[2][1]*_m[2][2];
1746 mout[2][0] = q[0][2]*_m[0][0] + q[1][2]*_m[1][0] + q[2][2]*_m[2][0];
1747 mout[2][1] = q[0][2]*_m[0][1] + q[1][2]*_m[1][1] + q[2][2]*_m[2][1];
1748 mout[2][2] = q[0][2]*_m[0][2] + q[1][2]*_m[1][2] + q[2][2]*_m[2][2];
1769 _m[0][0] = m[0]*q[0][0] + m[3]*q[1][0] + m[5]*q[2][0];
1770 _m[0][1] = m[0]*q[0][1] + m[3]*q[1][1] + m[5]*q[2][1];
1771 _m[0][2] = m[0]*q[0][2] + m[3]*q[1][2] + m[5]*q[2][2];
1773 _m[1][0] = m[3]*q[0][0] + m[1]*q[1][0] + m[4]*q[2][0];
1774 _m[1][1] = m[3]*q[0][1] + m[1]*q[1][1] + m[4]*q[2][1];
1775 _m[1][2] = m[3]*q[0][2] + m[1]*q[1][2] + m[4]*q[2][2];
1777 _m[2][0] = m[5]*q[0][0] + m[4]*q[1][0] + m[2]*q[2][0];
1778 _m[2][1] = m[5]*q[0][1] + m[4]*q[1][1] + m[2]*q[2][1];
1779 _m[2][2] = m[5]*q[0][2] + m[4]*q[1][2] + m[2]*q[2][2];
1782 mout[0] = q[0][0]*_m[0][0] + q[1][0]*_m[1][0] + q[2][0]*_m[2][0];
1783 mout[1] = q[0][1]*_m[0][1] + q[1][1]*_m[1][1] + q[2][1]*_m[2][1];
1784 mout[2] = q[0][2]*_m[0][2] + q[1][2]*_m[1][2] + q[2][2]*_m[2][2];
1786 mout[3] = q[0][0]*_m[0][1] + q[1][0]*_m[1][1] + q[2][0]*_m[2][1];
1787 mout[4] = q[0][1]*_m[0][2] + q[1][1]*_m[1][2] + q[2][1]*_m[2][2];
1788 mout[5] = q[0][0]*_m[0][2] + q[1][0]*_m[1][2] + q[2][0]*_m[2][2];
1809 _m[0][0] = m[0][0]*q[0][0] + m[0][1]*q[0][1] + m[0][2]*q[0][2];
1810 _m[0][1] = m[0][0]*q[1][0] + m[0][1]*q[1][1] + m[0][2]*q[1][2];
1811 _m[0][2] = m[0][0]*q[2][0] + m[0][1]*q[2][1] + m[0][2]*q[2][2];
1813 _m[1][0] = m[1][0]*q[0][0] + m[1][1]*q[0][1] + m[1][2]*q[0][2];
1814 _m[1][1] = m[1][0]*q[1][0] + m[1][1]*q[1][1] + m[1][2]*q[1][2];
1815 _m[1][2] = m[1][0]*q[2][0] + m[1][1]*q[2][1] + m[1][2]*q[2][2];
1817 _m[2][0] = m[2][0]*q[0][0] + m[2][1]*q[0][1] + m[2][2]*q[0][2];
1818 _m[2][1] = m[2][0]*q[1][0] + m[2][1]*q[1][1] + m[2][2]*q[1][2];
1819 _m[2][2] = m[2][0]*q[2][0] + m[2][1]*q[2][1] + m[2][2]*q[2][2];
1822 mout[0][0] = q[0][0]*_m[0][0] + q[0][1]*_m[1][0] + q[0][2]*_m[2][0];
1823 mout[0][1] = q[0][0]*_m[0][1] + q[0][1]*_m[1][1] + q[0][2]*_m[2][1];
1824 mout[0][2] = q[0][0]*_m[0][2] + q[0][1]*_m[1][2] + q[0][2]*_m[2][2];
1826 mout[1][0] = q[1][0]*_m[0][0] + q[1][1]*_m[1][0] + q[1][2]*_m[2][0];
1827 mout[1][1] = q[1][0]*_m[0][1] + q[1][1]*_m[1][1] + q[1][2]*_m[2][1];
1828 mout[1][2] = q[1][0]*_m[0][2] + q[1][1]*_m[1][2] + q[1][2]*_m[2][2];
1830 mout[2][0] = q[2][0]*_m[0][0] + q[2][1]*_m[1][0] + q[2][2]*_m[2][0];
1831 mout[2][1] = q[2][0]*_m[0][1] + q[2][1]*_m[1][1] + q[2][2]*_m[2][1];
1832 mout[2][2] = q[2][0]*_m[0][2] + q[2][1]*_m[1][2] + q[2][2]*_m[2][2];
1853 _m[0][0] = m[0]*q[0][0] + m[3]*q[0][1] + m[5]*q[0][2];
1854 _m[0][1] = m[0]*q[1][0] + m[3]*q[1][1] + m[5]*q[1][2];
1855 _m[0][2] = m[0]*q[2][0] + m[3]*q[2][1] + m[5]*q[2][2];
1857 _m[1][0] = m[3]*q[0][0] + m[1]*q[0][1] + m[4]*q[0][2];
1858 _m[1][1] = m[3]*q[1][0] + m[1]*q[1][1] + m[4]*q[1][2];
1859 _m[1][2] = m[3]*q[2][0] + m[1]*q[2][1] + m[4]*q[2][2];
1861 _m[2][0] = m[5]*q[0][0] + m[4]*q[0][1] + m[2]*q[0][2];
1862 _m[2][1] = m[5]*q[1][0] + m[4]*q[1][1] + m[2]*q[1][2];
1863 _m[2][2] = m[5]*q[2][0] + m[4]*q[2][1] + m[2]*q[2][2];
1866 mout[0] = q[0][0]*_m[0][0] + q[0][1]*_m[1][0] + q[0][2]*_m[2][0];
1867 mout[1] = q[1][0]*_m[0][1] + q[1][1]*_m[1][1] + q[1][2]*_m[2][1];
1868 mout[2] = q[2][0]*_m[0][2] + q[2][1]*_m[1][2] + q[2][2]*_m[2][2];
1871 mout[3] = q[0][0]*_m[0][1] + q[0][1]*_m[1][1] + q[0][2]*_m[2][1];
1872 mout[4] = q[1][0]*_m[0][2] + q[1][1]*_m[1][2] + q[1][2]*_m[2][2];
1873 mout[5] = q[0][0]*_m[0][2] + q[0][1]*_m[1][2] + q[0][2]*_m[2][2];
1893 m_sym[0][0] = 0.5 * (m[0][0] + m[0][0]);
1894 m_sym[0][1] = 0.5 * (m[0][1] + m[1][0]);
1895 m_sym[0][2] = 0.5 * (m[0][2] + m[2][0]);
1896 m_sym[1][0] = 0.5 * (m[1][0] + m[0][1]);
1897 m_sym[1][1] = 0.5 * (m[1][1] + m[1][1]);
1898 m_sym[1][2] = 0.5 * (m[1][2] + m[2][1]);
1899 m_sym[2][0] = 0.5 * (m[2][0] + m[0][2]);
1900 m_sym[2][1] = 0.5 * (m[2][1] + m[1][2]);
1901 m_sym[2][2] = 0.5 * (m[2][2] + m[2][2]);
1904 m_ant[0][0] = 0.5 * (m[0][0] - m[0][0]);
1905 m_ant[0][1] = 0.5 * (m[0][1] - m[1][0]);
1906 m_ant[0][2] = 0.5 * (m[0][2] - m[2][0]);
1907 m_ant[1][0] = 0.5 * (m[1][0] - m[0][1]);
1908 m_ant[1][1] = 0.5 * (m[1][1] - m[1][1]);
1909 m_ant[1][2] = 0.5 * (m[1][2] - m[2][1]);
1910 m_ant[2][0] = 0.5 * (m[2][0] - m[0][2]);
1911 m_ant[2][1] = 0.5 * (m[2][1] - m[1][2]);
1912 m_ant[2][2] = 0.5 * (m[2][2] - m[2][2]);
1953 mout[0][0] += m1[0][0]*m2[0][0] + m1[0][1]*m2[1][0] + m1[0][2]*m2[2][0];
1954 mout[0][1] += m1[0][0]*m2[0][1] + m1[0][1]*m2[1][1] + m1[0][2]*m2[2][1];
1955 mout[0][2] += m1[0][0]*m2[0][2] + m1[0][1]*m2[1][2] + m1[0][2]*m2[2][2];
1957 mout[1][0] += m1[1][0]*m2[0][0] + m1[1][1]*m2[1][0] + m1[1][2]*m2[2][0];
1958 mout[1][1] += m1[1][0]*m2[0][1] + m1[1][1]*m2[1][1] + m1[1][2]*m2[2][1];
1959 mout[1][2] += m1[1][0]*m2[0][2] + m1[1][1]*m2[1][2] + m1[1][2]*m2[2][2];
1961 mout[2][0] += m1[2][0]*m2[0][0] + m1[2][1]*m2[1][0] + m1[2][2]*m2[2][0];
1962 mout[2][1] += m1[2][0]*m2[0][1] + m1[2][1]*m2[1][1] + m1[2][2]*m2[2][1];
1963 mout[2][2] += m1[2][0]*m2[0][2] + m1[2][1]*m2[1][2] + m1[2][2]*m2[2][2];
1988 sout[0] = s1[0]*s2[0] + s1[3]*s2[3] + s1[5]*s2[5];
1990 sout[1] = s1[3]*s2[3] + s1[1]*s2[1] + s1[4]*s2[4];
1992 sout[2] = s1[5]*s2[5] + s1[4]*s2[4] + s1[2]*s2[2];
1994 sout[3] = s1[0]*s2[3] + s1[3]*s2[1] + s1[5]*s2[4];
1996 sout[4] = s1[3]*s2[5] + s1[1]*s2[4] + s1[4]*s2[2];
1998 sout[5] = s1[0]*s2[5] + s1[3]*s2[4] + s1[5]*s2[2];
2021 if (fabs(1.+m[0][0]+m[1][1]+m[2][2]) > 1.0e-12) {
2023 e[0] = 0.5*sqrt(1+m[0][0]+m[1][1]+m[2][2]);
2024 e[1] = 0.25*(m[2][1]-m[1][2])/e[0];
2025 e[2] = 0.25*(m[0][2]-m[2][0])/e[0];
2026 e[3] = 0.25*(m[1][0]-m[0][1])/e[0];
2028 else if (fabs(1+m[0][0]-m[1][1]-m[2][2]) > 1.0e-12) {
2030 e[1] = 0.5*sqrt(1+m[0][0]-m[1][1]-m[2][2]);
2031 e[0] = 0.25*(m[2][1]-m[1][2])/e[1];
2032 e[2] = 0.25*(m[1][0]+m[0][1])/e[1];
2033 e[3] = 0.25*(m[0][2]+m[2][0])/e[1];
2035 else if (fabs(1-m[0][0]+m[1][1]-m[2][2]) > 1.0e-12) {
2037 e[2] = 0.5*sqrt(1-m[0][0]+m[1][1]-m[2][2]);
2038 e[0] = 0.25*(m[0][2]-m[2][0])/e[2];
2039 e[1] = 0.25*(m[1][0]+m[0][1])/e[2];
2040 e[3] = 0.25*(m[2][1]+m[1][2])/e[2];
2042 else if (fabs(1-m[0][0]-m[1][1]+m[2][2]) > 1.0e-12) {
2044 e[3] = 0.5*sqrt(1-m[0][0]-m[1][1]+m[2][2]);
2045 e[0] = 0.25*(m[1][0]-m[0][1])/e[3];
2046 e[1] = 0.25*(m[0][2]+m[2][0])/e[3];
2047 e[2] = 0.25*(m[2][1]+m[1][2])/e[3];
2070 m[0][0] = 2.*(e[0]*e[0]+e[1]*e[1]-0.5);
2071 m[0][1] = 2.*(e[1]*e[2]+e[0]*e[3]);
2072 m[0][2] = 2.*(e[1]*e[3]-e[0]*e[2]);
2073 m[1][0] = 2.*(e[1]*e[2]-e[0]*e[3]);
2074 m[1][1] = 2.*(e[0]*e[0]+e[2]*e[2]-0.5);
2075 m[1][2] = 2.*(e[2]*e[3]+e[0]*e[1]);
2076 m[2][0] = 2.*(e[1]*e[3]+e[0]*e[2]);
2077 m[2][1] = 2.*(e[2]*e[3]-e[0]*e[1]);
2078 m[2][2] = 2.*(e[0]*e[0]+e[3]*e[3]-0.5);
2107 cs_real_t dir_p_dir_r[3] = {dir[0] + dir_r[0],
2124 euler[1] = n_rot[0];
2125 euler[2] = n_rot[1];
2126 euler[3] = n_rot[2];
2143 const int t2v[3][3] = {{0, 3, 5},
2147 const int iv2t[6] = {0, 1, 2, 0, 1, 0};
2148 const int jv2t[6] = {0, 1, 2, 1, 2, 2};
2150 for (
int i = 0; i < 6; i++) {
2151 for (
int j = 0; j < 6; j++)
2164 for (
int ij = 0; ij < 6; ij++) {
2167 for (
int k = 0;
k < 3;
k++) {
2171 sout[ij][ik] += s[j][
k];
2172 sout[ij][jk] += s[i][
k];
2200 _sout[0][0] = s1[0]*s2[0] + s1[3]*s2[3] + s1[5]*s2[5];
2202 _sout[1][1] = s1[3]*s2[3] + s1[1]*s2[1] + s1[4]*s2[4];
2204 _sout[2][2] = s1[5]*s2[5] + s1[4]*s2[4] + s1[2]*s2[2];
2206 _sout[0][1] = s1[0]*s2[3] + s1[3]*s2[1] + s1[5]*s2[4];
2208 _sout[1][0] = s2[0]*s1[3] + s2[3]*s1[1] + s2[5]*s1[4];
2210 _sout[1][2] = s1[3]*s2[5] + s1[1]*s2[4] + s1[4]*s2[2];
2212 _sout[2][1] = s2[3]*s1[5] + s2[1]*s1[4] + s2[4]*s1[2];
2214 _sout[0][2] = s1[0]*s2[5] + s1[3]*s2[4] + s1[5]*s2[2];
2216 _sout[2][0] = s2[0]*s1[5] + s2[3]*s1[4] + s2[5]*s1[2];
2218 sout[0][0] = _sout[0][0]*s3[0] + _sout[0][1]*s3[3] + _sout[0][2]*s3[5];
2220 sout[1][1] = _sout[1][0]*s3[3] + _sout[1][1]*s3[1] + _sout[1][2]*s3[4];
2222 sout[2][2] = _sout[2][0]*s3[5] + _sout[2][1]*s3[4] + _sout[2][2]*s3[2];
2224 sout[0][1] = _sout[0][0]*s3[3] + _sout[0][1]*s3[1] + _sout[0][2]*s3[4];
2226 sout[1][0] = s3[0]*_sout[1][0] + s3[3]*_sout[1][1] + s3[5]*_sout[1][2];
2228 sout[1][2] = _sout[1][0]*s3[5] + _sout[1][1]*s3[4] + _sout[1][2]*s3[2];
2230 sout[2][1] = s3[3]*_sout[2][0] + s3[1]*_sout[2][1] + s3[4]*_sout[2][2];
2232 sout[0][2] = _sout[0][0]*s3[5] + _sout[0][1]*s3[4] + _sout[0][2]*s3[2];
2234 sout[2][0] = s3[0]*_sout[2][0] + s3[3]*_sout[2][1] + s3[5]*_sout[2][2];
2250 cs_real_t magnitude = sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]);
2252 qv->
meas = magnitude;
2256 qv->
unitv[0] = inv * v[0];
2257 qv->
unitv[1] = inv * v[1];
2258 qv->
unitv[2] = inv * v[2];
2292 const cs_real_t d11 = ldlt[2] - l10*l10*d00;
2295 const cs_real_t l21 = (ldlt[4] - l20*d00*l10) * f11;
2296 const cs_real_t l31 = (ldlt[7] - l30*d00*l10) * f11;
2299 const cs_real_t d22 = ldlt[5] - l20*d00*l20 - l21*d11*l21;
2302 const cs_real_t l32 = (ldlt[8] - l30*d00*l20 - l31*d11*l21) * f22;
2305 const cs_real_t d33 = ldlt[9] - l30*d00*l30 - l31*d11*l31 - l32*d22*l32;
2346 x[1] = rhs[1] - x[0]*ldlt[1];
2347 x[2] = rhs[2] - x[0]*ldlt[3] - x[1]*ldlt[4];
2348 x[3] = rhs[3] - x[0]*ldlt[6] - x[1]*ldlt[7] - x[2]*ldlt[8];
2350 x[3] = x[3]*ldlt[9];
#define restrict
Definition: cs_defs.h:148
#define BEGIN_C_DECLS
Definition: cs_defs.h:528
#define CS_F_HOST_DEVICE
Definition: cs_defs.h:555
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:349
cs_real_t cs_real_6_t[6]
vector of 6 floating-point values
Definition: cs_defs.h:351
#define END_C_DECLS
Definition: cs_defs.h:529
cs_real_t cs_real_33_t[3][3]
3x3 matrix of floating-point values
Definition: cs_defs.h:358
@ t
Definition: cs_field_pointer.h:91
@ k
Definition: cs_field_pointer.h:68
@ x2
Definition: cs_field_pointer.h:199
CS_F_HOST_DEVICE void cs_math_33_normal_scaling_add(const cs_real_t n[3], cs_real_t factor, cs_real_t t[3][3])
Add the dot product with a normal vector to the normal,normal component of a tensor: t += factor * n....
Definition: cs_math.h:1214
CS_F_HOST_DEVICE cs_real_t cs_math_3_dot_product(const T u[3], const U v[3])
Compute the dot product of two vectors of 3 real values.
Definition: cs_math.h:194
CS_F_HOST_DEVICE cs_real_t cs_math_square_norm(const cs_real_t t[stride])
Compute a square norm associated with a vector or tensor.
Definition: cs_math.h:308
CS_F_HOST_DEVICE void cs_nvec3(const cs_real_t v[3], cs_nvec3_t *qv)
Define a cs_nvec3_t structure from a cs_real_3_t.
Definition: cs_math.h:2247
CS_F_HOST_DEVICE void cs_math_3_average(const cs_real_t u[3], const cs_real_t v[3], cs_real_t *restrict uv)
Compute the average of two vector of dimension 3.
Definition: cs_math.h:1446
static constexpr double cs_dbl_max
Definition: cs_math.h:99
CS_F_HOST_DEVICE void cs_math_sym_33_transform_a_to_r(const cs_real_t m[6], const cs_real_t q[3][3], cs_real_t mout[6])
Compute transformation from absolute to relative reference frame Q M Q^t.
Definition: cs_math.h:1847
CS_F_HOST_DEVICE cs_real_t cs_math_sym_33_determinant(const cs_real_t m[6])
Compute the determinant of a 3x3 symmetric matrix.
Definition: cs_math.h:1426
CS_F_HOST_DEVICE cs_real_t cs_math_sym_44_partial_solve_ldlt(const cs_real_t ldlt[10], const cs_real_t rhs[4])
LDL^T: Modified Cholesky decomposition of a 4x4 SPD matrix. For more reference, see for instance http...
Definition: cs_math.h:2337
CS_F_HOST_DEVICE void cs_math_33_inv_cramer_in_place(cs_real_t a[3][3])
Inverse a 3x3 matrix in place, using Cramer's rule.
Definition: cs_math.h:1587
CS_F_HOST_DEVICE cs_real_t cs_math_pow4(cs_real_t x)
Compute the 4-th power of a real value.
Definition: cs_math.h:934
static constexpr cs_real_6_t cs_math_sym_33_identity
Definition: cs_math.h:124
static constexpr cs_real_t cs_math_1ov6
Definition: cs_math.h:117
CS_F_HOST_DEVICE cs_real_t cs_math_3_distance_dot_product(const T xa[3], const T xb[3], const U xc[3])
Compute .
Definition: cs_math.h:171
static constexpr cs_real_t cs_math_1ov24
Definition: cs_math.h:119
void cs_math_33_eig_val_vec(const cs_real_t m_in[3][3], const cs_real_t tol_err, cs_real_t eig_val[3], cs_real_t eig_vec[3][3])
Evaluate eigenvalues and eigenvectors of a real symmetric matrix m1[3,3]: m1*m2 = lambda*m2.
CS_F_HOST_DEVICE void cs_math_sym_44_factor_ldlt(cs_real_t ldlt[10])
LDL^T: Modified Cholesky decomposition of a 4x4 SPD matrix. For more reference, see for instance http...
Definition: cs_math.h:2278
static constexpr cs_real_t cs_math_epzero
Definition: cs_math.h:102
double cs_math_surftri(const cs_real_t xv[3], const cs_real_t xe[3], const cs_real_t xf[3])
Compute the area of the convex_hull generated by 3 points. This corresponds to the computation of the...
Definition: cs_math.cpp:336
CS_F_HOST_DEVICE cs_real_t cs_math_sym_33_sym_33_product_trace(const cs_real_t m1[6], const cs_real_t m2[6])
Compute the product of two symmetric matrices of 3x3 real values and take the trace....
Definition: cs_math.h:1327
CS_F_HOST_DEVICE void cs_math_33_product_add(const cs_real_t m1[3][3], const cs_real_t m2[3][3], cs_real_t(*restrict mout)[3])
Add the product of two 3x3 real matrices to a matrix.
Definition: cs_math.h:1949
CS_F_HOST_DEVICE T cs_math_sq(T x)
Compute the square of a real value.
Definition: cs_math.h:149
CS_F_HOST_DEVICE void cs_math_3_normalize_threshold(const cs_real_t vin[3], const cs_real_t thres, cs_real_t vout[3])
Normalise a vector of 3 real values and clip the norm using a threshold value.
Definition: cs_math.h:1167
static constexpr double cs_dbl_min
Definition: cs_math.h:96
static constexpr double cs_dbl_epsilon
Definition: cs_math.h:93
CS_F_HOST_DEVICE void cs_math_33_transform_a_to_r(const cs_real_t m[3][3], const cs_real_t q[3][3], cs_real_t mout[3][3])
Compute transformation from absolute to relative reference frame Q M Q^t.
Definition: cs_math.h:1803
CS_F_HOST_DEVICE cs_real_t cs_math_3_distance(const cs_real_t xa[3], const cs_real_t xb[3])
Compute the (euclidean) distance between two points xa and xb in a Cartesian coordinate system of dim...
Definition: cs_math.h:970
CS_F_HOST_DEVICE void cs_math_reduce_sym_prod_33_to_66(const cs_real_t s[3][3], cs_real_t(*restrict sout)[6])
Compute a 6x6 matrix A, equivalent to a 3x3 matrix s, such as: A*R_6 = R*s^t + s*R.
Definition: cs_math.h:2140
CS_F_HOST_DEVICE void cs_math_33t_3_product(const cs_real_t m[3][3], const cs_real_t v[3], cs_real_t *restrict mv)
Compute the product of the transpose of a matrix of 3x3 real values by a vector of 3 real values.
Definition: cs_math.h:1261
static constexpr cs_real_t cs_math_zero_threshold
Definition: cs_math.h:90
CS_F_HOST_DEVICE void cs_math_66_6_product_add(const cs_real_t m[6][6], const cs_real_t v[6], cs_real_t *restrict mv)
Compute the product of a matrix of 6x6 real values by a vector of 6 real values and add it to the vec...
Definition: cs_math.h:1385
CS_F_HOST_DEVICE cs_real_t cs_math_6_trace(const cs_real_t t[6])
Compute the trace of a symmetric tensor.
Definition: cs_math.h:1346
static constexpr cs_real_33_t cs_math_33_identity
Definition: cs_math.h:121
void cs_math_sym_33_eigen(const cs_real_t m[6], cs_real_t eig_vals[3])
Compute all eigenvalues of a 3x3 symmetric matrix with symmetric storage.
Definition: cs_math.cpp:124
CS_F_HOST_DEVICE void cs_math_33_rotation_into_quaternions(const cs_real_t m[3][3], cs_real_t e[4])
Compute the 4 Euler parameters (defining a quaternion) knowing the rotation matrix m Based on: J....
Definition: cs_math.h:2017
CS_F_HOST_DEVICE void cs_math_sym_33_3_product(const T m[6], const U v[3], V *restrict mv)
Compute the product of a symmetric matrix of 3x3 real values by a vector of 3 real values....
Definition: cs_math.h:416
CS_F_HOST_DEVICE void cs_math_3_orthonormal_basis(const cs_real_t vect[3], cs_real_t axes[3][3])
Build an orthonormal basis based on a first vector "vect". axes[0] is vect normalized,...
Definition: cs_math.h:1518
CS_F_HOST_DEVICE cs_real_t cs_math_pow5(cs_real_t x)
Compute the 5-th power of a real value.
Definition: cs_math.h:951
CS_F_HOST_DEVICE void cs_math_matrix_gauss_inverse(const T a[n][n], T b[n][n])
Inverse square, dense matrix using Gauss-Jordan elimination.
Definition: cs_math.h:542
CS_F_HOST_DEVICE void cs_math_33_3_product_add(const cs_real_t m[3][3], const cs_real_t v[3], cs_real_t *restrict mv)
Compute the product of a matrix of 3x3 real values by a vector of 3 real values add.
Definition: cs_math.h:1240
void cs_math_fw_and_bw_lu(const cs_real_t a_lu[], const int n, cs_real_t x[], const cs_real_t b[])
Compute forward and backward to solve an LU P*P system.
Definition: cs_math.cpp:584
static constexpr cs_real_t cs_math_1ov12
Definition: cs_math.h:118
CS_F_HOST_DEVICE cs_real_t cs_math_3_triple_product(const cs_real_t u[3], const cs_real_t v[3], const cs_real_t w[3])
Compute the triple product.
Definition: cs_math.h:1496
CS_F_HOST_DEVICE void cs_math_33_inv_cramer_sym_in_place(cs_real_t a[3][3])
Inverse a 3x3 symmetric matrix (with non-symmetric storage) in place, using Cramer's rule.
Definition: cs_math.h:1622
CS_F_HOST_DEVICE cs_real_t cs_math_clamp(cs_real_t x, cs_real_t xmin, cs_real_t xmax)
Clamp function for a given scalar value.
Definition: cs_math.h:866
int cs_math_binom(int n, int k)
Computes the binomial coefficient of n and k.
Definition: cs_math.h:777
CS_F_HOST_DEVICE cs_real_t cs_math_33_determinant(const cs_real_t m[3][3])
Compute the determinant of a 3x3 matrix.
Definition: cs_math.h:1406
CS_F_HOST_DEVICE cs_real_t cs_math_fmax(cs_real_t x, cs_real_t y)
Compute the max value of two real values.
Definition: cs_math.h:844
CS_F_HOST_DEVICE void cs_math_33_3_product(const T m[3][3], const U v[3], V *restrict mv)
Compute the product of a matrix of 3x3 real values by a vector of 3 real values.
Definition: cs_math.h:389
void cs_math_33_eigen(const cs_real_t m[3][3], cs_real_t *eig_ratio, cs_real_t *eig_max)
Compute max/min eigenvalues ratio and max. eigenvalue of a 3x3 symmetric matrix with non-symmetric st...
Definition: cs_math.cpp:213
CS_F_HOST_DEVICE cs_real_t cs_math_pow3(cs_real_t x)
Compute the cube of a real value.
Definition: cs_math.h:918
static constexpr cs_real_t cs_math_infinite_r
Definition: cs_math.h:105
CS_F_HOST_DEVICE void cs_math_3_normalize(const T vin[3], U vout[3])
Normalise a vector of 3 real values.
Definition: cs_math.h:360
CS_F_HOST_DEVICE cs_real_t cs_math_3_33_3_dot_product(const T n1[3], const U t[3][3], const V n2[3])
Compute the dot product of a tensor t with two vectors, n1 and n2.
Definition: cs_math.h:469
CS_F_HOST_DEVICE void cs_math_3_normal_scaling(const T n[3], U factor, V v[3])
Add the dot product with a normal vector to the normal direction to a vector.
Definition: cs_math.h:442
CS_F_HOST_DEVICE void cs_math_33_transform_r_to_a(const cs_real_t m[3][3], const cs_real_t q[3][3], cs_real_t mout[3][3])
Compute transformation from relative to absolute reference frame Q^t M Q.
Definition: cs_math.h:1719
CS_F_HOST_DEVICE cs_real_t cs_math_pow2(cs_real_t x)
Compute the square of a real value.
Definition: cs_math.h:902
CS_F_HOST_DEVICE void cs_math_sym_33_3_product_add(const cs_real_t m[6], const cs_real_t v[3], cs_real_t *restrict mv)
Compute the product of a symmetric matrix of 3x3 real values by a vector of 3 real values and add it ...
Definition: cs_math.h:1305
CS_F_HOST_DEVICE void cs_math_6_gauss_inverse_in_place(T a[6])
Inverse 3x3 symmetric matrix in place, using Gauss-Jordan elimination.
Definition: cs_math.h:600
CS_F_HOST_DEVICE T cs_math_3_square_norm(const T v[3])
Compute the square norm of a vector of 3 real values.
Definition: cs_math.h:337
static constexpr cs_real_t cs_math_5ov3
Definition: cs_math.h:116
void cs_math_fact_lu(const int n, const cs_real_t *a, cs_real_t *a_lu)
Compute LU factorization of an array of dense matrices of identical size.
Definition: cs_math.cpp:532
CS_F_HOST_DEVICE cs_real_t cs_math_fmin(cs_real_t x, cs_real_t y)
Compute the min value of two real values.
Definition: cs_math.h:825
cs_math_sym_tensor_component_t
Definition: cs_math.h:72
@ ZZ
Definition: cs_math.h:76
@ XY
Definition: cs_math.h:77
@ XZ
Definition: cs_math.h:79
@ YZ
Definition: cs_math.h:78
@ YY
Definition: cs_math.h:75
@ XX
Definition: cs_math.h:74
CS_F_HOST_DEVICE void cs_math_3_length_unitv(const cs_real_t xa[3], const cs_real_t xb[3], cs_real_t *len, cs_real_3_t unitv)
Compute the length (Euclidean norm) between two points xa and xb in a Cartesian coordinate system of ...
Definition: cs_math.cpp:303
CS_F_HOST_DEVICE T cs_math_33_trace(const T t[3][3])
Compute the trace of a 3x3 tensor.
Definition: cs_math.h:257
static constexpr cs_real_t cs_math_4ov3
Definition: cs_math.h:115
CS_F_HOST_DEVICE void cs_math_33_extract_sym_ant(const cs_real_t m[3][3], cs_real_t m_sym[3][3], cs_real_t m_ant[3][3])
Extract from the given matrix its symmetric and anti-symmetric part.
Definition: cs_math.h:1888
CS_F_HOST_DEVICE void cs_math_quaternions_from_2_vectors(const cs_real_t dir[3], const cs_real_t dir_r[3], cs_real_t euler[4])
Compute the 4 Euler parameters using 2 direction vectors one for the relative mean velocity in the gl...
Definition: cs_math.h:2094
static constexpr cs_real_t cs_math_2ov3
Definition: cs_math.h:114
CS_F_HOST_DEVICE void cs_math_sym_33_transform_r_to_a(const cs_real_t m[6], const cs_real_t q[3][3], cs_real_t mout[6])
Compute transformation from relative to absolute reference frame Q^t M Q.
Definition: cs_math.h:1763
CS_F_HOST_DEVICE void cs_math_3_orthogonal_projection(const T n[3], const U v[3], V *restrict vout)
Orthogonal projection of a vector with respect to a normalised vector.
Definition: cs_math.h:497
double cs_math_voltet(const cs_real_t xv[3], const cs_real_t xe[3], const cs_real_t xf[3], const cs_real_t xc[3])
Compute the volume of the convex_hull generated by 4 points. This is equivalent to the computation of...
Definition: cs_math.cpp:366
CS_F_HOST_DEVICE T cs_math_3_norm(const T v[3])
Compute the euclidean norm of a vector of dimension 3.
Definition: cs_math.h:240
CS_F_HOST_DEVICE void cs_math_3_cross_product(const T u[3], const U v[3], V *restrict uv)
Compute the cross product of two vectors of 3 real values.
Definition: cs_math.h:522
CS_F_HOST_DEVICE void cs_math_sym_33_inv_cramer(const cs_real_t s[6], cs_real_t *restrict sout)
Compute the inverse of a symmetric matrix using Cramer's rule.
Definition: cs_math.h:1657
CS_F_HOST_DEVICE void cs_math_66_6_product(const cs_real_t m[6][6], const cs_real_t v[6], cs_real_t *restrict mv)
Compute the product of a matrix of 6x6 real values by a vector of 6 real values.
Definition: cs_math.h:1363
CS_F_HOST_DEVICE cs_real_t cs_math_3_square_distance(const cs_real_t xa[3], const cs_real_t xb[3])
Compute the squared distance between two points xa and xb in a Cartesian coordinate system of dimensi...
Definition: cs_math.h:1015
CS_F_HOST_DEVICE void cs_math_sym_33_double_product(const cs_real_t s1[6], const cs_real_t s2[6], const cs_real_t s3[6], cs_real_t(*restrict sout)[3])
Compute the product of three symmetric matrices.
Definition: cs_math.h:2192
CS_F_HOST_DEVICE void cs_math_33_product(const cs_real_t m1[3][3], const cs_real_t m2[3][3], cs_real_t mout[3][3])
Compute the product of two 3x3 real valued matrices.
Definition: cs_math.h:1690
CS_F_HOST_DEVICE void cs_math_33_inv_cramer(const cs_real_t in[3][3], cs_real_t out[3][3])
Inverse a 3x3 matrix.
Definition: cs_math.h:1555
CS_F_HOST_DEVICE cs_real_t cs_math_fabs(cs_real_t x)
Compute the absolute value of a real value.
Definition: cs_math.h:807
static constexpr cs_real_t cs_math_pi
Definition: cs_math.h:111
static constexpr cs_real_t cs_math_big_r
Definition: cs_math.h:108
CS_F_HOST_DEVICE void cs_math_sym_33_product(const cs_real_t s1[6], const cs_real_t s2[6], cs_real_t *restrict sout)
Compute the product of two symmetric matrices.
Definition: cs_math.h:1983
CS_F_HOST_DEVICE void cs_math_quaternions_into_33_rotation(const cs_real_t e[4], cs_real_t m[3][3])
Compute the rotation matrix m (3x3 matrix) knowing the 4 Euler parameters (defining a quaternion) Bas...
Definition: cs_math.h:2067
CS_F_HOST_DEVICE cs_real_t cs_math_3_sym_33_3_dot_product(const T n1[3], const U t[6], const V n2[3])
Compute the dot product of a symmetric tensor t with two vectors, n1 and n2.
Definition: cs_math.h:284
static constexpr cs_real_t cs_math_1ov3
Definition: cs_math.h:113
CS_F_HOST_DEVICE cs_real_t cs_math_33_main_invariant_2(const cs_real_t m[3][3])
Compute the second main invariant of the symmetric part of a 3x3 tensor.
Definition: cs_math.h:1927
Definition: cs_algorithm.h:51
CS_F_HOST_DEVICE T max(const T a, const T b)
Definition: cs_defs.h:735
CS_F_HOST_DEVICE float pow2(float x)
Compute the square of a real value.
Definition: cs_math.h:744
CS_F_HOST_DEVICE float max(const float a, const float b)
Definition: cs_math.h:695
CS_F_HOST_DEVICE T clamp(const T x, const T xmin, const T xmax)
Definition: cs_defs.h:760
CS_F_HOST_DEVICE T min(const T a, const T b)
Definition: cs_defs.h:712
CS_F_HOST_DEVICE float min(const float a, const float b)
Definition: cs_math.h:667
CS_F_HOST_DEVICE T abs(const T a)
Definition: cs_defs.h:690
Definition: cs_defs.h:390
double meas
Definition: cs_defs.h:392
double unitv[3]
Definition: cs_defs.h:393