47#include <initializer_list>
55#define _LOOP_FLOATMATRIX(M,r,c) for(std::size_t c=0; c<M.cols(); c++) for(std::size_t r=0; r<M.rows(); r++)
61template<std::
size_t N, std::
size_t M>
64:
public MatrixRCd<N,M>
69 typedef MatrixRCd<N,M> MatrixRCd_NM;
71 const double *
data()
const {
return MatrixRCd_NM::data(); }
72 double *
data() {
return MatrixRCd_NM::data(); }
75 class =
typename std::enable_if_t<
sizeof...(Args) == M*
N>,
76 class = std::enable_if_t<(std::conjunction_v<std::is_same<double, Args>...>)>
79 std::initializer_list<double> ini{ args ... };
82 for(
const double& x: ini){
88 std::size_t
rows()
const{
return MatrixRCd_NM::rows(); }
89 std::size_t
cols()
const{
return MatrixRCd_NM::cols(); }
99 template<
typename... V,
class =
typename std::enable_if_t<
sizeof...(V) ==
N*M> >
111 if ( mat.
rows() !=
N || mat.
cols() != M ) {
112 throw std::out_of_range(
"Can't convert dynamic float matrix of size " +
113 std::to_string(mat.
rows()) +
"x" + std::to_string(mat.
cols()) +
114 " to fixed size " + std::to_string(
N) +
"x" + std::to_string(M));
118 std::copy_n(mat.begin(),
N*M,
values.begin());
120 for(
Index c=0; c<mat.
cols(); c++)
for(
Index r=0; r<mat.
rows(); r++) (*
this)(r,c)=mat(r,c);
139 throw std::out_of_range(
"matrix error on rows : " + std::to_string(i) +
" <= 0");
140 }
else if ( j <= 0 ) {
141 throw std::out_of_range(
"matrix error on rows : " + std::to_string(j) +
" <= 0");
142 }
else if ( i >
N ) {
143 throw std::out_of_range(
"matrix error on rows : " + std::to_string(i) +
" < " + std::to_string(
N));
144 }
else if ( j > M ) {
145 throw std::out_of_range(
"matrix error on rows : " + std::to_string(j) +
" < " + std::to_string(M));
150 std::size_t
rows()
const {
return N; }
152 std::size_t
cols()
const {
return M; }
206 template<std::
size_t R, std::
size_t C>
210 for ( std::size_t i = 0; i < R; ++i ) {
211 for ( std::size_t j = 0; j < C; ++j ) {
212 x(i, j) = (*this)(r[i], c[j]);
224 double at(std::size_t i, std::size_t j)
const
229 return (*
this)(i-1, j-1);
237 inline double &
at(std::size_t i, std::size_t j)
242 return (*
this)(i-1, j-1);
248 for ( std::size_t r = 0; r <
N; ++r) {
249 for ( std::size_t c = 0; c < M; ++c) {
258 template<std::
size_t R, std::
size_t C>
261 for ( std::size_t i = 0; i < R; ++i ) {
262 for ( std::size_t j = 0; j < C; ++j ) {
263 (*this)(r[i], c[j]) += x(i, j);
276 for ( std::size_t i = 0; i <
N; i++ ) {
277 (*this)(i, c) = src[i];
288 for ( std::size_t i = 0; i < M; i++ ) {
289 (*this)(r, i) = src[i];
301 for ( std::size_t i = 0; i <
N; i++ ) {
302 c[i] = (*this)(i, j);
310 template<std::
size_t C,
class =
typename std::enable_if_t<C < M>>
311 FloatArrayF<N> column() const
314 for ( std::
size_t i = 0; i < N; i++ ) {
315 c[i] = (*this)(i, C);
323 template<std::
size_t R,
class =
typename std::enable_if_t<R < N>>
324 FloatArrayF<M> row() const
327 for ( std::
size_t j = 0; j < M; j++ ) {
328 r[j] = (*this)(R, j);
341 template<std::
size_t P>
345 for ( std::size_t i = 0; i <
N; ++i ) {
346 for ( std::size_t j = i; j < M; ++j ) {
348 for ( std::size_t k = 0; k < P; ++k ) {
349 summ += a(k, i) * b(k, j);
351 (*this)(i, j) += summ * dV;
361 void plusDyadSymmUpper(
const FloatArrayF<N> &a,
double dV)
364 for ( std::size_t i = 0; i <
N; ++i ) {
365 for ( std::size_t j = i; j <
N; ++j ) {
366 (*this)(i, j) += a[i] * a[j] * dV;
376 template<std::
size_t P>
377 void plusProductUnsym(
const FloatMatrixF<P,N> &a,
const FloatMatrixF<P,M> &b,
double dV)
380 for ( std::size_t i = 0; i <
N; ++i ) {
381 for ( std::size_t j = 0; j < M; ++j ) {
383 for ( std::size_t k = 0; k < P; ++k ) {
384 summ += a(k, i) * b(k, j);
386 (*this)(i, j) += summ * dV;
396 void plusDyadUnsym(
const FloatArray &a,
const FloatArray &b,
double dV)
399 for ( std::size_t i = 0; i <
N; ++i ) {
400 for ( std::size_t j = 0; j < M; ++j ) {
401 (*this)(i, j) += a[i] * b[j] * dV;
410 for ( std::size_t i = 2; i <= this->rows(); i++ ) {
411 for ( std::size_t j = 1; j < i; j++ ) {
412 this->
at(i, j) = this->
at(j, i);
420 printf(
"%s (%zu x %zu): \n", name.c_str(),
N, M);
421 if ( this->
rows() <= 250 && this->
cols() <= 250 ) {
422 for ( std::size_t i = 0; i < this->
rows(); ++i ) {
423 for ( std::size_t j = 0; j < this->
cols() && j < 100; ++j ) {
424 printf(
"%10.3e ", (*
this)(i, j) );
429 for ( std::size_t i = 0; i < this->
rows() && i < 20; ++i ) {
430 for ( std::size_t j = 0; j < this->
cols() && j < 10; ++j ) {
431 printf(
"%10.3e ", (*
this)(i, j) );
433 if ( this->
cols() > 10 ) printf(
" ...");
436 if ( this->
cols() > 20 ) printf(
" ...\n");
471template<std::
size_t N, std::
size_t M, std::
size_t R, std::
size_t C>
475 for ( std::size_t i = 0; i < R; ++i ) {
476 for ( std::size_t j = 0; j < C; ++j ) {
477 out(r[i], c[j]) = x(i, j);
484template<std::
size_t N, std::
size_t M>
487 out <<
N <<
" " << M <<
" {";
488 for ( std::size_t i = 0; i <
N; ++i ) {
489 for ( std::size_t j = 0; j < M; ++j ) {
490 out <<
" " << x(i, j);
498template<std::
size_t N, std::
size_t M>
506template<std::
size_t N, std::
size_t M>
512template<std::
size_t N, std::
size_t M>
520template<std::
size_t N, std::
size_t M>
528template<std::
size_t N, std::
size_t M>
536template<std::
size_t N, std::
size_t M>
543template<std::
size_t N, std::
size_t M>
550template<std::
size_t N, std::
size_t M>
558template<std::
size_t N, std::
size_t M>
561 for (
auto &val : mat ) {
562 if ( !std::isfinite(val) ) {
573template<std::
size_t N, std::
size_t NSD>
577 for ( std::size_t i = 0; i <
N; ++i ) {
578 for ( std::size_t j = 0; j < NSD; ++j ) {
579 out( j, i * NSD + j ) = n[j];
592 normal[0], normal[1],
593 normal[1], -normal[0]
603 double npn =
dot(tangent, normal);
604 tangent += -npn * normal;
605 tangent /=
norm(tangent);
606 auto bigent =
cross(tangent, normal);
612 out(0, 0) = normal[0];
613 out(0, 1) = normal[1];
614 out(0, 2) = normal[2];
616 out(1, 0) = bigent[0];
617 out(1, 1) = bigent[1];
618 out(1, 2) = bigent[2];
620 out(2, 0) = tangent[0];
621 out(2, 1) = tangent[1];
622 out(2, 2) = tangent[2];
627template<std::
size_t N, std::
size_t M>
631 for ( std::size_t i = 0; i <
N; ++i ) {
632 for ( std::size_t j = 0; j < M; ++j ) {
633 out(j, i) = mat(i, j);
640template<std::
size_t N, std::
size_t M, std::
size_t P>
645 for ( std::size_t i = 0; i <
N; i++ ) {
646 for ( std::size_t j = 0; j < P; j++ ) {
648 for ( std::size_t k = 0; k < M; k++ ) {
649 coeff += a(i, k) * b(k, j);
658template<std::
size_t N, std::
size_t M, std::
size_t P>
663 for ( std::size_t i = 0; i <
N; i++ ) {
664 for ( std::size_t j = 0; j < P; j++ ) {
666 for ( std::size_t k = 0; k < M; k++ ) {
667 coeff += a(i, k) * b(j, k);
676template<std::
size_t N, std::
size_t M, std::
size_t P>
681 for ( std::size_t i = 0; i <
N; i++ ) {
682 for ( std::size_t j = 0; j < P; j++ ) {
684 for ( std::size_t k = 0; k < M; k++ ) {
685 coeff += a(k, i) * b(k, j);
694template<std::
size_t N, std::
size_t M>
698 for ( std::size_t i = 0; i <
N; i++ ) {
700 for ( std::size_t j = 0; j < M; j++ ) {
701 sum += m(i, j) * x[j];
709template<std::
size_t N, std::
size_t M>
713 for ( std::size_t i = 0; i <
N; i++ ) {
715 for ( std::size_t j = 0; j < M; j++ ) {
716 sum += x[j] * m(j, i);
724template<std::
size_t N, std::
size_t M>
731template<std::
size_t N, std::
size_t M>
735 for ( std::size_t i = 0; i <
N; ++i ) {
736 for ( std::size_t j = 0; j < M; ++j ) {
737 out(i, j) = a[i] * b[j];
744template<std::
size_t N, std::
size_t M>
751template<std::
size_t N, std::
size_t M>
760template<std::
size_t N, std::
size_t M>
764 for ( std::size_t row = 0; row <
N; ++row ) {
765 ans[row] = mat(row, col);
825 0.5 * ( t(1, 2) + t(2, 1) ),
826 0.5 * ( t(0, 2) + t(2, 0) ),
827 0.5 * ( t(0, 1) + t(1, 0) )
838 v[0], 0.5*v[5], 0.5*v[4],
839 0.5*v[5], v[1], 0.5*v[3],
840 0.5*v[4], 0.5*v[3], v[2]
854 ( t(1, 2) + t(2, 1) ),
855 ( t(0, 2) + t(2, 0) ),
856 ( t(0, 1) + t(1, 0) )
863template<std::
size_t N>
867 for ( std::size_t i = 0; i <
N; ++i ) {
877template<std::
size_t N>
881 for ( std::size_t i = 0; i <
N; ++i ) {
890template<std::
size_t N, std::
size_t M>
894 for(std::size_t c=0; c<m.
cols(); c++)
for(std::size_t r=0; r<m.
rows(); r++) out[c*m.
rows()+r]=m(r,c);
903void swap_46(FloatMatrixF<6,6> &t)
905 std::swap( t(3, 0), t(5, 0) );
906 std::swap( t(3, 1), t(5, 1) );
907 std::swap( t(3, 2), t(5, 2) );
908 std::swap( t(0, 3), t(0, 5) );
909 std::swap( t(1, 3), t(1, 5) );
910 std::swap( t(2, 3), t(2, 5) );
911 std::swap( t(3, 3), t(5, 5) );
912 std::swap( t(4, 3), t(4, 5) );
913 std::swap( t(5, 3), t(3, 5) );
914 std::swap( t(3, 4), t(5, 4) );
922 std::array<std::size_t, 9> abq2oo = {0, 1, 2, 5, 4, 3, 6, 8, 7};
925 for ( std::size_t i = 0; i < 9; i++ ) {
926 for ( std::size_t j = 0; j < 9; j++ ) {
927 tmp(i, j) = t(abq2oo[ i ], abq2oo[ j ]);
936template<std::
size_t N,std::
size_t M>
943template<std::
size_t N>
947 for ( std::size_t i = 0; i <
N; ++i ) {
955 2./3., -1./3., -1/3., 0., 0., 0.,
956 -1./3., 2./3., -1/3., 0., 0., 0.,
957 -1./3., -1./3., 2/3., 0., 0., 0.,
958 0., 0., 0., 0.5, 0., 0.,
959 0., 0., 0., 0., 0.5, 0.,
960 0., 0., 0., 0., 0., 0.5,
965 1., 1., 1., 0., 0., 0.,
966 1., 1., 1., 0., 0., 0.,
967 1., 1., 1., 0., 0., 0.,
968 0., 0., 0., 0., 0., 0.,
969 0., 0., 0., 0., 0., 0.,
970 0., 0., 0., 0., 0., 0.,
980template<std::
size_t N, std::
size_t NSD>
984 for ( std::size_t i = 0; i <
N; ++i ) {
985 for ( std::size_t j = 0; j < NSD; ++j ) {
986 out( j, i * NSD + j ) = n[j];
993template<std::
size_t N>
997 for ( std::size_t j = 0, k = 0; j < dN.
rows(); j++, k += 3 ) {
998 B(0, k + 0) = B(3, k + 1) = B(4, k + 2) = dN(0, j);
999 B(1, k + 1) = B(3, k + 0) = B(5, k + 2) = dN(1, j);
1000 B(2, k + 2) = B(4, k + 0) = B(5, k + 1) = dN(2, j);
1006template<std::
size_t N>
1010 for ( std::size_t j = 0, k = 0; j <
N; j++, k += 2 ) {
1011 B(0, k + 0) = B(2, k + 1) = dN(0, j);
1012 B(1, k + 1) = B(2, k + 0) = dN(1, j);
1023template<std::
size_t N>
1027 for ( std::size_t i = 0; i <
N; ++i ) {
1038template<std::
size_t N>
1043 return std::sqrt( n );
1052template<std::
size_t N>
1056 double max_col = 0.;
1057 for ( std::size_t j = 0; j <
N; j++ ) {
1058 double col_sum = 0.;
1059 for ( std::size_t i = 0; i <
N; i++ ) {
1060 col_sum += fabs( mat(i, j) );
1062 if ( col_sum > max_col ) {
1067 }
else if ( p == 2 ) {
1069 return sqrt(e.first(0));
1080template<std::
size_t N>
1084 double anorm =
norm(mat, p);
1085 if (
det(mat) <= 1e-6 * anorm ) {
1088 return 1. / (
norm(
inv(mat)) * anorm, p );
1094 return mat(0, 0) * mat(1, 1) - mat(0, 1) * mat(1, 0);
1100 return mat(0, 0) * mat(1, 1) * mat(2, 2) + mat(0, 1) * mat(1, 2) * mat(2, 0) +
1101 mat(0, 2) * mat(1, 0) * mat(2, 1) - mat(0, 2) * mat(1, 1) * mat(2, 0) -
1102 mat(1, 2) * mat(2, 1) * mat(0, 0) - mat(2, 2) * mat(0, 1) * mat(1, 0);
1110 double d =
det(mat);
1111 out(0, 0) = mat(1, 1) / d;
1112 out(1, 0) = -mat(1, 0) / d;
1113 out(0, 1) = -mat(0, 1) / d;
1114 out(1, 1) = mat(0, 0) / d;
1122 double d =
det(mat);
1123 out(0, 0) = ( mat(1, 1) * mat(2, 2) - mat(1, 2) * mat(2, 1) ) / d;
1124 out(1, 0) = ( mat(1, 2) * mat(2, 0) - mat(1, 0) * mat(2, 2) ) / d;
1125 out(2, 0) = ( mat(1, 0) * mat(2, 1) - mat(1, 1) * mat(2, 0) ) / d;
1126 out(0, 1) = ( mat(0, 2) * mat(2, 1) - mat(0, 1) * mat(2, 2) ) / d;
1127 out(1, 1) = ( mat(0, 0) * mat(2, 2) - mat(0, 2) * mat(2, 0) ) / d;
1128 out(2, 1) = ( mat(0, 1) * mat(2, 0) - mat(0, 0) * mat(2, 1) ) / d;
1129 out(0, 2) = ( mat(0, 1) * mat(1, 2) - mat(0, 2) * mat(1, 1) ) / d;
1130 out(1, 2) = ( mat(0, 2) * mat(1, 0) - mat(0, 0) * mat(1, 2) ) / d;
1131 out(2, 2) = ( mat(0, 0) * mat(1, 1) - mat(0, 1) * mat(1, 0) ) / d;
1137template<std::
size_t N>
1140 if constexpr (
N==2)
return inv_22(mat,zeropiv);
1141 if constexpr (
N==3)
return inv_33(mat,zeropiv);
1147 for ( std::size_t i = 1; i <
N; i++ ) {
1148 double piv = tmp.at(i, i);
1149 if ( std::abs(piv) <= zeropiv ) {
1150 OOFEM_ERROR(
"pivot (%d,%d) to close to small", (
int)i, (
int)i);
1152 for ( std::size_t j = i + 1; j <=
N; j++ ) {
1153 double linkomb = tmp.at(j, i) / tmp.at(i, i);
1154 for ( std::size_t k = i; k <=
N; k++ ) {
1155 tmp.at(j, k) -= tmp.at(i, k) * linkomb;
1157 for ( std::size_t k = 1; k <=
N; k++ ) {
1158 out.at(j, k) -= out.at(i, k) * linkomb;
1163 for ( std::size_t i =
N; i > 1; i-- ) {
1164 double piv = tmp.at(i, i);
1165 for ( std::size_t j = i - 1; j > 0; j-- ) {
1166 double linkomb = tmp.at(j, i) / piv;
1167 for ( std::size_t k = i; k > 0; k-- ) {
1168 tmp.at(j, k) -= tmp.at(i, k) * linkomb;
1170 for ( std::size_t k =
N; k > 0; k-- ) {
1171 out.at(j, k) -= out.at(i, k) * linkomb;
1176 for ( std::size_t i = 1; i <=
N; i++ ) {
1177 for ( std::size_t j = 1; j <=
N; j++ ) {
1178 out.at(i, j) /= tmp.at(i, i);
1191template<std::
size_t N>
1198 for ( std::size_t i = 0; i <
N; ++i ) {
1199 for ( std::size_t j = 0; j <
N; ++j ) {
1200 sum += fabs( mat(i, j) );
1211 double tol = pow(c_b2, nf);
1216 for ( std::size_t j = 1; j <
N; ++j ) {
1217 for ( std::size_t i = 0; i < j; ++i ) {
1218 if ( ( fabs( m(i, j) ) /
sum ) > tol ) {
1219 ssum += fabs( m(i, j) );
1221 double aa = atan2( m(i, j) * 2.0, eval[i] - eval[j] ) / 2.0;
1222 double si = sin(aa);
1223 double co = cos(aa);
1247 for ( std::size_t k = 0; k < i; ++k ) {
1248 double tt2 = m(k, i);
1249 m(k, i) = co * tt2 + si * m(k, j);
1250 m(k, j) = -si * tt2 + co * m(k, j);
1252 v(k, i) = co * tt2 + si * v(k, j);
1253 v(k, j) = -si * tt2 + co * v(k, j);
1257 double tt = eval[i];
1258 eval[i] = co * tt + si * m(i, j);
1259 double aij = -si * tt + co * m(i, j);
1261 v(i, i) = co * tt + si * v(i, j);
1262 v(i, j) = -si * tt + co * v(i, j);
1264 for ( std::size_t k = i + 1; k < j; ++k ) {
1265 double tt2 = m(i, k);
1266 m(i, k) = co * tt2 + si * m(k, j);
1267 m(k, j) = -si * tt2 + co * m(k, j);
1269 v(k, i) = co * tt2 + si * v(k, j);
1270 v(k, j) = -si * tt2 + co * v(k, j);
1275 double aji = co * tt + si * eval[j];
1276 eval[j] = -si * tt + co * eval[j];
1279 v(j, i) = co * tt + si * v(j, j);
1280 v(j, j) = -si * tt + co * v(j, j);
1282 for ( std::size_t k = j + 1; k <
N; ++k ) {
1283 double tt2 = m(i, k);
1284 m(i, k) = co * tt2 + si * m(j, k);
1285 m(j, k) = -si * tt2 + co * m(j, k);
1287 v(k, i) = co * tt2 + si * v(k, j);
1288 v(k, j) = -si * tt2 + co * v(k, j);
1292 eval[i] = co * eval[i] + si * aji;
1293 eval[j] = -si * aij + co * eval[j];
1302 throw std::runtime_error(
"eig computation failed");
1304 }
while ( fabs(ssum) /
sum > tol );
1314template<std::
size_t N>
1318 double rtol = 1e-12;
1321 std::array<FloatArrayF<N>,
N> x;
1322 for ( std::size_t i = 0; i <
N; ++i ) {
1326 auto invmat =
inv(mat);
1328 for (
int it = 0; it < nitem; it++ ) {
1331 for ( std::size_t i = 0; i <
N; ++i ) {
1332 x[i] =
dot(invmat, z[i]);
1337 for ( std::size_t i = 0; i <
N; i++ ) {
1338 w[i] =
dot(z[i], x[i]) /
dot(x[i], x[i]);
1344 if ( norm2(old_w - w) <= norm2(w) * rtol ) {
1353template<std::
size_t N>
1356 for ( std::size_t j = 0; j <
N; j++ ) {
1358 for ( std::size_t ii = 0; ii < j; ii++ ) {
1359 x[j] -=
dot(x[ii], t) * x[ii];
1361 x[j] *= 1.0 /
norm(x[j]);
1368inline std::pair<FloatArrayF<2>, FloatMatrixF<2,2>>
eig(
const FloatMatrixF<2,2> &mat,
int nf)
1370 double b = - (mat(0,0) + mat(1,1))/2.;
1371 double c = mat(0,0) * mat(1,1) - mat(0,1) * mat(1,0);
1372 FloatArrayF<2> vals = {
1373 -b + std::sqrt(b*b - c),
1374 -b - std::sqrt(b*b - c)
1378 return {vals, vecs};
1388template<std::
size_t N>
1394 for ( std::size_t i = 0; i <
N - 1; i++ ) {
1396 double piv = fabs( mtrx(i, i) );
1397 std::size_t pivRow = i;
1398 for ( std::size_t j = i + 1; j <
N; j++ ) {
1399 if ( fabs( mtrx(j, i) ) > piv ) {
1401 piv = fabs( mtrx(j, i) );
1405 if ( piv <= zeropiv ) {
1410 if ( pivRow != i ) {
1411 for ( std::size_t j = i; j <
N; j++ ) {
1412 double help = mtrx(i, j);
1413 mtrx(i, j) = mtrx(pivRow, j);
1414 mtrx(pivRow, j) = help;
1416 double help = answer[i];
1417 answer[i] = answer[pivRow];
1418 answer[pivRow] = help;
1421 for ( std::size_t j = i + 1; j <
N; j++ ) {
1422 double linkomb = mtrx(j, i) / mtrx(i, i);
1423 for ( std::size_t k = i; k <
N; k++ ) {
1424 mtrx(j, k) -= mtrx(i, k) * linkomb;
1427 answer[j] -= answer[i] * linkomb;
1432 for (
int i =
N - 1; i >= 0; i-- ) {
1434 for ( std::size_t j = i + 1; j <
N; j++ ) {
1435 help += mtrx(i, j) * answer[j];
1438 answer[i] = ( answer[i] - help ) / mtrx(i, i);
1440 return {
true, answer};
1450template<std::
size_t N>
1457 throw std::runtime_error(
"Singular pivot encountered");
1467template<std::
size_t N, std::
size_t M>
1473 for ( std::size_t i = 0; i <
N - 1; i++ ) {
1475 double piv = fabs( mtrx(i, i) );
1476 std::size_t pivRow = i;
1477 for ( std::size_t j = i + 1; j <
N; j++ ) {
1478 if ( fabs( mtrx(j, i) ) > piv ) {
1480 piv = fabs( mtrx(j, i) );
1484 if ( fabs(piv) < zeropiv ) {
1485 throw std::runtime_error(
"pivot too small, matrix problem could not be solved");
1489 if ( pivRow != i ) {
1490 for ( std::size_t j = i; j <
N; j++ ) {
1491 double help = mtrx(i, j);
1492 mtrx(i, j) = mtrx(pivRow, j);
1493 mtrx(pivRow, j) = help;
1496 for ( std::size_t j = 0; j < M; j++ ) {
1497 double help = answer(i, j);
1498 answer(i, j) = answer(pivRow, j);
1499 answer(pivRow, j) = help;
1503 for ( std::size_t j = i + 1; j <
N; j++ ) {
1504 double linkomb = mtrx(j, i) / mtrx(i, i);
1505 for ( std::size_t k = i; k <
N; k++ ) {
1506 mtrx(j, k) -= mtrx(i, k) * linkomb;
1509 for ( std::size_t k = 0; k < M; k++ ) {
1510 answer(j, k) -= answer(i, k) * linkomb;
1516 for ( std::size_t i =
N - 1; i >= 0; i-- ) {
1517 for ( std::size_t k = 0; k < M; k++ ) {
1519 for ( std::size_t j = i + 1; j <
N; j++ ) {
1520 help += mtrx(i, j) * answer(j, k);
1523 answer(i, k) = ( answer(i, k) - help ) / mtrx(i, i);
virtual int read(int *data, std::size_t count)=0
Reads count integer values into array pointed by data.
virtual int givePackSizeOfDouble(std::size_t count)=0
virtual int write(const int *data, std::size_t count)=0
Writes count integer values from array pointed by data.
contextIOResultType restoreYourself(DataStream &stream)
double operator[](std::size_t i) const
void checkBounds(std::size_t i, std::size_t j) const
void setRow(const FloatArrayF< M > &src, int r)
double & at(std::size_t i, std::size_t j)
contextIOResultType storeYourself(DataStream &stream) const
void setColumn(const FloatArrayF< N > &src, std::size_t c)
double & operator()(std::size_t i, std::size_t j)
FloatMatrixF(const FloatMatrix &mat)
FloatMatrix conversion constructor.
FloatMatrixF(const FloatMatrixF< N, M > &mat) noexcept
Copy constructor.
FloatMatrixF< R, C > operator()(std::size_t const (&r)[R], std::size_t const (&c)[C]) const
std::array< double, N *M > values
Values of matrix stored column wise.
const double * givePointer() const
const double * data() const
FloatArrayF< N > column(std::size_t j) const
double operator()(std::size_t i, std::size_t j) const
double at(std::size_t i, std::size_t j) const
std::size_t cols() const
Returns number of columns of receiver.
FloatMatrixF & operator=(const FloatMatrixF< N, M > &mat)
Assignment operator.
void printYourself(const std::string &name="FloatMatrixF") const
Prints matrix to stdout. Useful for debugging.
double & operator[](std::size_t i)
std::size_t rows() const
Returns number of rows of receiver.
void assemble(const FloatMatrixF< R, C > &x, int const (&r)[R], int const (&c)[C])
Assemble x into self.
static FloatMatrixF< N, M > fromColumns(FloatArrayF< N > const (&x)[M]) noexcept
int givePackSize(DataStream &buff) const
FloatMatrixF(V... x) noexcept
#define _LOOP_FLOATMATRIX(M, r, c)
FloatArrayF< 6 > to_voigt_stress_33(const FloatMatrixF< 3, 3 > &t)
FloatArray operator+(const FloatArray &x, const FloatArray &y)
double norm(const FloatArray &x)
OOFEM_EXPORT FloatArray operator/(const FloatArray &x, const double &a)
FloatArrayF< 6 > to_voigt_strain_33(const FloatMatrixF< 3, 3 > &t)
FloatMatrixF< N *3, NSD > Nmatrix(const FloatArrayF< N > &n)
FloatMatrixF< M, N > transpose(const FloatMatrixF< N, M > &mat)
Constructs transposed matrix.
FloatArray operator-(const FloatArray &x, const FloatArray &y)
FloatMatrixF< N, P > Tdot(const FloatMatrixF< M, N > &a, const FloatMatrixF< M, P > &b)
Computes .
std::pair< bool, FloatArrayF< N > > solve_check(FloatMatrixF< N, N > mtrx, const FloatArrayF< N > &b, double zeropiv=1e-20)
FloatMatrixF< 3, 3 > from_voigt_form_9(const FloatArrayF< 9 > &v)
FloatMatrixF< N, M > dyad(const FloatArrayF< N > &a, const FloatArrayF< M > &b)
Computes the dyadic product .
FloatMatrixF< 3, 3 > from_voigt_strain_6(const FloatArrayF< 6 > &v)
FloatArrayF< N > assemble(const FloatArrayF< M > &x, int const (&c)[M])
Assemble components into zero matrix.
std::pair< FloatArrayF< N >, FloatMatrixF< N, N > > eig(const FloatMatrixF< N, N > &mat, int nf=9)
FloatMatrixF< N, P > dotT(const FloatMatrixF< N, M > &a, const FloatMatrixF< P, M > &b)
Computes .
FloatMatrixF< 3, 3 > from_voigt_stress_6(const FloatArrayF< 6 > &v)
FloatMatrixF< 6, N *3 > Bmatrix_3d(const FloatMatrixF< 3, N > &dN)
Constructs the B matrix for 3D momentum balance problems.
const FloatMatrixF< 6, 6 > I6_I6
I(x)I expressed in Voigt form.
FloatArray & operator+=(FloatArray &x, const FloatArray &y)
std::ostream & operator<<(std ::ostream &out, const Dictionary &r)
double det(const FloatMatrixF< 2, 2 > &mat)
Computes the determinant.
double frobeniusNorm(const FloatMatrixF< N, N > &mat)
FloatArrayF< 9 > to_voigt_form_33(const FloatMatrixF< 3, 3 > &t)
void orthogonalize(std::array< FloatArrayF< N >, N > &x)
FloatArrayF< 3 > cross(const FloatArrayF< 3 > &x, const FloatArrayF< 3 > &y)
Computes $ x \cross y $.
double sum(const FloatArray &x)
double rcond(const FloatMatrixF< N, N > &mat, int p=1)
FloatArrayF< N > solve(FloatMatrixF< N, N > mtrx, const FloatArrayF< N > &b, double zeropiv=1e-20)
FloatMatrixF< M, M > rotate(FloatMatrixF< N, N > &a, const FloatMatrixF< N, M > &r)
Computes .
FloatMatrixF< 3, N *2 > Bmatrix_2d(const FloatMatrixF< 2, N > &dN)
Constructs the B matrix for plane stress momentum balance problems.
const FloatMatrixF< 6, 6 > I_dev6
I_dev matrix in Voigt (stress) form.
FloatMatrixF< N, N > diag(const FloatArrayF< N > &v)
double dot(const FloatArray &x, const FloatArray &y)
bool isfinite(const FloatArray &x)
std::pair< FloatArrayF< N >, FloatMatrixF< N, N > > eig_inverse(const FloatMatrixF< N, N > &mat)
FloatMatrixF< N, M > zero()
Constructs a zero matrix (this is the default behavior when constructing a matrix,...
FloatArray & operator-=(FloatArray &x, const FloatArray &y)
FloatMatrixF< N, N > inv(const FloatMatrixF< N, N > &mat, double zeropiv=1e-24)
Computes the inverse.
FloatMatrixF< 2, 2 > local_cs(const FloatArrayF< 2 > &normal)
FloatMatrixF< M, M > unrotate(FloatMatrixF< N, N > &a, const FloatMatrixF< M, N > &r)
Computes .
FloatMatrixF< 2, 2 > inv_22(const FloatMatrixF< 2, 2 > &mat, double)
Computes the inverse.
FloatArray operator*(const double &a, const FloatArray &x)
FloatMatrixF< 3, 3 > inv_33(const FloatMatrixF< 3, 3 > &mat, double)
Computes the inverse.
void swap_46(FloatArrayF< 6 > &t)
FloatArrayF< N > zeros()
For more readable code.
FloatArray & operator*=(FloatArray &x, const double &a)
Vector multiplication by scalar.
@ CIO_IOERR
General IO error.
double trace(const FloatMatrixF< N, N > &mat)
FloatMatrixF< N, N > eye()
Constructs an identity matrix.
FloatArrayF< N > column(const FloatMatrixF< N, M > &mat, std::size_t col)
FloatArrayF< N *M > flatten(const FloatMatrixF< N, M > &m)