39 #if defined(__NVCC__) && defined(__CUDA_ARCH__)
47 #if defined(DEBUG) && !defined(NDEBUG)
82 #if defined(__NVCC__) && defined(__CUDA_ARCH__)
86 #define cs_math_zero_threshold FLT_MIN
87 #define cs_math_epzero 1e-12
88 #define cs_math_infinite_r 1.e30
89 #define cs_math_big_r 1.e12
90 #define cs_math_pi 3.14159265358979323846
139 const int n_iter = (
k > n-
k) ? n-
k :
k;
140 for (
int j = 1; j <= n_iter; j++, n--) {
143 else if (ret % j == 0)
308 return x*(x*x)*(x*x);
329 v[0] = xb[0] - xa[0];
330 v[1] = xb[1] - xa[1];
331 v[2] = xb[2] - xa[2];
333 return sqrt(
v[0]*
v[0] +
v[1]*
v[1] +
v[2]*
v[2]);
353 return ((xb[0] - xa[0])*xc[0]+(xb[1] - xa[1])*xc[1]+(xb[2] - xa[2])*xc[2]);
376 return (
v[0]*
v[0] +
v[1]*
v[1] +
v[2]*
v[2]);
417 = ( n1[0]*
t[0][0]*n2[0] + n1[1]*
t[1][0]*n2[0] + n1[2]*
t[2][0]*n2[0]
418 + n1[0]*
t[0][1]*n2[1] + n1[1]*
t[1][1]*n2[1] + n1[2]*
t[2][1]*n2[1]
419 + n1[0]*
t[0][2]*n2[2] + n1[1]*
t[1][2]*n2[2] + n1[2]*
t[2][2]*n2[2]);
444 return ( n1[0] * (
t[0]*n2[0] +
t[3]*n2[1] +
t[5]*n2[2])
445 + n1[1] * (
t[3]*n2[0] +
t[1]*n2[1] +
t[4]*n2[2])
446 + n1[2] * (
t[5]*n2[0] +
t[4]*n2[1] +
t[2]*n2[2]));
462 return sqrt(
v[0]*
v[0] +
v[1]*
v[1] +
v[2]*
v[2]);
502 vout[0] = inv_norm * vin[0];
503 vout[1] = inv_norm * vin[1];
504 vout[2] = inv_norm * vin[2];
526 vout[0] = inv_norm * vin[0];
527 vout[1] = inv_norm * vin[1];
528 vout[2] = inv_norm * vin[2];
551 cs_real_t inv_norm = ((norm > thres) ? 1. / norm : 1. / thres);
553 vout[0] = inv_norm * vin[0];
554 vout[1] = inv_norm * vin[1];
555 vout[2] = inv_norm * vin[2];
574 vout[0] =
v[0]*(1.-n[0]*n[0])-
v[1]* n[1]*n[0] -
v[2]* n[2]*n[0];
575 vout[1] = -
v[0]* n[0]*n[1] +
v[1]*(1.-n[1]*n[1])-
v[2]* n[2]*n[1];
576 vout[2] = -
v[0]* n[0]*n[2] -
v[1]* n[1]*n[2] +
v[2]*(1.-n[2]*n[2]);
596 for (
int i = 0; i < 3; i++)
597 v[i] += v_dot_n * n[i];
618 ( n[0] *
t[0][0] * n[0] + n[1] *
t[1][0] * n[0] + n[2] *
t[2][0] * n[0]
619 + n[0] *
t[0][1] * n[1] + n[1] *
t[1][1] * n[1] + n[2] *
t[2][1] * n[1]
620 + n[0] *
t[0][2] * n[2] + n[1] *
t[1][2] * n[2] + n[2] *
t[2][2] * n[2]);
621 for (
int i = 0; i < 3; i++) {
622 for (
int j = 0; j < 3; j++)
623 t[i][j] += n_t_n * n[i] * n[j];
642 mv[0] = m[0][0]*
v[0] + m[0][1]*
v[1] + m[0][2]*
v[2];
643 mv[1] = m[1][0]*
v[0] + m[1][1]*
v[1] + m[1][2]*
v[2];
644 mv[2] = m[2][0]*
v[0] + m[2][1]*
v[1] + m[2][2]*
v[2];
663 mv[0] += m[0][0]*
v[0] + m[0][1]*
v[1] + m[0][2]*
v[2];
664 mv[1] += m[1][0]*
v[0] + m[1][1]*
v[1] + m[1][2]*
v[2];
665 mv[2] += m[2][0]*
v[0] + m[2][1]*
v[1] + m[2][2]*
v[2];
684 mv[0] = m[0][0]*
v[0] + m[1][0]*
v[1] + m[2][0]*
v[2];
685 mv[1] = m[0][1]*
v[0] + m[1][1]*
v[1] + m[2][1]*
v[2];
686 mv[2] = m[0][2]*
v[0] + m[1][2]*
v[1] + m[2][2]*
v[2];
706 mv[0] = m[0]*
v[0] + m[3]*
v[1] + m[5]*
v[2];
707 mv[1] = m[3]*
v[0] + m[1]*
v[1] + m[4]*
v[2];
708 mv[2] = m[5]*
v[0] + m[4]*
v[1] + m[2]*
v[2];
728 mv[0] += m[0] *
v[0] + m[3] *
v[1] + m[5] *
v[2];
729 mv[1] += m[3] *
v[0] + m[1] *
v[1] + m[4] *
v[2];
730 mv[2] += m[5] *
v[0] + m[4] *
v[1] + m[2] *
v[2];
749 return m1[0]*m2[0] + 2.*m1[3]*m2[3] + 2.*m1[5]*m2[5]
750 + m1[1]*m2[1] + 2.*m1[4]*m2[4]
767 return (
t[0][0] +
t[1][1] +
t[2][2]);
783 return (
t[0] +
t[1] +
t[2]);
802 for (
int i = 0; i < 6; i++) {
803 for (
int j = 0; j < 6; j++)
804 mv[i] = m[i][j] *
v[j];
824 for (
int i = 0; i < 6; i++) {
825 for (
int j = 0; j < 6; j++)
826 mv[i] += m[i][j] *
v[j];
843 const cs_real_t com0 = m[1][1]*m[2][2] - m[2][1]*m[1][2];
844 const cs_real_t com1 = m[2][1]*m[0][2] - m[0][1]*m[2][2];
845 const cs_real_t com2 = m[0][1]*m[1][2] - m[1][1]*m[0][2];
847 return m[0][0]*com0 + m[1][0]*com1 + m[2][0]*com2;
863 const cs_real_t com0 = m[1]*m[2] - m[4]*m[4];
864 const cs_real_t com1 = m[4]*m[5] - m[3]*m[2];
865 const cs_real_t com2 = m[3]*m[4] - m[1]*m[5];
867 return m[0]*com0 + m[3]*com1 + m[5]*com2;
880 #if defined(__INTEL_COMPILER)
881 #pragma optimization_level 0
889 uv[0] =
u[1]*
v[2] -
u[2]*
v[1];
890 uv[1] =
u[2]*
v[0] -
u[0]*
v[2];
891 uv[2] =
u[0]*
v[1] -
u[1]*
v[0];
906 #if defined(__INTEL_COMPILER)
907 #pragma optimization_level 0
915 return (
u[1]*
v[2] -
u[2]*
v[1]) * w[0]
916 + (
u[2]*
v[0] -
u[0]*
v[2]) * w[1]
917 + (
u[0]*
v[1] -
u[1]*
v[0]) * w[2];
973 out[0][0] = in[1][1]*in[2][2] - in[2][1]*in[1][2];
974 out[0][1] = in[2][1]*in[0][2] - in[0][1]*in[2][2];
975 out[0][2] = in[0][1]*in[1][2] - in[1][1]*in[0][2];
977 out[1][0] = in[2][0]*in[1][2] - in[1][0]*in[2][2];
978 out[1][1] = in[0][0]*in[2][2] - in[2][0]*in[0][2];
979 out[1][2] = in[1][0]*in[0][2] - in[0][0]*in[1][2];
981 out[2][0] = in[1][0]*in[2][1] - in[2][0]*in[1][1];
982 out[2][1] = in[2][0]*in[0][1] - in[0][0]*in[2][1];
983 out[2][2] = in[0][0]*in[1][1] - in[1][0]*in[0][1];
985 const double det = in[0][0]*out[0][0]+in[1][0]*out[0][1]+in[2][0]*out[0][2];
986 const double invdet = 1./det;
988 out[0][0] *= invdet, out[0][1] *= invdet, out[0][2] *= invdet;
989 out[1][0] *= invdet, out[1][1] *= invdet, out[1][2] *= invdet;
990 out[2][0] *= invdet, out[2][1] *= invdet, out[2][2] *= invdet;
1004 cs_real_t a00 = a[1][1]*a[2][2] - a[2][1]*a[1][2];
1005 cs_real_t a01 = a[2][1]*a[0][2] - a[0][1]*a[2][2];
1006 cs_real_t a02 = a[0][1]*a[1][2] - a[1][1]*a[0][2];
1007 cs_real_t a10 = a[2][0]*a[1][2] - a[1][0]*a[2][2];
1008 cs_real_t a11 = a[0][0]*a[2][2] - a[2][0]*a[0][2];
1009 cs_real_t a12 = a[1][0]*a[0][2] - a[0][0]*a[1][2];
1010 cs_real_t a20 = a[1][0]*a[2][1] - a[2][0]*a[1][1];
1011 cs_real_t a21 = a[2][0]*a[0][1] - a[0][0]*a[2][1];
1012 cs_real_t a22 = a[0][0]*a[1][1] - a[1][0]*a[0][1];
1014 double det_inv = 1. / (a[0][0]*a00 + a[1][0]*a01 + a[2][0]*a02);
1016 a[0][0] = a00 * det_inv;
1017 a[0][1] = a01 * det_inv;
1018 a[0][2] = a02 * det_inv;
1019 a[1][0] = a10 * det_inv;
1020 a[1][1] = a11 * det_inv;
1021 a[1][2] = a12 * det_inv;
1022 a[2][0] = a20 * det_inv;
1023 a[2][1] = a21 * det_inv;
1024 a[2][2] = a22 * det_inv;
1039 cs_real_t a00 = a[1][1]*a[2][2] - a[2][1]*a[1][2];
1040 cs_real_t a01 = a[2][1]*a[0][2] - a[0][1]*a[2][2];
1041 cs_real_t a02 = a[0][1]*a[1][2] - a[1][1]*a[0][2];
1042 cs_real_t a11 = a[0][0]*a[2][2] - a[2][0]*a[0][2];
1043 cs_real_t a12 = a[1][0]*a[0][2] - a[0][0]*a[1][2];
1044 cs_real_t a22 = a[0][0]*a[1][1] - a[1][0]*a[0][1];
1046 double det_inv = 1. / (a[0][0]*a00 + a[1][0]*a01 + a[2][0]*a02);
1048 a[0][0] = a00 * det_inv;
1049 a[0][1] = a01 * det_inv;
1050 a[0][2] = a02 * det_inv;
1051 a[1][0] = a01 * det_inv;
1052 a[1][1] = a11 * det_inv;
1053 a[1][2] = a12 * det_inv;
1054 a[2][0] = a02 * det_inv;
1055 a[2][1] = a12 * det_inv;
1056 a[2][2] = a22 * det_inv;
1077 sout[0] = s[1]*s[2] - s[4]*s[4];
1078 sout[1] = s[0]*s[2] - s[5]*s[5];
1079 sout[2] = s[0]*s[1] - s[3]*s[3];
1080 sout[3] = s[4]*s[5] - s[3]*s[2];
1081 sout[4] = s[3]*s[5] - s[0]*s[4];
1082 sout[5] = s[3]*s[4] - s[1]*s[5];
1084 detinv = 1. / (s[0]*sout[0] + s[3]*sout[3] + s[5]*sout[5]);
1109 mout[0][0] = m1[0][0]*m2[0][0] + m1[0][1]*m2[1][0] + m1[0][2]*m2[2][0];
1110 mout[0][1] = m1[0][0]*m2[0][1] + m1[0][1]*m2[1][1] + m1[0][2]*m2[2][1];
1111 mout[0][2] = m1[0][0]*m2[0][2] + m1[0][1]*m2[1][2] + m1[0][2]*m2[2][2];
1113 mout[1][0] = m1[1][0]*m2[0][0] + m1[1][1]*m2[1][0] + m1[1][2]*m2[2][0];
1114 mout[1][1] = m1[1][0]*m2[0][1] + m1[1][1]*m2[1][1] + m1[1][2]*m2[2][1];
1115 mout[1][2] = m1[1][0]*m2[0][2] + m1[1][1]*m2[1][2] + m1[1][2]*m2[2][2];
1117 mout[2][0] = m1[2][0]*m2[0][0] + m1[2][1]*m2[1][0] + m1[2][2]*m2[2][0];
1118 mout[2][1] = m1[2][0]*m2[0][1] + m1[2][1]*m2[1][1] + m1[2][2]*m2[2][1];
1119 mout[2][2] = m1[2][0]*m2[0][2] + m1[2][1]*m2[1][2] + m1[2][2]*m2[2][2];
1140 _m[0][0] = m[0][0]*q[0][0] + m[0][1]*q[1][0] + m[0][2]*q[2][0];
1141 _m[0][1] = m[0][0]*q[0][1] + m[0][1]*q[1][1] + m[0][2]*q[2][1];
1142 _m[0][2] = m[0][0]*q[0][2] + m[0][1]*q[1][2] + m[0][2]*q[2][2];
1144 _m[1][0] = m[1][0]*q[0][0] + m[1][1]*q[1][0] + m[1][2]*q[2][0];
1145 _m[1][1] = m[1][0]*q[0][1] + m[1][1]*q[1][1] + m[1][2]*q[2][1];
1146 _m[1][2] = m[1][0]*q[0][2] + m[1][1]*q[1][2] + m[1][2]*q[2][2];
1148 _m[2][0] = m[2][0]*q[0][0] + m[2][1]*q[1][0] + m[2][2]*q[2][0];
1149 _m[2][1] = m[2][0]*q[0][1] + m[2][1]*q[1][1] + m[2][2]*q[2][1];
1150 _m[2][2] = m[2][0]*q[0][2] + m[2][1]*q[1][2] + m[2][2]*q[2][2];
1153 mout[0][0] = q[0][0]*_m[0][0] + q[1][0]*_m[1][0] + q[2][0]*_m[2][0];
1154 mout[0][1] = q[0][0]*_m[0][1] + q[1][0]*_m[1][1] + q[2][0]*_m[2][1];
1155 mout[0][2] = q[0][0]*_m[0][2] + q[1][0]*_m[1][2] + q[2][0]*_m[2][2];
1157 mout[1][0] = q[0][1]*_m[0][0] + q[1][1]*_m[1][0] + q[2][1]*_m[2][0];
1158 mout[1][1] = q[0][1]*_m[0][1] + q[1][1]*_m[1][1] + q[2][1]*_m[2][1];
1159 mout[1][2] = q[0][1]*_m[0][2] + q[1][1]*_m[1][2] + q[2][1]*_m[2][2];
1161 mout[2][0] = q[0][2]*_m[0][0] + q[1][2]*_m[1][0] + q[2][2]*_m[2][0];
1162 mout[2][1] = q[0][2]*_m[0][1] + q[1][2]*_m[1][1] + q[2][2]*_m[2][1];
1163 mout[2][2] = q[0][2]*_m[0][2] + q[1][2]*_m[1][2] + q[2][2]*_m[2][2];
1184 _m[0][0] = m[0]*q[0][0] + m[3]*q[1][0] + m[5]*q[2][0];
1185 _m[0][1] = m[0]*q[0][1] + m[3]*q[1][1] + m[5]*q[2][1];
1186 _m[0][2] = m[0]*q[0][2] + m[3]*q[1][2] + m[5]*q[2][2];
1188 _m[1][0] = m[3]*q[0][0] + m[1]*q[1][0] + m[4]*q[2][0];
1189 _m[1][1] = m[3]*q[0][1] + m[1]*q[1][1] + m[4]*q[2][1];
1190 _m[1][2] = m[3]*q[0][2] + m[1]*q[1][2] + m[4]*q[2][2];
1192 _m[2][0] = m[5]*q[0][0] + m[4]*q[1][0] + m[2]*q[2][0];
1193 _m[2][1] = m[5]*q[0][1] + m[4]*q[1][1] + m[2]*q[2][1];
1194 _m[2][2] = m[5]*q[0][2] + m[4]*q[1][2] + m[2]*q[2][2];
1197 mout[0] = q[0][0]*_m[0][0] + q[1][0]*_m[1][0] + q[2][0]*_m[2][0];
1198 mout[1] = q[0][1]*_m[0][1] + q[1][1]*_m[1][1] + q[2][1]*_m[2][1];
1199 mout[2] = q[0][2]*_m[0][2] + q[1][2]*_m[1][2] + q[2][2]*_m[2][2];
1201 mout[3] = q[0][0]*_m[0][1] + q[1][0]*_m[1][1] + q[2][0]*_m[2][1];
1202 mout[4] = q[0][1]*_m[0][2] + q[1][1]*_m[1][2] + q[2][1]*_m[2][2];
1203 mout[5] = q[0][0]*_m[0][2] + q[1][0]*_m[1][2] + q[2][0]*_m[2][2];
1224 _m[0][0] = m[0][0]*q[0][0] + m[0][1]*q[0][1] + m[0][2]*q[0][2];
1225 _m[0][1] = m[0][0]*q[1][0] + m[0][1]*q[1][1] + m[0][2]*q[1][2];
1226 _m[0][2] = m[0][0]*q[2][0] + m[0][1]*q[2][1] + m[0][2]*q[2][2];
1228 _m[1][0] = m[1][0]*q[0][0] + m[1][1]*q[0][1] + m[1][2]*q[0][2];
1229 _m[1][1] = m[1][0]*q[1][0] + m[1][1]*q[1][1] + m[1][2]*q[1][2];
1230 _m[1][2] = m[1][0]*q[2][0] + m[1][1]*q[2][1] + m[1][2]*q[2][2];
1232 _m[2][0] = m[2][0]*q[0][0] + m[2][1]*q[0][1] + m[2][2]*q[0][2];
1233 _m[2][1] = m[2][0]*q[1][0] + m[2][1]*q[1][1] + m[2][2]*q[1][2];
1234 _m[2][2] = m[2][0]*q[2][0] + m[2][1]*q[2][1] + m[2][2]*q[2][2];
1237 mout[0][0] = q[0][0]*_m[0][0] + q[0][1]*_m[1][0] + q[0][2]*_m[2][0];
1238 mout[0][1] = q[0][0]*_m[0][1] + q[0][1]*_m[1][1] + q[0][2]*_m[2][1];
1239 mout[0][2] = q[0][0]*_m[0][2] + q[0][1]*_m[1][2] + q[0][2]*_m[2][2];
1241 mout[1][0] = q[1][0]*_m[0][0] + q[1][1]*_m[1][0] + q[1][2]*_m[2][0];
1242 mout[1][1] = q[1][0]*_m[0][1] + q[1][1]*_m[1][1] + q[1][2]*_m[2][1];
1243 mout[1][2] = q[1][0]*_m[0][2] + q[1][1]*_m[1][2] + q[1][2]*_m[2][2];
1245 mout[2][0] = q[2][0]*_m[0][0] + q[2][1]*_m[1][0] + q[2][2]*_m[2][0];
1246 mout[2][1] = q[2][0]*_m[0][1] + q[2][1]*_m[1][1] + q[2][2]*_m[2][1];
1247 mout[2][2] = q[2][0]*_m[0][2] + q[2][1]*_m[1][2] + q[2][2]*_m[2][2];
1268 _m[0][0] = m[0]*q[0][0] + m[3]*q[0][1] + m[5]*q[0][2];
1269 _m[0][1] = m[0]*q[1][0] + m[3]*q[1][1] + m[5]*q[1][2];
1270 _m[0][2] = m[0]*q[2][0] + m[3]*q[2][1] + m[5]*q[2][2];
1272 _m[1][0] = m[3]*q[0][0] + m[1]*q[0][1] + m[4]*q[0][2];
1273 _m[1][1] = m[3]*q[1][0] + m[1]*q[1][1] + m[4]*q[1][2];
1274 _m[1][2] = m[3]*q[2][0] + m[1]*q[2][1] + m[4]*q[2][2];
1276 _m[2][0] = m[5]*q[0][0] + m[4]*q[0][1] + m[2]*q[0][2];
1277 _m[2][1] = m[5]*q[1][0] + m[4]*q[1][1] + m[2]*q[1][2];
1278 _m[2][2] = m[5]*q[2][0] + m[4]*q[2][1] + m[2]*q[2][2];
1281 mout[0] = q[0][0]*_m[0][0] + q[0][1]*_m[1][0] + q[0][2]*_m[2][0];
1282 mout[1] = q[1][0]*_m[0][1] + q[1][1]*_m[1][1] + q[1][2]*_m[2][1];
1283 mout[2] = q[2][0]*_m[0][2] + q[2][1]*_m[1][2] + q[2][2]*_m[2][2];
1286 mout[3] = q[0][0]*_m[0][1] + q[0][1]*_m[1][1] + q[0][2]*_m[2][1];
1287 mout[4] = q[1][0]*_m[0][2] + q[1][1]*_m[1][2] + q[1][2]*_m[2][2];
1288 mout[5] = q[0][0]*_m[0][2] + q[0][1]*_m[1][2] + q[0][2]*_m[2][2];
1308 m_sym[0][0] = 0.5 * (m[0][0] + m[0][0]);
1309 m_sym[0][1] = 0.5 * (m[0][1] + m[1][0]);
1310 m_sym[0][2] = 0.5 * (m[0][2] + m[2][0]);
1311 m_sym[1][0] = 0.5 * (m[1][0] + m[0][1]);
1312 m_sym[1][1] = 0.5 * (m[1][1] + m[1][1]);
1313 m_sym[1][2] = 0.5 * (m[1][2] + m[2][1]);
1314 m_sym[2][0] = 0.5 * (m[2][0] + m[0][2]);
1315 m_sym[2][1] = 0.5 * (m[2][1] + m[1][2]);
1316 m_sym[2][2] = 0.5 * (m[2][2] + m[2][2]);
1319 m_ant[0][0] = 0.5 * (m[0][0] - m[0][0]);
1320 m_ant[0][1] = 0.5 * (m[0][1] - m[1][0]);
1321 m_ant[0][2] = 0.5 * (m[0][2] - m[2][0]);
1322 m_ant[1][0] = 0.5 * (m[1][0] - m[0][1]);
1323 m_ant[1][1] = 0.5 * (m[1][1] - m[1][1]);
1324 m_ant[1][2] = 0.5 * (m[1][2] - m[2][1]);
1325 m_ant[2][0] = 0.5 * (m[2][0] - m[0][2]);
1326 m_ant[2][1] = 0.5 * (m[2][1] - m[1][2]);
1327 m_ant[2][2] = 0.5 * (m[2][2] - m[2][2]);
1368 mout[0][0] += m1[0][0]*m2[0][0] + m1[0][1]*m2[1][0] + m1[0][2]*m2[2][0];
1369 mout[0][1] += m1[0][0]*m2[0][1] + m1[0][1]*m2[1][1] + m1[0][2]*m2[2][1];
1370 mout[0][2] += m1[0][0]*m2[0][2] + m1[0][1]*m2[1][2] + m1[0][2]*m2[2][2];
1372 mout[1][0] += m1[1][0]*m2[0][0] + m1[1][1]*m2[1][0] + m1[1][2]*m2[2][0];
1373 mout[1][1] += m1[1][0]*m2[0][1] + m1[1][1]*m2[1][1] + m1[1][2]*m2[2][1];
1374 mout[1][2] += m1[1][0]*m2[0][2] + m1[1][1]*m2[1][2] + m1[1][2]*m2[2][2];
1376 mout[2][0] += m1[2][0]*m2[0][0] + m1[2][1]*m2[1][0] + m1[2][2]*m2[2][0];
1377 mout[2][1] += m1[2][0]*m2[0][1] + m1[2][1]*m2[1][1] + m1[2][2]*m2[2][1];
1378 mout[2][2] += m1[2][0]*m2[0][2] + m1[2][1]*m2[1][2] + m1[2][2]*m2[2][2];
1403 sout[0] = s1[0]*s2[0] + s1[3]*s2[3] + s1[5]*s2[5];
1405 sout[1] = s1[3]*s2[3] + s1[1]*s2[1] + s1[4]*s2[4];
1407 sout[2] = s1[5]*s2[5] + s1[4]*s2[4] + s1[2]*s2[2];
1409 sout[3] = s1[0]*s2[3] + s1[3]*s2[1] + s1[5]*s2[4];
1411 sout[4] = s1[3]*s2[5] + s1[1]*s2[4] + s1[4]*s2[2];
1413 sout[5] = s1[0]*s2[5] + s1[3]*s2[4] + s1[5]*s2[2];
1430 const int t2v[3][3] = {{0, 3, 5},
1434 const int iv2t[6] = {0, 1, 2, 0, 1, 0};
1435 const int jv2t[6] = {0, 1, 2, 1, 2, 2};
1437 for (
int i = 0; i < 6; i++) {
1438 for (
int j = 0; j < 6; j++)
1451 for (
int ij = 0; ij < 6; ij++) {
1454 for (
int k = 0;
k < 3;
k++) {
1458 sout[ij][
ik] += s[j][
k];
1459 sout[ij][jk] += s[i][
k];
1487 _sout[0][0] = s1[0]*s2[0] + s1[3]*s2[3] + s1[5]*s2[5];
1489 _sout[1][1] = s1[3]*s2[3] + s1[1]*s2[1] + s1[4]*s2[4];
1491 _sout[2][2] = s1[5]*s2[5] + s1[4]*s2[4] + s1[2]*s2[2];
1493 _sout[0][1] = s1[0]*s2[3] + s1[3]*s2[1] + s1[5]*s2[4];
1495 _sout[1][0] = s2[0]*s1[3] + s2[3]*s1[1] + s2[5]*s1[4];
1497 _sout[1][2] = s1[3]*s2[5] + s1[1]*s2[4] + s1[4]*s2[2];
1499 _sout[2][1] = s2[3]*s1[5] + s2[1]*s1[4] + s2[4]*s1[2];
1501 _sout[0][2] = s1[0]*s2[5] + s1[3]*s2[4] + s1[5]*s2[2];
1503 _sout[2][0] = s2[0]*s1[5] + s2[3]*s1[4] + s2[5]*s1[2];
1505 sout[0][0] = _sout[0][0]*s3[0] + _sout[0][1]*s3[3] + _sout[0][2]*s3[5];
1507 sout[1][1] = _sout[1][0]*s3[3] + _sout[1][1]*s3[1] + _sout[1][2]*s3[4];
1509 sout[2][2] = _sout[2][0]*s3[5] + _sout[2][1]*s3[4] + _sout[2][2]*s3[2];
1511 sout[0][1] = _sout[0][0]*s3[3] + _sout[0][1]*s3[1] + _sout[0][2]*s3[4];
1513 sout[1][0] = s3[0]*_sout[1][0] + s3[3]*_sout[1][1] + s3[5]*_sout[1][2];
1515 sout[1][2] = _sout[1][0]*s3[5] + _sout[1][1]*s3[4] + _sout[1][2]*s3[2];
1517 sout[2][1] = s3[3]*_sout[2][0] + s3[1]*_sout[2][1] + s3[4]*_sout[2][2];
1519 sout[0][2] = _sout[0][0]*s3[5] + _sout[0][1]*s3[4] + _sout[0][2]*s3[2];
1521 sout[2][0] = s3[0]*_sout[2][0] + s3[3]*_sout[2][1] + s3[5]*_sout[2][2];
1539 qv->
meas = magnitude;
1543 qv->
unitv[0] = inv *
v[0];
1544 qv->
unitv[1] = inv *
v[1];
1545 qv->
unitv[2] = inv *
v[2];
#define restrict
Definition: cs_defs.h:141
#define BEGIN_C_DECLS
Definition: cs_defs.h:528
#define CS_F_HOST_DEVICE
Definition: cs_defs.h:546
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:347
cs_real_t cs_real_6_t[6]
vector of 6 floating-point values
Definition: cs_defs.h:349
#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:356
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
@ t
Definition: cs_field_pointer.h:92
@ k
Definition: cs_field_pointer.h:70
static CS_F_HOST_DEVICE void cs_math_3_normalize(const cs_real_t vin[3], cs_real_t vout[3])
Normalise a vector of 3 real values.
Definition: cs_math.h:519
const cs_real_t cs_math_1ov6
static 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:274
static CS_F_HOST_DEVICE cs_real_t cs_math_3_sym_33_3_dot_product(const cs_real_t n1[3], const cs_real_t t[6], const cs_real_t n2[3])
Compute the dot product of a symmetric tensor t with two vectors, n1 and n2.
Definition: cs_math.h:440
static 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 mv[restrict 3])
Compute the product of the transpose of a matrix of 3x3 real values by a vector of 3 real values.
Definition: cs_math.h:680
static 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:1303
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:446
static CS_F_HOST_DEVICE void cs_math_sym_33_inv_cramer(const cs_real_t s[6], cs_real_t sout[restrict 6])
Compute the inverse of a symmetric matrix using Cramer's rule.
Definition: cs_math.h:1072
static 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:1037
static 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 mv[restrict 3])
Compute the product of a matrix of 3x3 real values by a vector of 3 real values add.
Definition: cs_math.h:659
const cs_real_t cs_math_infinite_r
static 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 sout[restrict 3][3])
Compute the product of three symmetric matrices.
Definition: cs_math.h:1479
static 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:258
const cs_real_t cs_math_4ov3
static CS_F_HOST_DEVICE void cs_math_3_cross_product(const cs_real_t u[3], const cs_real_t v[3], cs_real_t uv[restrict 3])
Compute the cross product of two vectors of 3 real values.
Definition: cs_math.h:885
static 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:369
static 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:1178
static 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:1134
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:234
static 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:1342
const cs_real_t cs_math_2ov3
static 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:290
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[])
Block Jacobi utilities. Compute forward and backward to solve an LU P*P system.
Definition: cs_math.cpp:692
const cs_real_t cs_math_1ov12
void cs_math_fact_lu(cs_lnum_t n_blocks, const int b_size, 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:634
static CS_F_HOST_DEVICE cs_real_t cs_math_3_distance_dot_product(const cs_real_t xa[3], const cs_real_t xb[3], const cs_real_t xc[3])
Compute .
Definition: cs_math.h:349
static CS_F_HOST_DEVICE cs_real_t cs_math_3_square_norm(const cs_real_t v[3])
Compute the square norm of a vector of 3 real values.
Definition: cs_math.h:476
static 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:613
static 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:545
static 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 mv[restrict 6])
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:820
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:323
static 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 sout[restrict 6])
Compute the product of two symmetric matrices.
Definition: cs_math.h:1398
const cs_real_t cs_math_1ov24
static CS_F_HOST_DEVICE void cs_math_3_normal_scaling(const cs_real_t n[3], cs_real_t factor, cs_real_t v[3])
Add the dot product with a normal vector to the normal direction to a vector.
Definition: cs_math.h:591
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.cpp:796
static 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 mv[restrict 6])
Compute the product of a matrix of 6x6 real values by a vector of 6 real values.
Definition: cs_math.h:798
static 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:1002
static 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:970
cs_math_sym_tensor_component_t
Definition: cs_math.h:65
@ ZZ
Definition: cs_math.h:69
@ XY
Definition: cs_math.h:70
@ XZ
Definition: cs_math.h:72
@ YZ
Definition: cs_math.h:71
@ YY
Definition: cs_math.h:68
@ XX
Definition: cs_math.h:67
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:413
static CS_F_HOST_DEVICE void cs_math_33_3_product(const cs_real_t m[3][3], const cs_real_t v[3], cs_real_t mv[restrict 3])
Compute the product of a matrix of 3x3 real values by a vector of 3 real values.
Definition: cs_math.h:638
static 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 mout[restrict 3][3])
Add the product of two 3x3 real matrices to a matrix.
Definition: cs_math.h:1364
static 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:911
static CS_F_HOST_DEVICE cs_real_t cs_math_3_33_3_dot_product(const cs_real_t n1[3], const cs_real_t t[3][3], const cs_real_t n2[3])
Compute the dot product of a tensor t with two vectors, n1 and n2.
Definition: cs_math.h:412
static 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:324
static 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:306
const cs_real_t cs_math_1ov3
static 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:1262
static CS_F_HOST_DEVICE cs_real_t cs_math_sym_33_determinant(const cs_real_6_t m)
Compute the determinant of a 3x3 symmetric matrix.
Definition: cs_math.h:861
static CS_F_HOST_DEVICE cs_real_t cs_math_3_dot_product(const cs_real_t u[3], const cs_real_t v[3])
Compute the dot product of two vectors of 3 real values.
Definition: cs_math.h:391
const cs_real_t cs_math_5ov3
static 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:841
static 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 mv[restrict 3])
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:724
const cs_real_t cs_math_epzero
static CS_F_HOST_DEVICE void cs_math_reduce_sym_prod_33_to_66(const cs_real_t s[3][3], cs_real_t sout[restrict 6][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:1427
static 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:1105
const cs_real_t cs_math_big_r
static 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:1218
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:476
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[restrict 3], cs_real_t eig_vec[restrict 3][3])
Evaluate eigenvalues and eigenvectors of a real symmetric matrix m1[3,3]: m1*m2 = lambda*m2.
Definition: cs_math.cpp:510
static int cs_math_binom(int n, int k)
Computes the binomial coefficient of n and k.
Definition: cs_math.h:133
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.cpp:737
static CS_F_HOST_DEVICE void cs_nvec3(const cs_real_3_t v, cs_nvec3_t *qv)
Define a cs_nvec3_t structure from a cs_real_3_t.
Definition: cs_math.h:1534
static 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:781
static 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:746
const cs_real_t cs_math_pi
static 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:222
static const cs_real_33_t cs_math_33_identity
Definition: cs_math.h:110
static const cs_real_6_t cs_math_sym_33_identity
Definition: cs_math.h:113
static void cs_math_3_normalise(const cs_real_t vin[3], cs_real_t vout[3])
Normalize a vector of 3 real values.
Definition: cs_math.h:495
static CS_F_HOST_DEVICE void cs_math_sym_33_3_product(const cs_real_t m[6], const cs_real_t v[3], cs_real_t mv[restrict 3])
Compute the product of a symmetric matrix of 3x3 real values by a vector of 3 real values....
Definition: cs_math.h:702
static CS_F_HOST_DEVICE cs_real_t cs_math_3_norm(const cs_real_t v[3])
Compute the euclidean norm of a vector of dimension 3.
Definition: cs_math.h:460
static 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:163
static CS_F_HOST_DEVICE cs_real_t cs_math_33_trace(const cs_real_t t[3][3])
Compute the trace of a 3x3 tensor.
Definition: cs_math.h:765
static 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:181
const cs_real_t cs_math_zero_threshold
static CS_F_HOST_DEVICE cs_real_t cs_math_sq(cs_real_t x)
Compute the square of a real value.
Definition: cs_math.h:242
static CS_F_HOST_DEVICE void cs_math_3_orthogonal_projection(const cs_real_t n[3], const cs_real_t v[3], cs_real_t vout[restrict 3])
Orthogonal projection of a vector with respect to a normalised vector.
Definition: cs_math.h:570
static 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:933
static 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:200
double precision, dimension(:,:,:), allocatable u
Definition: atimbr.f90:112
double precision, dimension(:,:,:), allocatable v
Definition: atimbr.f90:113
integer, save ik
turbulent kinetic energy
Definition: numvar.f90:75
Definition: cs_defs.h:386
double meas
Definition: cs_defs.h:388
double unitv[3]
Definition: cs_defs.h:389