From c67f1184ed8fc4108de991ae0aaa48243be7c089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Oberhuber?= <oberhuber.tomas@gmail.com> Date: Tue, 4 May 2021 14:44:28 +0200 Subject: [PATCH] Fixed RealType definition in SparseMatrixView - removing const. --- src/TNL/Matrices/SparseMatrixView.h | 4 ++-- src/TNL/Matrices/SparseMatrixView.hpp | 12 +++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/TNL/Matrices/SparseMatrixView.h b/src/TNL/Matrices/SparseMatrixView.h index ba73ea651f..29371c8028 100644 --- a/src/TNL/Matrices/SparseMatrixView.h +++ b/src/TNL/Matrices/SparseMatrixView.h @@ -98,7 +98,7 @@ class SparseMatrixView : public MatrixView< Real, Device, Index > /** * \brief The type of matrix elements. */ - using RealType = Real; + using RealType = std::remove_const_t< Real >; using ComputeRealType = ComputeReal; @@ -942,7 +942,7 @@ class SparseMatrixView : public MatrixView< Real, Device, Index > } }; -} // namespace Conatiners + } // namespace Matrices } // namespace TNL #include <TNL/Matrices/SparseMatrixView.hpp> diff --git a/src/TNL/Matrices/SparseMatrixView.hpp b/src/TNL/Matrices/SparseMatrixView.hpp index 72377f8478..63220888af 100644 --- a/src/TNL/Matrices/SparseMatrixView.hpp +++ b/src/TNL/Matrices/SparseMatrixView.hpp @@ -80,8 +80,8 @@ getConstView() const -> ConstViewType return ConstViewType( this->getRows(), this->getColumns(), this->getValues().getConstView(), - this->getColumnsIndexes().getConstView(), - this->segments.getConstView() ); + this->getColumnIndexes().getConstView(), + const_cast< SparseMatrixView* >( this )->segments.getView() ); } template< typename Real, @@ -862,14 +862,12 @@ SparseMatrixView< Real, Device, Index, MatrixType, SegmentsView, ComputeReal >:: operator==( const Matrix& m ) const { const auto& view1 = *this; - // FIXME: getConstView does not work - //const auto view2 = m.getConstView(); - const auto view2 = m.getView(); + const auto view2 = m.getConstView(); auto fetch = [=] __cuda_callable__ ( const IndexType i ) -> bool { return view1.getRow( i ) == view2.getRow( i ); }; - return Algorithms::reduce< DeviceType >( (IndexType) 0, this->getRows(), fetch, std::logical_and<>{}, true ); + return Algorithms::reduce< DeviceType >( ( IndexType ) 0, this->getRows(), fetch, std::logical_and<>{}, true ); } template< typename Real, @@ -896,7 +894,7 @@ void SparseMatrixView< Real, Device, Index, MatrixType, SegmentsView, ComputeReal >:: save( File& file ) const { - MatrixView< RealType, DeviceType, IndexType >::save( file ); + MatrixView< Real, Device, Index >::save( file ); file << this->columnIndexes; this->segments.save( file ); } -- GitLab