From 4a70c74f04beae9c9d204e4acbb1d6b34116959d Mon Sep 17 00:00:00 2001 From: Tomas Oberhuber <tomas.oberhuber@fjfi.cvut.cz> Date: Wed, 29 Jan 2020 17:29:17 +0100 Subject: [PATCH] Added matrix values holder. --- src/TNL/Matrices/Dense.h | 4 +- src/TNL/Matrices/DenseMatrixView.h | 4 +- src/TNL/Matrices/Multidiagonal.h | 4 +- src/TNL/Matrices/SparseMatrix.h | 4 +- src/TNL/Matrices/Tridiagonal.h | 4 +- src/TNL/Matrices/details/ValuesHolder.h | 50 +++++++++++++++++++++++-- 6 files changed, 56 insertions(+), 14 deletions(-) diff --git a/src/TNL/Matrices/Dense.h b/src/TNL/Matrices/Dense.h index 8c109ac1e3..cee69688b3 100644 --- a/src/TNL/Matrices/Dense.h +++ b/src/TNL/Matrices/Dense.h @@ -36,8 +36,8 @@ class Dense : public Matrix< Real, Device, Index > using IndexType = Index; using RealAllocatorType = RealAllocator; using BaseType = Matrix< Real, Device, Index, RealAllocator >; - using ValuesType = typename BaseType::ValuesVector; - using ValuesViewType = typename ValuesType::ViewType; + using ValuesHolderType = typename BaseType::ValuesHolderType; + using ValuesViewType = typename ValuesHolderType::ViewType; using SegmentsType = Containers::Segments::Ellpack< DeviceType, IndexType, typename Allocators::Default< Device >::template Allocator< IndexType >, RowMajorOrder, 1 >; using SegmentViewType = typename SegmentsType::SegmentViewType; using ViewType = DenseMatrixView< Real, Device, Index, RowMajorOrder >; diff --git a/src/TNL/Matrices/DenseMatrixView.h b/src/TNL/Matrices/DenseMatrixView.h index d963dd7c3e..c5771f2eee 100644 --- a/src/TNL/Matrices/DenseMatrixView.h +++ b/src/TNL/Matrices/DenseMatrixView.h @@ -39,8 +39,8 @@ class DenseMatrixView : public MatrixView< Real, Device, Index > using DeviceType = Device; using IndexType = Index; using BaseType = Matrix< Real, Device, Index >; - using ValuesType = typename BaseType::ValuesVector; - using ValuesViewType = typename ValuesType::ViewType; + using ValuesHolderType = typename BaseType::ValuesHolderType; + using ValuesViewType = typename ValuesHolderType::ViewType; using SegmentsType = Containers::Segments::Ellpack< DeviceType, IndexType, typename Allocators::Default< Device >::template Allocator< IndexType >, RowMajorOrder, 1 >; using SegmentsViewType = typename SegmentsType::ViewType; using SegmentViewType = typename SegmentsType::SegmentViewType; diff --git a/src/TNL/Matrices/Multidiagonal.h b/src/TNL/Matrices/Multidiagonal.h index 749ddfae7f..c93dc7d9cb 100644 --- a/src/TNL/Matrices/Multidiagonal.h +++ b/src/TNL/Matrices/Multidiagonal.h @@ -35,8 +35,8 @@ class Multidiagonal : public Matrix< Real, Device, Index, RealAllocator > using RealAllocatorType = RealAllocator; using IndexAllocatorType = IndexAllocator; using BaseType = Matrix< Real, Device, Index, RealAllocator >; - using ValuesType = typename BaseType::ValuesVector; - using ValuesViewType = typename ValuesType::ViewType; + using ValuesHolderType = typename BaseType::ValuesHolderType; + using ValuesViewType = typename ValuesHolderType::ViewType; using IndexerType = details::MultidiagonalMatrixIndexer< IndexType, RowMajorOrder >; using DiagonalsShiftsType = Containers::Vector< IndexType, DeviceType, IndexType, IndexAllocatorType >; using DiagonalsShiftsView = typename DiagonalsShiftsType::ViewType; diff --git a/src/TNL/Matrices/SparseMatrix.h b/src/TNL/Matrices/SparseMatrix.h index 9f91ee7d18..ffcccfadea 100644 --- a/src/TNL/Matrices/SparseMatrix.h +++ b/src/TNL/Matrices/SparseMatrix.h @@ -46,8 +46,8 @@ class SparseMatrix : public Matrix< Real, Device, Index, RealAllocator > using RowsCapacitiesType = Containers::Vector< IndexType, DeviceType, IndexType, IndexAllocatorType >; using RowsCapacitiesView = Containers::VectorView< IndexType, DeviceType, IndexType >; using ConstRowsCapacitiesView = typename RowsCapacitiesView::ConstViewType; - using ValuesVectorType = typename Matrix< Real, Device, Index, RealAllocator >::ValuesVector; - using ValuesViewType = typename ValuesVectorType::ViewType; + using ValuesHolderType = typename Matrix< Real, Device, Index, RealAllocator >::ValuesHolderType; + using ValuesViewType = typename ValuesHolderType::ViewType; using ColumnsIndexesVectorType = Containers::Vector< IndexType, DeviceType, IndexType, IndexAllocatorType >; using ColumnsIndexesViewType = typename ColumnsIndexesVectorType::ViewType; using ViewType = SparseMatrixView< Real, Device, Index, MatrixType, SegmentsViewTemplate >; diff --git a/src/TNL/Matrices/Tridiagonal.h b/src/TNL/Matrices/Tridiagonal.h index 6f0c6a548e..b65cfb5273 100644 --- a/src/TNL/Matrices/Tridiagonal.h +++ b/src/TNL/Matrices/Tridiagonal.h @@ -34,8 +34,8 @@ class Tridiagonal : public Matrix< Real, Device, Index, RealAllocator > using RealAllocatorType = RealAllocator; using BaseType = Matrix< Real, Device, Index, RealAllocator >; using IndexerType = details::TridiagonalMatrixIndexer< IndexType, RowMajorOrder >; - using ValuesType = typename BaseType::ValuesVector; - using ValuesViewType = typename ValuesType::ViewType; + using ValuesHolderType = typename BaseType::ValuesHolderType; + using ValuesViewType = typename ValuesHolderType::ViewType; using ViewType = TridiagonalMatrixView< Real, Device, Index, RowMajorOrder >; using ConstViewType = TridiagonalMatrixView< typename std::add_const< Real >::type, Device, Index, RowMajorOrder >; using RowView = TridiagonalMatrixRowView< ValuesViewType, IndexerType >; diff --git a/src/TNL/Matrices/details/ValuesHolder.h b/src/TNL/Matrices/details/ValuesHolder.h index 9b4ab75404..c76f0d344a 100644 --- a/src/TNL/Matrices/details/ValuesHolder.h +++ b/src/TNL/Matrices/details/ValuesHolder.h @@ -14,13 +14,54 @@ namespace TNL { namespace Matrices { namespace details { + +template< typename Real, + typename Device, + typename Index > +struct ValuesHolderView +: public Containers::VectorView< Real, Device, Index > +{ + using RealType = Real; + using DeviceType = Device; + using IndexType = Index; + + using Containers::VectorView< Real, Device, Index >::VectorView; + using Containers::VectorView< Real, Device, Index >::operator=; + /*__cuda_callable__ + ValuesHolderView() = default; + + __cuda_callable__ + explicit ValuesHolderView( const ValuesHolderView& ) = default; + + __cuda_callable__ + ValuesHolderView( ValuesHolderView&& ) = default;*/ + +}; + template< typename Real, typename Device, typename Index, - typename RealAllocator > -class ValuesHolder -: public Containers::Vector< Real, Device, Index, RealAllocator > -{}; + typename Allocator > +struct ValuesHolder +: public Containers::Vector< Real, Device, Index, Allocator > +{ + using RealType = Real; + using DeviceType = Device; + using IndexType = Index; + using AllocatorType = Allocator; + using ViewType = ValuesHolderView< Real, Device, Index >; + + using Containers::Vector< Real, Device, Index, Allocator >::Vector; + using Containers::Vector< Real, Device, Index, Allocator >::operator=; + /*ValuesHolder() = default; + + explicit ValuesHolder( const ValuesHolder& ) = default; + + explicit ValuesHolder( const ValuesHolder& vector, const AllocatorType& allocator ); + + ValuesHolder( ValuesHolder&& ) = default;*/ + +}; template< typename Device, typename Index > @@ -31,6 +72,7 @@ class BooleanValuesHolder using RealType = bool; using DeviceType = Device; using IndexType = Index; + using ViewType = BooleanValuesHolder; BooleanValuesHolder() : size( 0 ){}; -- GitLab