From 2f5c199ddf57849a52b7698e748f407c54353294 Mon Sep 17 00:00:00 2001
From: Lukas Cejka <lukas.ostatek@gmail.com>
Date: Tue, 25 Jun 2019 19:56:13 +0200
Subject: [PATCH] Fixed allocation of elements, empty matrices don't throw
 errors now

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

diff --git a/src/TNL/Matrices/Ellpack_impl.h b/src/TNL/Matrices/Ellpack_impl.h
index b71233022b..95a9955a64 100644
--- a/src/TNL/Matrices/Ellpack_impl.h
+++ b/src/TNL/Matrices/Ellpack_impl.h
@@ -803,8 +803,12 @@ void Ellpack< Real, Device, Index >::allocateElements()
    IndexType numMtxElmnts = this->alignedRows * this->rowLengths;
    
    // CORRECT? Can the overflown value pass this assert?
-   TNL_ASSERT_TRUE( this->alignedRows != 0 && numMtxElmnts / this->alignedRows == this->rowLengths, "Ellpack cannot store this matrix. The number of matrix elements has overflown the value that IndexType is capable of storing" );
-
+   if( this->alignedRows != 0 )
+   {
+       TNL_ASSERT_EQ( numMtxElmnts / this->alignedRows, this->rowLengths, 
+                      "Ellpack cannot store this matrix. The number of matrix elements has overflown the value that IndexType is capable of storing" );
+//       TNL_ASSERT_TRUE( this->alignedRows != 0 && numMtxElmnts / this->alignedRows == this->rowLengths, "Ellpack cannot store this matrix. The number of matrix elements has overflown the value that IndexType is capable of storing" );
+   }
    // ORIGINAL from: https://stackoverflow.com/questions/1815367/catch-and-compute-overflow-during-multiplication-of-two-large-integers
 //   if (this->alignedRows != 0 && numMtxElmnts / this->alignedRows != this->rowLengths) {
 //       TNL_ASSERT_FALSE( this->alignedRows != 0 && numMtxElmnts / this->alignedRows != this->rowLengths, "Ellpack cannot store this matrix. The number of matrix elements has overflown the value that IndexType is capable of storing" );
-- 
GitLab