From f25f162b69963727ea6964ab253d35ad8805b07c Mon Sep 17 00:00:00 2001 From: Oliver Sander <sander@igpm.rwth-aachen.de> Date: Fri, 3 Sep 2010 08:26:38 +0000 Subject: [PATCH] add infinity_norm() and operator<< [[Imported from SVN: r6327]] --- dune/gfe/tensor3.hh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/dune/gfe/tensor3.hh b/dune/gfe/tensor3.hh index 11dc9b24..41db5c72 100644 --- a/dune/gfe/tensor3.hh +++ b/dune/gfe/tensor3.hh @@ -14,6 +14,14 @@ class Tensor3 { public: + T infinity_norm() const + { + dune_static_assert(N1>0, "infinity_norm not implemented for empty tensors"); + T norm = (*this)[0].infinity_norm(); + for (int i=1; i<N1; i++) + norm = std::max(norm, (*this)[i].infinity_norm()); + return norm; + } static Tensor3<T,N1,N2,N3> product(const Dune::FieldVector<T,N1>& a, const Dune::FieldVector<T,N2>& b, const Dune::FieldVector<T,N3>& c) { @@ -90,4 +98,15 @@ class Tensor3 }; +//! Output operator for array +template <class T, int N1, int N2, int N3> +inline std::ostream& operator<< (std::ostream& s, const Tensor3<T,N1,N2,N3>& tensor) +{ + for (int i=0; i<N1; i++) + s << tensor[i]; + return s; +} + + + #endif \ No newline at end of file -- GitLab