From 8698d81a3b425b17590950bf3e2db0f1f9f98be7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= <klinkjak@fjfi.cvut.cz>
Date: Sat, 1 Sep 2018 23:57:45 +0200
Subject: [PATCH] Fixed template parameters for performSORIteration

The x and b vectors might have different type.
---
 src/Python/pytnl/tnl/SparseMatrix.h    |  2 +-
 src/TNL/Matrices/CSR.h                 |  6 +++---
 src/TNL/Matrices/CSR_impl.h            |  6 +++---
 src/TNL/Matrices/ChunkedEllpack.h      |  6 +++---
 src/TNL/Matrices/ChunkedEllpack_impl.h | 10 +++++-----
 src/TNL/Matrices/Dense.h               |  6 +++---
 src/TNL/Matrices/Dense_impl.h          | 10 +++++-----
 src/TNL/Matrices/Ellpack.h             |  6 +++---
 src/TNL/Matrices/Ellpack_impl.h        | 10 +++++-----
 src/TNL/Matrices/Multidiagonal.h       |  6 +++---
 src/TNL/Matrices/Multidiagonal_impl.h  | 10 +++++-----
 src/TNL/Matrices/SlicedEllpack.h       |  6 +++---
 src/TNL/Matrices/SlicedEllpack_impl.h  | 10 +++++-----
 src/TNL/Matrices/Tridiagonal.h         |  6 +++---
 src/TNL/Matrices/Tridiagonal_impl.h    | 10 +++++-----
 15 files changed, 55 insertions(+), 55 deletions(-)

diff --git a/src/Python/pytnl/tnl/SparseMatrix.h b/src/Python/pytnl/tnl/SparseMatrix.h
index 5d278ae8a1..7f8aa04047 100644
--- a/src/Python/pytnl/tnl/SparseMatrix.h
+++ b/src/Python/pytnl/tnl/SparseMatrix.h
@@ -99,7 +99,7 @@ void export_Matrix( py::module & m, const char* name )
         // TODO: these two don't work
         //.def("addMatrix",           &Matrix::addMatrix)
         //.def("getTransposition",    &Matrix::getTransposition)
-        .def("performSORIteration", &Matrix::template performSORIteration< VectorType >)
+        .def("performSORIteration", &Matrix::template performSORIteration< VectorType, VectorType >)
 //        .def("assign",              &Matrix::operator=)
         .def("assign", []( Matrix& matrix, const Matrix& other ) -> Matrix& {
                 return matrix = other;
diff --git a/src/TNL/Matrices/CSR.h b/src/TNL/Matrices/CSR.h
index c6d7dd5b7f..f6d4c6d31b 100644
--- a/src/TNL/Matrices/CSR.h
+++ b/src/TNL/Matrices/CSR.h
@@ -164,10 +164,10 @@ public:
    void getTransposition( const CSR< Real2, Device, Index2 >& matrix,
                           const RealType& matrixMultiplicator = 1.0 );
 
-   template< typename Vector >
-   bool performSORIteration( const Vector& b,
+   template< typename Vector1, typename Vector2 >
+   bool performSORIteration( const Vector1& b,
                              const IndexType row,
-                             Vector& x,
+                             Vector2& x,
                              const RealType& omega = 1.0 ) const;
 
    // copy assignment
diff --git a/src/TNL/Matrices/CSR_impl.h b/src/TNL/Matrices/CSR_impl.h
index 9e22c5a9d6..1516e93223 100644
--- a/src/TNL/Matrices/CSR_impl.h
+++ b/src/TNL/Matrices/CSR_impl.h
@@ -494,10 +494,10 @@ void CSR< Real, Device, Index >::getTransposition( const CSR< Real2, Device, Ind
 template< typename Real,
           typename Device,
           typename Index >
-   template< typename Vector >
-bool CSR< Real, Device, Index >::performSORIteration( const Vector& b,
+   template< typename Vector1, typename Vector2 >
+bool CSR< Real, Device, Index >::performSORIteration( const Vector1& b,
                                                       const IndexType row,
-                                                      Vector& x,
+                                                      Vector2& x,
                                                       const RealType& omega ) const
 {
    TNL_ASSERT( row >=0 && row < this->getRows(),
diff --git a/src/TNL/Matrices/ChunkedEllpack.h b/src/TNL/Matrices/ChunkedEllpack.h
index ba14092163..8c4a47a320 100644
--- a/src/TNL/Matrices/ChunkedEllpack.h
+++ b/src/TNL/Matrices/ChunkedEllpack.h
@@ -224,10 +224,10 @@ public:
    void getTransposition( const ChunkedEllpack< Real2, Device, Index2 >& matrix,
                           const RealType& matrixMultiplicator = 1.0 );
 
-   template< typename Vector >
-   bool performSORIteration( const Vector& b,
+   template< typename Vector1, typename Vector2 >
+   bool performSORIteration( const Vector1& b,
                              const IndexType row,
-                             Vector& x,
+                             Vector2& x,
                              const RealType& omega = 1.0 ) const;
 
    // copy assignment
diff --git a/src/TNL/Matrices/ChunkedEllpack_impl.h b/src/TNL/Matrices/ChunkedEllpack_impl.h
index 5c5c71543c..1a47fe4e60 100644
--- a/src/TNL/Matrices/ChunkedEllpack_impl.h
+++ b/src/TNL/Matrices/ChunkedEllpack_impl.h
@@ -1154,11 +1154,11 @@ void ChunkedEllpack< Real, Device, Index >::getTransposition( const ChunkedEllpa
 template< typename Real,
           typename Device,
           typename Index >
-   template< typename Vector >
-bool ChunkedEllpack< Real, Device, Index >::performSORIteration( const Vector& b,
-                                                                                    const IndexType row,
-                                                                                    Vector& x,
-                                                                                    const RealType& omega ) const
+   template< typename Vector1, typename Vector2 >
+bool ChunkedEllpack< Real, Device, Index >::performSORIteration( const Vector1& b,
+                                                                 const IndexType row,
+                                                                 Vector2& x,
+                                                                 const RealType& omega ) const
 {
    TNL_ASSERT( row >=0 && row < this->getRows(),
               std::cerr << "row = " << row
diff --git a/src/TNL/Matrices/Dense.h b/src/TNL/Matrices/Dense.h
index 3904f5c059..bb7a156c20 100644
--- a/src/TNL/Matrices/Dense.h
+++ b/src/TNL/Matrices/Dense.h
@@ -177,10 +177,10 @@ public:
    void getTransposition( const Matrix& matrix,
                           const RealType& matrixMultiplicator = 1.0 );
 
-   template< typename Vector >
-   void performSORIteration( const Vector& b,
+   template< typename Vector1, typename Vector2 >
+   void performSORIteration( const Vector1& b,
                              const IndexType row,
-                             Vector& x,
+                             Vector2& x,
                              const RealType& omega = 1.0 ) const;
 
    // copy assignment
diff --git a/src/TNL/Matrices/Dense_impl.h b/src/TNL/Matrices/Dense_impl.h
index 64d154779d..36610ac78d 100644
--- a/src/TNL/Matrices/Dense_impl.h
+++ b/src/TNL/Matrices/Dense_impl.h
@@ -847,11 +847,11 @@ void Dense< Real, Device, Index >::getTransposition( const Matrix& matrix,
 template< typename Real,
           typename Device,
           typename Index >
-   template< typename Vector >
-void Dense< Real, Device, Index >::performSORIteration( const Vector& b,
-                                                                 const IndexType row,
-                                                                 Vector& x,
-                                                                 const RealType& omega ) const
+   template< typename Vector1, typename Vector2 >
+void Dense< Real, Device, Index >::performSORIteration( const Vector1& b,
+                                                        const IndexType row,
+                                                        Vector2& x,
+                                                        const RealType& omega ) const
 {
    RealType sum( 0.0 ), diagonalValue;
    for( IndexType i = 0; i < this->getColumns(); i++ )
diff --git a/src/TNL/Matrices/Ellpack.h b/src/TNL/Matrices/Ellpack.h
index 3b4b00b3e0..38333685bf 100644
--- a/src/TNL/Matrices/Ellpack.h
+++ b/src/TNL/Matrices/Ellpack.h
@@ -161,10 +161,10 @@ public:
    void getTransposition( const Ellpack< Real2, Device, Index2 >& matrix,
                           const RealType& matrixMultiplicator = 1.0 );
 
-   template< typename Vector >
-   bool performSORIteration( const Vector& b,
+   template< typename Vector1, typename Vector2 >
+   bool performSORIteration( const Vector1& b,
                              const IndexType row,
-                             Vector& x,
+                             Vector2& x,
                              const RealType& omega = 1.0 ) const;
 
    template< typename Vector >
diff --git a/src/TNL/Matrices/Ellpack_impl.h b/src/TNL/Matrices/Ellpack_impl.h
index be72eb42e3..9801b6bcac 100644
--- a/src/TNL/Matrices/Ellpack_impl.h
+++ b/src/TNL/Matrices/Ellpack_impl.h
@@ -540,11 +540,11 @@ void Ellpack< Real, Device, Index >::getTransposition( const Ellpack< Real2, Dev
 template< typename Real,
           typename Device,
           typename Index >
-   template< typename Vector >
-bool Ellpack< Real, Device, Index > :: performSORIteration( const Vector& b,
-                                                                           const IndexType row,
-                                                                           Vector& x,
-                                                                           const RealType& omega ) const
+   template< typename Vector1, typename Vector2 >
+bool Ellpack< Real, Device, Index > :: performSORIteration( const Vector1& b,
+                                                            const IndexType row,
+                                                            Vector2& x,
+                                                            const RealType& omega ) const
 {
    TNL_ASSERT( row >=0 && row < this->getRows(),
               std::cerr << "row = " << row
diff --git a/src/TNL/Matrices/Multidiagonal.h b/src/TNL/Matrices/Multidiagonal.h
index 28de74b8ac..9b8f18779c 100644
--- a/src/TNL/Matrices/Multidiagonal.h
+++ b/src/TNL/Matrices/Multidiagonal.h
@@ -177,10 +177,10 @@ public:
    void getTransposition( const Multidiagonal< Real2, Device, Index2 >& matrix,
                           const RealType& matrixMultiplicator = 1.0 );
 
-   template< typename Vector >
-   bool performSORIteration( const Vector& b,
+   template< typename Vector1, typename Vector2 >
+   bool performSORIteration( const Vector1& b,
                              const IndexType row,
-                             Vector& x,
+                             Vector2& x,
                              const RealType& omega = 1.0 ) const;
 
    // copy assignment
diff --git a/src/TNL/Matrices/Multidiagonal_impl.h b/src/TNL/Matrices/Multidiagonal_impl.h
index 47d827b93d..5f7228d698 100644
--- a/src/TNL/Matrices/Multidiagonal_impl.h
+++ b/src/TNL/Matrices/Multidiagonal_impl.h
@@ -576,11 +576,11 @@ void Multidiagonal< Real, Device, Index >::getTransposition( const Multidiagonal
 template< typename Real,
           typename Device,
           typename Index >
-   template< typename Vector >
-bool Multidiagonal< Real, Device, Index > :: performSORIteration( const Vector& b,
-                                                                           const IndexType row,
-                                                                           Vector& x,
-                                                                           const RealType& omega ) const
+   template< typename Vector1, typename Vector2 >
+bool Multidiagonal< Real, Device, Index > :: performSORIteration( const Vector1& b,
+                                                                  const IndexType row,
+                                                                  Vector2& x,
+                                                                  const RealType& omega ) const
 {
    TNL_ASSERT( row >=0 && row < this->getRows(),
               std::cerr << "row = " << row
diff --git a/src/TNL/Matrices/SlicedEllpack.h b/src/TNL/Matrices/SlicedEllpack.h
index 0557d26ebb..815728d7a5 100644
--- a/src/TNL/Matrices/SlicedEllpack.h
+++ b/src/TNL/Matrices/SlicedEllpack.h
@@ -187,10 +187,10 @@ public:
    void getTransposition( const SlicedEllpack< Real2, Device, Index2 >& matrix,
                           const RealType& matrixMultiplicator = 1.0 );
 
-   template< typename Vector >
-   bool performSORIteration( const Vector& b,
+   template< typename Vector1, typename Vector2 >
+   bool performSORIteration( const Vector1& b,
                              const IndexType row,
-                             Vector& x,
+                             Vector2& x,
                              const RealType& omega = 1.0 ) const;
 
    // copy assignment
diff --git a/src/TNL/Matrices/SlicedEllpack_impl.h b/src/TNL/Matrices/SlicedEllpack_impl.h
index 52288c650f..2ff01b49c5 100644
--- a/src/TNL/Matrices/SlicedEllpack_impl.h
+++ b/src/TNL/Matrices/SlicedEllpack_impl.h
@@ -562,11 +562,11 @@ template< typename Real,
           typename Device,
           typename Index,
           int SliceSize >
-   template< typename Vector >
-bool SlicedEllpack< Real, Device, Index, SliceSize >::performSORIteration( const Vector& b,
-                                                                                    const IndexType row,
-                                                                                    Vector& x,
-                                                                                    const RealType& omega ) const
+   template< typename Vector1, typename Vector2 >
+bool SlicedEllpack< Real, Device, Index, SliceSize >::performSORIteration( const Vector1& b,
+                                                                           const IndexType row,
+                                                                           Vector2& x,
+                                                                           const RealType& omega ) const
 {
    TNL_ASSERT( row >=0 && row < this->getRows(),
               std::cerr << "row = " << row
diff --git a/src/TNL/Matrices/Tridiagonal.h b/src/TNL/Matrices/Tridiagonal.h
index 0769ca83f2..472cadffcd 100644
--- a/src/TNL/Matrices/Tridiagonal.h
+++ b/src/TNL/Matrices/Tridiagonal.h
@@ -167,11 +167,11 @@ public:
    void getTransposition( const Tridiagonal< Real2, Device, Index2 >& matrix,
                           const RealType& matrixMultiplicator = 1.0 );
 
-   template< typename Vector >
+   template< typename Vector1, typename Vector2 >
    __cuda_callable__
-   void performSORIteration( const Vector& b,
+   void performSORIteration( const Vector1& b,
                              const IndexType row,
-                             Vector& x,
+                             Vector2& x,
                              const RealType& omega = 1.0 ) const;
 
    // copy assignment
diff --git a/src/TNL/Matrices/Tridiagonal_impl.h b/src/TNL/Matrices/Tridiagonal_impl.h
index f3c073cd0d..66fe9d7e80 100644
--- a/src/TNL/Matrices/Tridiagonal_impl.h
+++ b/src/TNL/Matrices/Tridiagonal_impl.h
@@ -535,12 +535,12 @@ void Tridiagonal< Real, Device, Index >::getTransposition( const Tridiagonal< Re
 template< typename Real,
           typename Device,
           typename Index >
-   template< typename Vector >
+   template< typename Vector1, typename Vector2 >
 __cuda_callable__
-void Tridiagonal< Real, Device, Index >::performSORIteration( const Vector& b,
-                                                                       const IndexType row,
-                                                                       Vector& x,
-                                                                       const RealType& omega ) const
+void Tridiagonal< Real, Device, Index >::performSORIteration( const Vector1& b,
+                                                              const IndexType row,
+                                                              Vector2& x,
+                                                              const RealType& omega ) const
 {
    RealType sum( 0.0 );
    if( row > 0 )
-- 
GitLab