From cf4a141e8265b02b2d0b15ddc7e58e686c02a121 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= <klinkjak@fjfi.cvut.cz>
Date: Sat, 2 Mar 2019 14:53:18 +0100
Subject: [PATCH] Fixed bug in Ellpack for rectangular matrices

---
 src/TNL/Matrices/Ellpack_impl.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/TNL/Matrices/Ellpack_impl.h b/src/TNL/Matrices/Ellpack_impl.h
index f3c05c492d..5e757efb96 100644
--- a/src/TNL/Matrices/Ellpack_impl.h
+++ b/src/TNL/Matrices/Ellpack_impl.h
@@ -75,7 +75,7 @@ void Ellpack< Real, Device, Index >::setDimensions( const IndexType rows,
    this->rows = rows;
    this->columns = columns;
    if( std::is_same< Device, Devices::Cuda >::value )
-      this->alignedRows = roundToMultiple( columns, Devices::Cuda::getWarpSize() );
+      this->alignedRows = roundToMultiple( rows, Devices::Cuda::getWarpSize() );
    else this->alignedRows = rows;
    if( this->rowLengths != 0 )
       allocateElements();
@@ -142,7 +142,9 @@ void Ellpack< Real, Device, Index >::setLike( const Ellpack< Real2, Device2, Ind
 {
    Sparse< Real, Device, Index >::setLike( matrix );
    this->rowLengths = matrix.rowLengths;
-   this->alignedRows = matrix.alignedRows;
+   if( std::is_same< Device, Devices::Cuda >::value )
+      this->alignedRows = roundToMultiple( this->getRows(), Devices::Cuda::getWarpSize() );
+   else this->alignedRows = this->getRows();
 }
 
 template< typename Real,
-- 
GitLab