Skip to content
Snippets Groups Projects
Commit 10a73b53 authored by Andreas Dedner's avatar Andreas Dedner
Browse files

make some vector/matrix operations with template argument (FS954)

[[Imported from SVN: r6534]]
parent 5b4e08ac
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
......
......@@ -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 );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment