diff --git a/dune/common/densematrix.hh b/dune/common/densematrix.hh index e3132e87a02d9032ec1d1e815b461ce2685dce26..43ec7283fe5aeb3dc3bb6311b4fe87e80066e06e 100644 --- a/dune/common/densematrix.hh +++ b/dune/common/densematrix.hh @@ -297,7 +297,8 @@ namespace Dune //===== vector space arithmetic //! vector space addition - DenseMatrix& operator+= (const DenseMatrix& y) + template <class Other> + DenseMatrix& operator+= (const DenseMatrix<Other>& y) { for (size_type i=0; i<rows(); i++) (*this)[i] += y[i]; @@ -305,7 +306,8 @@ namespace Dune } //! vector space subtraction - DenseMatrix& operator-= (const DenseMatrix& y) + template <class Other> + DenseMatrix& operator-= (const DenseMatrix<Other>& y) { for (size_type i=0; i<rows(); i++) (*this)[i] -= y[i]; @@ -329,7 +331,8 @@ namespace Dune } //! vector space axpy operation (*this += k y) - DenseMatrix &axpy (const field_type &k, const DenseMatrix &y ) + template <class Other> + DenseMatrix &axpy (const field_type &k, const DenseMatrix<Other> &y ) { for( size_type i = 0; i < rows(); ++i ) (*this)[ i ].axpy( k, y[ i ] ); @@ -337,7 +340,8 @@ namespace Dune } //! Binary matrix comparison - bool operator== (const DenseMatrix& y) const + template <class Other> + bool operator== (const DenseMatrix<Other>& y) const { for (size_type i=0; i<rows(); i++) if ((*this)[i]!=y[i]) @@ -345,7 +349,8 @@ namespace Dune return true; } //! Binary matrix incomparison - bool operator!= (const DenseMatrix& y) const + template <class Other> + bool operator!= (const DenseMatrix<Other>& y) const { return !operator==(y); } diff --git a/dune/common/densevector.hh b/dune/common/densevector.hh index bd118632cf4e1f4e68579894517c6b0827afe0fe..995fe59c90a37c5ea42e3fce039c46ab40c91566 100644 --- a/dune/common/densevector.hh +++ b/dune/common/densevector.hh @@ -393,7 +393,8 @@ namespace Dune { //===== vector space arithmetic //! vector space addition - derived_type& operator+= (const DenseVector& y) + template <class Other> + derived_type& operator+= (const DenseVector<Other>& y) { assert(y.size() == size()); for (size_type i=0; i<size(); i++) @@ -402,7 +403,8 @@ namespace Dune { } //! vector space subtraction - derived_type& operator-= (const DenseVector& y) + template <class Other> + derived_type& operator-= (const DenseVector<Other>& y) { assert(y.size() == size()); for (size_type i=0; i<size(); i++) @@ -411,14 +413,16 @@ namespace Dune { } //! Binary vector addition - derived_type operator+ (const DenseVector& b) const + template <class Other> + derived_type operator+ (const DenseVector<Other>& b) const { derived_type z = asImp(); return (z+=b); } //! Binary vector subtraction - derived_type operator- (const DenseVector& b) const + template <class Other> + derived_type operator- (const DenseVector<Other>& b) const { derived_type z = asImp(); return (z-=b); @@ -457,7 +461,8 @@ namespace Dune { } //! Binary vector comparison - bool operator== (const DenseVector& y) const + template <class Other> + bool operator== (const DenseVector<Other>& y) const { assert(y.size() == size()); for (size_type i=0; i<size(); i++) @@ -468,14 +473,16 @@ namespace Dune { } //! Binary vector incomparison - bool operator!= (const DenseVector& y) const + template <class Other> + bool operator!= (const DenseVector<Other>& y) const { return !operator==(y); } //! vector space axpy operation ( *this += a y ) - derived_type& axpy (const value_type& a, const DenseVector& y) + template <class Other> + derived_type& axpy (const value_type& a, const DenseVector<Other>& y) { assert(y.size() == size()); for (size_type i=0; i<size(); i++) @@ -486,7 +493,8 @@ namespace Dune { //===== Euclidean scalar product //! scalar product (x^T y) - value_type operator* (const DenseVector& y) const + template <class Other> + value_type operator* (const DenseVector<Other>& y) const { assert(y.size() == size()); value_type result( 0 );