12 #ifndef MFEM_LINALG_KERNELS_HPP
13 #define MFEM_LINALG_KERNELS_HPP
15 #include "../config/config.hpp"
16 #include "../general/backends.hpp"
17 #include "../general/globals.hpp"
43 for (
int i = 0; i <
dim; i++) { d += (x[i]-y[i])*(x[i]-y[i]); }
49 MFEM_HOST_DEVICE
inline void Diag(
const double c,
double *data)
52 for (
int i = 0; i < N; i++) { data[i] = 0.0; }
53 for (
int i = 0; i <
dim; i++) { data[i*(dim+1)] = c; }
58 MFEM_HOST_DEVICE
inline void Subtract(
const double a,
59 const double *x,
const double *y,
62 for (
int i = 0; i <
dim; i++) { z[i] = a * (x[i] - y[i]); }
67 MFEM_HOST_DEVICE
inline void AddMultVWt(
const double *v,
const double *w,
70 for (
int i = 0; i <
dim; i++)
72 const double vi = v[i];
73 for (
int j = 0; j <
dim; j++) { VWt[i*dim+j] += vi * w[j]; }
77 template<
int H,
int W,
typename T>
78 MFEM_HOST_DEVICE
inline
79 void FNorm(
double &scale_factor,
double &scaled_fnorm2,
const T *data)
82 T max_norm = 0.0, entry, fnorm2;
84 for (i = 0; i < hw; i++)
86 entry = fabs(data[i]);
95 scale_factor = scaled_fnorm2 = 0.0;
100 for (i = 0; i < hw; i++)
102 entry = data[i] / max_norm;
103 fnorm2 += entry * entry;
106 scale_factor = max_norm;
107 scaled_fnorm2 = fnorm2;
111 template<
int H,
int W,
typename T>
112 MFEM_HOST_DEVICE
inline
116 kernels::FNorm<H,W>(
s, n2, data);
121 template<
int H,
int W,
typename T>
122 MFEM_HOST_DEVICE
inline
126 kernels::FNorm<H,W>(
s, n2, data);
132 MFEM_HOST_DEVICE
inline
133 double Norml2(
const int size,
const T *data)
135 if (0 == size) {
return 0.0; }
136 if (1 == size) {
return std::abs(data[0]); }
139 for (
int i = 0; i < size; i++)
143 const T absdata = fabs(data[i]);
144 if (scale <= absdata)
146 const T sqr_arg = scale / absdata;
147 sum = 1.0 + sum * (sqr_arg * sqr_arg);
151 const T sqr_arg = absdata / scale;
152 sum += (sqr_arg * sqr_arg);
155 return scale * sqrt(sum);
161 template<
typename TA,
typename TX,
typename TY>
162 MFEM_HOST_DEVICE
inline
163 void Mult(
const int height,
const int width, TA *data,
const TX *x, TY *y)
167 for (
int row = 0; row < height; row++)
175 for (
int row = 0; row < height; row++)
177 y[row] = x_col*d_col[row];
180 for (
int col = 1; col < width; col++)
183 for (
int row = 0; row < height; row++)
185 y[row] += x_col*d_col[row];
193 MFEM_HOST_DEVICE
inline
196 for (
int i = 0; i < size; i++)
198 for (
int j = 0; j < i; j++)
200 const T
a = 0.5 * (data[i*size+j] + data[j*size+i]);
201 data[j*size+i] = data[i*size+j] =
a;
207 template<
int dim,
typename T>
208 MFEM_HOST_DEVICE
inline T
Det(
const T *data)
215 template<
int dim,
typename T>
216 MFEM_HOST_DEVICE
inline
220 const T det = TAdjDetHD<T>(layout_t(), data, layout_t(), inv_data);
221 TAssignHD<AssignOp::Mult>(layout_t(), inv_data,
static_cast<T
>(1.0)/det);
225 template<
int dim,
typename T>
226 MFEM_HOST_DEVICE
inline
230 TAdjugateHD<T>(layout_t(), data, layout_t(), adj_data);
235 template<
typename TALPHA,
typename TA,
typename TB,
typename TC>
236 MFEM_HOST_DEVICE
inline
237 void Add(
const int height,
const int width,
const TALPHA
alpha,
238 const TA *Adata,
const TB *Bdata, TC *Cdata)
240 for (
int j = 0; j < width; j++)
242 for (
int i = 0; i < height; i++)
244 const int n = i*width+j;
245 Cdata[n] = Adata[n] + alpha * Bdata[n];
252 template<
typename TALPHA,
typename TBETA,
typename TA,
typename TB,
typename TC>
253 MFEM_HOST_DEVICE
inline
254 void Add(
const int height,
const int width,
255 const TALPHA
alpha,
const TA *Adata,
256 const TBETA beta,
const TB *Bdata,
259 const int m = height * width;
260 for (
int i = 0; i < m; i++)
262 Cdata[i] = alpha * Adata[i] + beta * Bdata[i];
268 template<
typename TA,
typename TB>
269 MFEM_HOST_DEVICE
inline
270 void Add(
const int height,
const int width,
const TA *Adata, TB *Bdata)
272 const int m = height * width;
273 for (
int i = 0; i < m; i++)
275 Bdata[i] += Adata[i];
281 template<
typename TA,
typename TB>
282 MFEM_HOST_DEVICE
inline
283 void Add(
const int height,
const int width,
284 const double alpha,
const TA *Adata, TB *Bdata)
286 const int m = height * width;
287 for (
int i = 0; i < m; i++)
289 Bdata[i] += alpha * Adata[i];
295 template<
typename TA,
typename TB>
296 MFEM_HOST_DEVICE
inline
297 void Set(
const int height,
const int width,
298 const double alpha,
const TA *Adata, TB *Bdata)
300 const int m = height * width;
301 for (
int i = 0; i < m; i++)
303 Bdata[i] = alpha * Adata[i];
310 template<
typename TA,
typename TB,
typename TC>
311 MFEM_HOST_DEVICE
inline
312 void Mult(
const int Aheight,
const int Awidth,
const int Bwidth,
313 const TB *Bdata,
const TC *Cdata, TA *Adata)
315 const int ah_x_aw = Aheight * Awidth;
316 for (
int i = 0; i < ah_x_aw; i++) { Adata[i] = 0.0; }
317 for (
int j = 0; j < Awidth; j++)
319 for (
int k = 0; k < Bwidth; k++)
321 for (
int i = 0; i < Aheight; i++)
323 Adata[i+j*Aheight] += Bdata[i+k*Aheight] * Cdata[k+j*Bwidth];
332 template<
typename TA,
typename TB,
typename TC>
333 MFEM_HOST_DEVICE
inline
334 void MultABt(
const int Aheight,
const int Awidth,
const int Bheight,
335 const TA *Adata,
const TB *Bdata, TC *ABtdata)
337 const int ah_x_bh = Aheight * Bheight;
338 for (
int i = 0; i < ah_x_bh; i++) { ABtdata[i] = 0.0; }
339 for (
int k = 0; k < Awidth; k++)
342 for (
int j = 0; j < Bheight; j++)
344 const double bjk = Bdata[j];
345 for (
int i = 0; i < Aheight; i++)
347 c[i] += Adata[i] * bjk;
359 template<
int dim> MFEM_HOST_DEVICE
363 template<
int dim> MFEM_HOST_DEVICE
373 MFEM_HOST_DEVICE
static inline
384 MFEM_HOST_DEVICE
static inline
385 void Eigenvalues2S(
const double &d12,
double &d1,
double &d2)
387 const double sqrt_1_eps = sqrt(1./Epsilon);
392 const double zeta = (d2 - d1)/(2*d12);
393 if (fabs(zeta) < sqrt_1_eps)
395 t = d12*copysign(1./(fabs(zeta) + sqrt(1. + zeta*zeta)), zeta);
399 t = d12*copysign(0.5/fabs(zeta), zeta);
407 MFEM_HOST_DEVICE
static inline
408 void Eigensystem2S(
const double &d12,
double &d1,
double &d2,
409 double &c,
double &
s)
411 const double sqrt_1_eps = sqrt(1./Epsilon);
421 const double zeta = (d2 - d1)/(2*d12);
422 const double azeta = fabs(zeta);
423 if (azeta < sqrt_1_eps)
425 t = copysign(1./(azeta + sqrt(1. + zeta*zeta)), zeta);
429 t = copysign(0.5/azeta, zeta);
431 c = sqrt(1./(1. + t*t));
441 MFEM_HOST_DEVICE
static inline
442 void GetScalingFactor(
const double &d_max,
double &mult)
447 mult = frexp(d_max, &d_exp);
448 if (d_exp == std::numeric_limits<double>::max_exponent)
450 mult *= std::numeric_limits<double>::radix;
463 MFEM_HOST_DEVICE
static inline
464 bool KernelVector2G(
const int &mode,
465 double &d1,
double &d12,
double &d21,
double &d2)
476 double n1 = fabs(d1) + fabs(d21);
477 double n2 = fabs(d2) + fabs(d12);
479 bool swap_columns = (n2 > n1);
491 if (fabs(d1) > fabs(d21))
499 if (fabs(d1) < fabs(d21))
511 if (fabs(d12) > fabs(d2))
524 if (fabs(d12) < fabs(d2))
543 mu = copysign(n1, d1);
544 n1 = -d21*(d21/(d1 +
mu));
548 if (fabs(n1) <= fabs(d21))
552 mu = (2./(1. + n1*n1))*(n1*d12 + d2);
560 mu = (2./(1. + n2*n2))*(d12 + n2*d2);
582 n2 = 1./(1. + fabs(mu));
584 if (fabs(d1) <= n2*fabs(d2))
605 MFEM_HOST_DEVICE
static inline
606 void Vec_normalize3_aux(
const double &x1,
const double &x2,
608 double &n1,
double &n2,
double &n3)
612 const double m = fabs(x1);
616 t = sqrt(1./(t + r*r));
617 n1 = copysign(t, x1);
624 MFEM_HOST_DEVICE
static inline
625 void Vec_normalize3(
const double &x1,
const double &x2,
const double &x3,
626 double &n1,
double &n2,
double &n3)
629 if (fabs(x1) >= fabs(x2))
631 if (fabs(x1) >= fabs(x3))
635 Vec_normalize3_aux(x1, x2, x3, n1, n2, n3);
644 else if (fabs(x2) >= fabs(x3))
646 Vec_normalize3_aux(x2, x1, x3, n2, n1, n3);
649 Vec_normalize3_aux(x3, x1, x2, n3, n1, n2);
653 MFEM_HOST_DEVICE
static inline
654 int KernelVector3G_aux(
const int &mode,
655 double &d1,
double &d2,
double &d3,
656 double &c12,
double &c13,
double &c23,
657 double &c21,
double &c31,
double &c32)
660 double mu, n1, n2, n3, s1, s2, s3;
662 s1 = hypot(c21, c31);
669 mu = copysign(n1, d1);
670 n1 = -s1*(s1/(d1 +
mu));
675 if (fabs(n1) >= fabs(c21))
677 if (fabs(n1) >= fabs(c31))
682 mu = 2./(1. + s2*s2 + s3*s3);
683 n2 = mu*(c12 + s2*d2 + s3*c32);
684 n3 = mu*(c13 + s2*c23 + s3*d3);
694 else if (fabs(c21) >= fabs(c31))
699 mu = 2./(1. + s1*s1 + s3*s3);
700 n2 = mu*(s1*c12 + d2 + s3*c32);
701 n3 = mu*(s1*c13 + c23 + s3*d3);
713 mu = 2./(1. + s1*s1 + s2*s2);
714 n2 = mu*(s1*c12 + s2*d2 + c32);
715 n3 = mu*(s1*c13 + s2*c23 + d3);
729 if (KernelVector2G(mode, d2, c23, c32, d3))
750 d1 = -(c12*d2 + c13*d3)/d1;
754 Vec_normalize3(d1, d2, d3, d1, d2, d3);
760 MFEM_HOST_DEVICE
static inline
761 int KernelVector3S(
const int &mode,
const double &d12,
762 const double &d13,
const double &d23,
763 double &d1,
double &d2,
double &d3)
776 double c12 = d12, c13 = d13, c23 = d23;
777 double c21, c31, c32;
781 c32 = fabs(d1) + fabs(c12) + fabs(c13);
782 c31 = fabs(d2) + fabs(c12) + fabs(c23);
783 c21 = fabs(d3) + fabs(c13) + fabs(c23);
788 col = (c32 >= c31) ? 1 : 2;
792 col = (c31 >= c21) ? 2 : 3;
824 if (fabs(d1) <= fabs(c13))
826 row = (fabs(d1) <= fabs(c12)) ? 1 : 2;
830 row = (fabs(c12) <= fabs(c13)) ? 2 : 3;
835 if (fabs(d1) >= fabs(c13))
837 row = (fabs(d1) >= fabs(c12)) ? 1 : 2;
841 row = (fabs(c12) >= fabs(c13)) ? 2 : 3;
872 row = KernelVector3G_aux(mode, d1, d2, d3, c12, c13, c23, c21, c31, c32);
888 MFEM_HOST_DEVICE
static inline
889 int Reduce3S(
const int &mode,
890 double &d1,
double &d2,
double &d3,
891 double &d12,
double &d13,
double &d23,
892 double &z1,
double &z2,
double &z3,
893 double &v1,
double &v2,
double &v3,
913 double s, w1, w2, w3;
919 if (fabs(z1) <= fabs(z3))
921 k = (fabs(z1) <= fabs(z2)) ? 1 : 2;
925 k = (fabs(z2) <= fabs(z3)) ? 2 : 3;
931 if (fabs(z1) >= fabs(z3))
933 k = (fabs(z1) >= fabs(z2)) ? 1 : 2;
937 k = (fabs(z2) >= fabs(z3)) ? 2 : 3;
964 g = copysign(1., z1);
965 v1 = -s*(s/(z1 + g));
968 if (fabs(z2) > g) { g = fabs(z2); }
969 if (fabs(z3) > g) { g = fabs(z3); }
973 g = 2./(v1*v1 + v2*v2 + v3*v3);
978 w1 = g*( d1*v1 + d12*v2 + d13*v3);
979 w2 = g*(d12*v1 + d2*v2 + d23*v3);
980 w3 = g*(d13*v1 + d23*v2 + d3*v3);
982 s = (g/2)*(v1*w1 + v2*w2 + v3*w3);
989 d23 -= v2*w3 + v3*w2;
994 s = d12 - v1*w2 - v2*w1;
995 s = d13 - v1*w3 - v3*w1;
1018 template<> MFEM_HOST_DEVICE
inline
1021 double d0 = data[0];
1022 double d2 = data[2];
1023 double d3 = data[3];
1025 internal::Eigensystem2S(d2, d0, d3, c, s);
1049 template<> MFEM_HOST_DEVICE
inline
1052 double d11 = data[0];
1053 double d12 = data[3];
1054 double d22 = data[4];
1055 double d13 = data[6];
1056 double d23 = data[7];
1057 double d33 = data[8];
1061 double d_max = fabs(d11);
1062 if (d_max < fabs(d22)) { d_max = fabs(d22); }
1063 if (d_max < fabs(d33)) { d_max = fabs(d33); }
1064 if (d_max < fabs(d12)) { d_max = fabs(d12); }
1065 if (d_max < fabs(d13)) { d_max = fabs(d13); }
1066 if (d_max < fabs(d23)) { d_max = fabs(d23); }
1068 internal::GetScalingFactor(d_max, mult);
1071 d11 /= mult; d22 /= mult; d33 /= mult;
1072 d12 /= mult; d13 /= mult; d23 /= mult;
1074 double aa = (d11 + d22 + d33)/3;
1075 double c1 = d11 - aa;
1076 double c2 = d22 - aa;
1077 double c3 = d33 - aa;
1081 Q = (2*(d12*d12 + d13*d13 + d23*d23) + c1*c1 + c2*c2 + c3*c3)/6;
1082 R = (c1*(d23*d23 - c2*c3)+ d12*(d12*c3 - 2*d13*d23) + d13*d13*c2)/2;
1086 lambda[0] = lambda[1] = lambda[2] = aa;
1087 vec[0] = 1.; vec[3] = 0.; vec[6] = 0.;
1088 vec[1] = 0.; vec[4] = 1.; vec[7] = 0.;
1089 vec[2] = 0.; vec[5] = 0.; vec[8] = 1.;
1093 double sqrtQ = sqrt(Q);
1094 double sqrtQ3 = Q*sqrtQ;
1098 if (fabs(R) >= sqrtQ3)
1117 r = -2*sqrtQ*cos((acos(R) + 2.0*M_PI)/3);
1121 r = -2*sqrtQ*cos(acos(R)/3);
1145 switch (internal::KernelVector3S(mode, d12, d13, d23, c1, c2, c3))
1149 lambda[0] = lambda[1] = lambda[2] = aa;
1150 vec[0] = 1.; vec[3] = 0.; vec[6] = 0.;
1151 vec[1] = 0.; vec[4] = 1.; vec[7] = 0.;
1152 vec[2] = 0.; vec[5] = 0.; vec[8] = 1.;
1166 double v1, v2, v3, g;
1167 int k = internal::Reduce3S(mode, d11, d22, d33, d12, d13, d23,
1168 c1, c2, c3, v1, v2, v3, g);
1176 internal::Eigensystem2S(d23, d22, d33, c, s);
1179 double *vec_1, *vec_2, *vec_3;
1184 lambda[0] = d11; vec_1 = vec;
1185 lambda[1] = d22; vec_2 = vec + 3;
1186 lambda[2] = d33; vec_3 = vec + 6;
1188 else if (d11 <= d33)
1190 lambda[0] = d11; vec_1 = vec;
1191 lambda[1] = d33; vec_3 = vec + 3;
1192 lambda[2] = d22; vec_2 = vec + 6;
1196 lambda[0] = d33; vec_3 = vec;
1197 lambda[1] = d11; vec_1 = vec + 3;
1198 lambda[2] = d22; vec_2 = vec + 6;
1205 lambda[0] = d22; vec_2 = vec;
1206 lambda[1] = d11; vec_1 = vec + 3;
1207 lambda[2] = d33; vec_3 = vec + 6;
1209 else if (d22 <= d33)
1211 lambda[0] = d22; vec_2 = vec;
1212 lambda[1] = d33; vec_3 = vec + 3;
1213 lambda[2] = d11; vec_1 = vec + 6;
1217 lambda[0] = d33; vec_3 = vec;
1218 lambda[1] = d22; vec_2 = vec + 3;
1219 lambda[2] = d11; vec_1 = vec + 6;
1226 d22 = g*(v2*c - v3*
s);
1227 d33 = g*(v2*s + v3*c);
1228 vec_2[0] = - v1*d22; vec_3[0] = - v1*d33;
1229 vec_2[1] = c - v2*d22; vec_3[1] = s - v2*d33;
1230 vec_2[2] = -s - v3*d22; vec_3[2] = c - v3*d33;
1251 template<> MFEM_HOST_DEVICE
inline
1254 double d0, d1, d2, d3;
1262 double d_max = fabs(d0);
1263 if (d_max < fabs(d1)) { d_max = fabs(d1); }
1264 if (d_max < fabs(d2)) { d_max = fabs(d2); }
1265 if (d_max < fabs(d3)) { d_max = fabs(d3); }
1266 internal::GetScalingFactor(d_max, mult);
1274 double t = 0.5*((d0+d2)*(d0-d2)+(d1-d3)*(d1+d3));
1275 double s = d0*d2 + d1*d3;
1276 s = sqrt(0.5*(d0*d0 + d1*d1 + d2*d2 + d3*d3) + sqrt(t*t + s*s));
1282 t = fabs(d0*d3 - d1*d2) /
s;
1299 template<> MFEM_HOST_DEVICE
inline
1302 double d0, d1, d2, d3, d4, d5, d6, d7, d8;
1303 d0 = data[0]; d3 = data[3]; d6 = data[6];
1304 d1 = data[1]; d4 = data[4]; d7 = data[7];
1305 d2 = data[2]; d5 = data[5]; d8 = data[8];
1308 double d_max = fabs(d0);
1309 if (d_max < fabs(d1)) { d_max = fabs(d1); }
1310 if (d_max < fabs(d2)) { d_max = fabs(d2); }
1311 if (d_max < fabs(d3)) { d_max = fabs(d3); }
1312 if (d_max < fabs(d4)) { d_max = fabs(d4); }
1313 if (d_max < fabs(d5)) { d_max = fabs(d5); }
1314 if (d_max < fabs(d6)) { d_max = fabs(d6); }
1315 if (d_max < fabs(d7)) { d_max = fabs(d7); }
1316 if (d_max < fabs(d8)) { d_max = fabs(d8); }
1317 internal::GetScalingFactor(d_max, mult);
1320 d0 /= mult; d1 /= mult; d2 /= mult;
1321 d3 /= mult; d4 /= mult; d5 /= mult;
1322 d6 /= mult; d7 /= mult; d8 /= mult;
1324 double b11 = d0*d0 + d1*d1 + d2*d2;
1325 double b12 = d0*d3 + d1*d4 + d2*d5;
1326 double b13 = d0*d6 + d1*d7 + d2*d8;
1327 double b22 = d3*d3 + d4*d4 + d5*d5;
1328 double b23 = d3*d6 + d4*d7 + d5*d8;
1329 double b33 = d6*d6 + d7*d7 + d8*d8;
1348 double aa = (b11 + b22 + b33)/3;
1354 double b11_b22 = ((d0-d3)*(d0+d3)+(d1-d4)*(d1+d4)+(d2-d5)*(d2+d5));
1355 double b22_b33 = ((d3-d6)*(d3+d6)+(d4-d7)*(d4+d7)+(d5-d8)*(d5+d8));
1356 double b33_b11 = ((d6-d0)*(d6+d0)+(d7-d1)*(d7+d1)+(d8-d2)*(d8+d2));
1357 c1 = (b11_b22 - b33_b11)/3;
1358 c2 = (b22_b33 - b11_b22)/3;
1359 c3 = (b33_b11 - b22_b33)/3;
1362 Q = (2*(b12*b12 + b13*b13 + b23*b23) + c1*c1 + c2*c2 + c3*c3)/6;
1363 R = (c1*(b23*b23 - c2*c3)+ b12*(b12*c3 - 2*b13*b23) +b13*b13*c2)/2;
1396 double sqrtQ = sqrt(Q);
1397 double sqrtQ3 = Q*sqrtQ;
1402 if (fabs(R) >= sqrtQ3)
1424 aa -= 2*sqrtQ*cos(acos(R)/3);
1428 aa -= 2*sqrtQ*cos((acos(R) + 2.0*M_PI)/3);
1432 aa -= 2*sqrtQ*cos((acos(R) - 2.0*M_PI)/3);
1439 r = -2*sqrtQ*cos((acos(R) + 2.0*M_PI)/3);
1448 r = -2*sqrtQ*cos(acos(R)/3);
1479 switch (internal::KernelVector3S(mode, b12, b13, b23, c1, c2, c3))
1495 double v1, v2, v3, g;
1496 internal::Reduce3S(mode, b11, b22, b33, b12, b13, b23,
1497 c1, c2, c3, v1, v2, v3, g);
1504 internal::Eigenvalues2S(b23, b22, b33);
1508 aa = fmin(fmin(b11, b22), b33);
1514 aa = (b22 <= b33) ? b22 : fmax(b11, b33);
1518 aa = (b11 <= b33) ? b11 : fmax(b33, b22);
1523 aa = fmax(fmax(b11, b22), b33);
1529 return sqrt(fabs(aa))*mult;
1541 inline void LUSolve(
const double *data,
const int m,
const int *ipiv,
1545 for (
int i = 0; i < m; i++)
1547 internal::Swap<double>(x[i], x[ipiv[i]]);
1551 for (
int j = 0; j < m; j++)
1553 const double x_j = x[j];
1554 for (
int i = j + 1; i < m; i++)
1556 x[i] -= data[i + j * m] * x_j;
1561 for (
int j = m - 1; j >= 0; j--)
1563 const double x_j = (x[j] /= data[j + j * m]);
1564 for (
int i = 0; i < j; i++)
1566 x[i] -= data[i + j * m] * x_j;
1575 #endif // MFEM_LINALG_KERNELS_HPP
MFEM_HOST_DEVICE T Det(const T *data)
Compute the determinant of a square matrix of size dim with given data.
MFEM_HOST_DEVICE double DistanceSquared(const double *x, const double *y)
Compute the square of the Euclidean distance to another vector.
MFEM_HOST_DEVICE void FNorm(double &scale_factor, double &scaled_fnorm2, const T *data)
MFEM_HOST_DEVICE void MultABt(const int Aheight, const int Awidth, const int Bheight, const TA *Adata, const TB *Bdata, TC *ABtdata)
Multiply a matrix of size Aheight x Awidth and data Adata with the transpose of a matrix of size Bhei...
MFEM_HOST_DEVICE void Diag(const double c, double *data)
Creates n x n diagonal matrix with diagonal elements c.
MFEM_HOST_DEVICE void Add(const int height, const int width, const TALPHA alpha, const TA *Adata, const TB *Bdata, TC *Cdata)
Compute C = A + alpha*B, where the matrices A, B and C are of size height x width with data Adata...
MFEM_HOST_DEVICE double CalcSingularvalue< 3 >(const double *data, const int i)
Return the i'th singular value of the matrix of size 3 with given data.
MFEM_HOST_DEVICE void CalcEigenvalues(const double *data, double *lambda, double *vec)
MFEM_HOST_DEVICE void CalcEigenvalues< 2 >(const double *data, double *lambda, double *vec)
MFEM_HOST_DEVICE void LUSolve(const double *data, const int m, const int *ipiv, double *x)
Assuming L.U = P.A for a factored matrix (m x m),.
MFEM_HOST_DEVICE double Norml2(const int size, const T *data)
Returns the l2 norm of the Vector with given size and data.
MFEM_HOST_DEVICE void CalcAdjugate(const T *data, T *adj_data)
Return the adjugate of a matrix.
void Swap(Array< T > &, Array< T > &)
MFEM_HOST_DEVICE double CalcSingularvalue(const double *data, const int i)
Return the i'th singular value of the matrix of size dim with given data.
MFEM_HOST_DEVICE double CalcSingularvalue< 2 >(const double *data, const int i)
Return the i'th singular value of the matrix of size 2 with given data.
MFEM_HOST_DEVICE void CalcEigenvalues< 3 >(const double *data, double *lambda, double *vec)
MFEM_HOST_DEVICE void CalcInverse(const T *data, T *inv_data)
Return the inverse of a matrix with given size and data into the matrix with data inv_data...
MFEM_HOST_DEVICE void Subtract(const double a, const double *x, const double *y, double *z)
Vector subtraction operation: z = a * (x - y)
MFEM_HOST_DEVICE void Set(const int height, const int width, const double alpha, const TA *Adata, TB *Bdata)
Compute B = alpha*A, where the matrices A and B are of size height x width with data Adata and Bdata...
MFEM_HOST_DEVICE void Mult(const int height, const int width, TA *data, const TX *x, TY *y)
Matrix vector multiplication: y = A x, where the matrix A is of size height x width with given data...
MFEM_HOST_DEVICE void AddMultVWt(const double *v, const double *w, double *VWt)
Dense matrix operation: VWt += v w^t.
MFEM_HOST_DEVICE void Symmetrize(const int size, T *data)
Symmetrize a square matrix with given size and data: A -> (A+A^T)/2.
MFEM_HOST_DEVICE double FNorm2(const T *data)
Compute the square of the Frobenius norm of the matrix.