Commit 45abb132 by Praetorius, Simon

### Merge branch 'issue/clang_errors' into 'develop'

several issues found by clang corrected, especiall related to FieldMatVec…

See merge request !11
(std::abs(b)); }; return std::pow( Impl::accumulate(x, T(0), op), 1.0/p ); } auto p_norm(FieldMatrix const& x); /** \ingroup vector_norms * \brief The infty-norm of a vector = max_i |x_i| = alias for \ref abs_max **/ template auto infty_norm(FieldVector const& x) { return abs_max(x); } auto infty_norm(FieldVector const& x); template auto infty_norm(FieldMatrix const& x) { return abs_max(x); } auto infty_norm(FieldMatrix const& x); // ---------------------------------------------------------------------------- /// The euklidean distance between two vectors = |lhs-rhs|_2 template T distance(FieldVector const& lhs, FieldVector const& rhs) { T result = 0; for (int i = 0; i < N; ++i) result += Math::sqr(lhs[i] - rhs[i]); return std::sqrt(result); } T distance(FieldVector const& lhs, FieldVector const& rhs); // ---------------------------------------------------------------------------- /// Outer product (vec1 * vec2^T) template auto outer(FieldMatrix const& vec1, FieldMatrix const& vec2) { using result_type = FieldMatrix() * std::declval() ), N, M>; result_type mat; for (int i = 0; i < N; ++i) for (int j = 0; j < M; ++j) mat[i][j] = vec1[i].dot(vec2[j]); return mat; } auto outer(FieldMatrix const& vec1, FieldMatrix const& vec2); // ---------------------------------------------------------------------------- template T det(FieldMatrix const& /*mat*/) { return 0; } T det(FieldMatrix const& /*mat*/); /// Determinant of a 1x1 matrix template T det(FieldMatrix const& mat) { return mat[0][0]; } T det(FieldMatrix const& mat); /// Determinant of a 2x2 matrix template T det(FieldMatrix const& mat) { return mat[0][0]*mat[1][1] - mat[0][1]*mat[1][0]; } T det(FieldMatrix const& mat); /// Determinant of a 3x3 matrix template T det(FieldMatrix const& mat) { return mat[0][0]*mat[1][1]*mat[2][2] + mat[0][1]*mat[1][2]*mat[2][0] + mat[0][2]*mat[1][0]*mat[2][1] - (mat[0][2]*mat[1][1]*mat[2][0] + mat[0][1]*mat[1][0]*mat[2][2] + mat[0][0]*mat[1][2]*mat[2][1]); } T det(FieldMatrix const& mat); /// Determinant of a NxN matrix template T det(FieldMatrix const& mat) { return mat.determinant(); } T det(FieldMatrix const& mat); /// Return the inverse of the matrix mat template auto inv(FieldMatrix mat) { mat.invert(); return mat; } auto inv(FieldMatrix mat); /// Solve the linear system A*x = b template void solve(FieldMatrix const& A, FieldVector& x, FieldVector const& b) { A.solve(x, b); } void solve(FieldMatrix const& A, FieldVector& x, FieldVector const& b); /// Gramian determinant = sqrt( det( DT^T * DF ) ) template T gramian(FieldMatrix const& DF) { using std::sqrt; return sqrt( det(outer(DF, DF)) ); } T gramian(FieldMatrix const& DF); /// Gramian determinant, specialization for 1 column matrices template T gramian(FieldMatrix const& DF) { using std::sqrt; return sqrt(dot(DF[0], DF[0])); } T gramian(FieldMatrix const& DF); // ---------------------------------------------------------------------------- // some arithmetic operations with FieldMatrix template FieldMatrix trans(FieldMatrix const& A) { FieldMatrix At; for (int i = 0; i < M; ++i) for (int j = 0; j < N; ++j) At[j][i] = A[i][j]; return At; } FieldMatrix trans(FieldMatrix const& A); template ) > FieldMatrix operator*(S scalar, FieldMatrix A) { return A *= scalar; } FieldMatrix operator*(S scalar, FieldMatrix A); template ) > FieldMatrix operator*(FieldMatrix A, S scalar) { return A *= scalar; } FieldMatrix operator*(FieldMatrix A, S scalar); template ) > FieldMatrix operator/(FieldMatrix A, S scalar) { return A /= scalar; } FieldMatrix operator/(FieldMatrix A, S scalar); template FieldMatrix operator+(FieldMatrix A, FieldMatrix const& B) { return A += B; } FieldMatrix operator+(FieldMatrix A, FieldMatrix const& B); template FieldMatrix operator-(FieldMatrix A, FieldMatrix const& B) { return A -= B; } FieldMatrix operator-(FieldMatrix A, FieldMatrix const& B); template FieldVector operator*(FieldMatrix const& mat, FieldVector const& vec) { return Dune::FMatrixHelp::mult(mat, vec); } FieldVector operator*(FieldMatrix const& mat, FieldVector const& vec); template FieldMatrix multiplies(FieldMatrix const& A, FieldMatrix const& B) { return A.rightmultiplyany(B); } FieldMatrix multiplies(FieldMatrix const& A, FieldMatrix const& B); template FieldMatrix multiplies_AtB(FieldMatrix const& A, FieldMatrix const& B) { FieldMatrix C; for (int m = 0; m < M; ++m) { for (int n = 0; n < N; ++n) { C[m][n] = 0; for (int l = 0; l < L; ++l) C[m][n] += A[l][m] * B[n][l]; } } return C; } FieldMatrix multiplies_AtB(FieldMatrix const& A, FieldMatrix const& B); template FieldMatrix multiplies_ABt(FieldMatrix const& A, FieldMatrix const& B) { FieldMatrix C; for (int m = 0; m < M; ++m) { for (int n = 0; n < N; ++n) { C[m][n] = 0; for (int l = 0; l < L; ++l) C[m][n] += A[m][l] * B[n][l]; } } return C; } FieldMatrix multiplies_ABt(FieldMatrix const& A, FieldMatrix const& B); template FieldMatrix& multiplies_ABt(FieldMatrix const& A, FieldMatrix const& B, FieldMatrix& C) { for (int m = 0; m < M; ++m) { for (int n = 0; n < N; ++n) { C[m][n] = 0; for (int l = 0; l < L; ++l) C[m][n] += A[m][l] * B[n][l]; } } return C; } FieldMatrix& multiplies_ABt(FieldMatrix const& A, FieldMatrix const& B, FieldMatrix& C); template FieldMatrix& multiplies_ABt(FieldMatrix const& A, Dune::DiagonalMatrix const& B, FieldMatrix& C) { for (int m = 0; m < M; ++m) { for (int n = 0; n < N; ++n) { C[m][n] = A[m][n] * B.diagonal(n); } } return C; } FieldMatrix& multiplies_ABt(FieldMatrix const& A, Dune::DiagonalMatrix const& B, FieldMatrix& C); } // end namespace AMDiS #include "FieldMatVec.inc.hpp"