From 27cb1cfa5e00fe44807e0626845ff147c6400a8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Oberhuber?= <oberhuber.tomas@gmail.com> Date: Sat, 18 Jan 2020 10:45:02 +0100 Subject: [PATCH] Fixed multidiagonal to sparse matrix assignment. --- src/UnitTests/Matrices/SparseMatrixCopyTest.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/UnitTests/Matrices/SparseMatrixCopyTest.h b/src/UnitTests/Matrices/SparseMatrixCopyTest.h index 7f29191b6f..6e1427ad1b 100644 --- a/src/UnitTests/Matrices/SparseMatrixCopyTest.h +++ b/src/UnitTests/Matrices/SparseMatrixCopyTest.h @@ -502,7 +502,7 @@ void multidiagonalMatrixAssignment() MultidiagonalHost hostMatrix( rows, columns, diagonals ); for( IndexType i = 0; i < rows; i++ ) for( IndexType j = 0; j < columns; j++ ) - if( diagonals.containsValue( i - j ) ) + if( diagonals.containsValue( j - i ) ) hostMatrix.setElement( i, j, i + j ); Matrix matrix; @@ -510,15 +510,15 @@ void multidiagonalMatrixAssignment() using RowCapacitiesType = typename Matrix::RowsCapacitiesType; RowCapacitiesType rowCapacities; matrix.getCompressedRowLengths( rowCapacities ); - RowCapacitiesType exactRowLengths{ 1, 3, 3, 3, 3, 3, 3, 3, 3, 2 }; + RowCapacitiesType exactRowLengths{ 3, 4, 5, 5, 6, 5, 5, 4, 4, 3 }; EXPECT_EQ( rowCapacities, exactRowLengths ); for( IndexType i = 0; i < rows; i++ ) for( IndexType j = 0; j < columns; j++ ) { - if( diagonals.containsValue( i - j ) ) - EXPECT_EQ( matrix.getElement( i, j ), 0.0 ); - else + if( diagonals.containsValue( j - i ) ) EXPECT_EQ( matrix.getElement( i, j ), i + j ); + else + EXPECT_EQ( matrix.getElement( i, j ), 0.0 ); } #ifdef HAVE_CUDA @@ -530,10 +530,10 @@ void multidiagonalMatrixAssignment() for( IndexType i = 0; i < rows; i++ ) for( IndexType j = 0; j < columns; j++ ) { - if( diagonals.containsValue( i - j ) > 1 ) - EXPECT_EQ( matrix.getElement( i, j ), 0.0 ); - else + if( diagonals.containsValue( j - i ) ) EXPECT_EQ( matrix.getElement( i, j ), i + j ); + else + EXPECT_EQ( matrix.getElement( i, j ), 0.0 ); } #endif } -- GitLab