#pragma once #include #include #include #include #include namespace AMDiS { using Dune::FieldVector; using Dune::FieldMatrix; // some arithmetic operations with FieldVector template ) > FieldVector operator*(FieldVector v, S factor); template ) > FieldVector operator*(S factor, FieldVector v); template ) > FieldVector operator/(FieldVector v, S factor); template FieldVector operator*(FieldVector const& v, FieldVector const& w); template FieldVector operator*(FieldVector const& factor, FieldVector v); template FieldVector operator*(FieldVector v, FieldVector const& factor); // ---------------------------------------------------------------------------- /// Cross-product a 2d-vector = orthogonal vector template FieldVector cross(FieldVector const& a); /// Cross-product of two 3d-vectors template FieldVector cross(FieldVector const& a, FieldVector const& b); /// Dot product (vec1^T * vec2) template auto dot(FieldVector const& vec1, FieldVector const& vec2); template auto operator*(FieldVector const& v, FieldVector const& w); // ---------------------------------------------------------------------------- /// Sum of vector entires. template T sum(FieldVector const& x); template T sum(FieldMatrix const& x); /// Dot-product with the vector itself template auto unary_dot(FieldVector const& x); template auto unary_dot(FieldMatrix const& x); /// Maximum over all vector entries template auto max(FieldVector const& x); template auto max(FieldMatrix const& x); /// Minimum over all vector entries template auto min(FieldVector const& x); template auto min(FieldMatrix const& x); /// Maximum of the absolute values of vector entries template auto abs_max(FieldVector const& x); template auto abs_max(FieldMatrix const& x); /// Minimum of the absolute values of vector entries template auto abs_min(FieldVector const& x); template auto abs_min(FieldMatrix const& x); // ---------------------------------------------------------------------------- /** \ingroup vector_norms * \brief The 1-norm of a vector = sum_i |x_i| **/ template auto one_norm(FieldVector const& x); template auto one_norm(FieldMatrix const& x); /** \ingroup vector_norms * \brief The euklidean 2-norm of a vector = sqrt( sum_i |x_i|^2 ) **/ template auto two_norm(FieldVector const& x); template auto two_norm(FieldMatrix const& x); /** \ingroup vector_norms * \brief The p-norm of a vector = ( sum_i |x_i|^p )^(1/p) **/ template auto p_norm(FieldVector const& x); template 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); template auto infty_norm(FieldMatrix const& x); // ---------------------------------------------------------------------------- /// The euklidean distance between two vectors = |lhs-rhs|_2 template T distance(FieldVector const& lhs, FieldVector const& rhs); // ---------------------------------------------------------------------------- /// Outer product (vec1 * vec2^T) template auto outer(FieldMatrix const& vec1, FieldMatrix const& vec2); // ---------------------------------------------------------------------------- template T det(FieldMatrix const& /*mat*/); /// Determinant of a 1x1 matrix template T det(FieldMatrix const& mat); /// Determinant of a 2x2 matrix template T det(FieldMatrix const& mat); /// Determinant of a 3x3 matrix template T det(FieldMatrix const& mat); /// Determinant of a NxN matrix template T det(FieldMatrix const& mat); /// Return the inverse of the matrix mat template auto inv(FieldMatrix mat); /// Solve the linear system A*x = b template void solve(FieldMatrix const& A, FieldVector& x, FieldVector const& b); /// Gramian determinant = sqrt( det( DT^T * DF ) ) template T gramian(FieldMatrix const& DF); /// Gramian determinant, specialization for 1 column matrices template T gramian(FieldMatrix const& DF); // ---------------------------------------------------------------------------- // some arithmetic operations with FieldMatrix template FieldMatrix trans(FieldMatrix const& A); template ) > FieldMatrix operator*(S scalar, FieldMatrix A); template ) > FieldMatrix operator*(FieldMatrix A, S scalar); template ) > FieldMatrix operator/(FieldMatrix A, S scalar); template FieldMatrix operator+(FieldMatrix A, FieldMatrix const& B); template FieldMatrix operator-(FieldMatrix A, FieldMatrix const& B); template FieldVector operator*(FieldMatrix const& mat, FieldVector const& vec); template FieldMatrix multiplies(FieldMatrix const& A, FieldMatrix const& B); template FieldMatrix multiplies_AtB(FieldMatrix const& A, FieldMatrix const& B); template FieldMatrix multiplies_ABt(FieldMatrix const& A, FieldMatrix const& B); template FieldMatrix& multiplies_ABt(FieldMatrix const& A, FieldMatrix const& B, FieldMatrix& C); template FieldMatrix& multiplies_ABt(FieldMatrix const& A, Dune::DiagonalMatrix const& B, FieldMatrix& C); } // end namespace AMDiS #include "FieldMatVec.inc.hpp"