From 2ea8dc337af6d84b1b62f72975ffcd8dde698cb2 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 17:21:50 +0200
Subject: [PATCH] Added SparseMatrixRowViewValueGetter.

---
 .../details/SparseMatrixRowViewValueGetter.h  | 76 +++++++++++++++++++
 1 file changed, 76 insertions(+)
 create mode 100644 src/TNL/Matrices/details/SparseMatrixRowViewValueGetter.h

diff --git a/src/TNL/Matrices/details/SparseMatrixRowViewValueGetter.h b/src/TNL/Matrices/details/SparseMatrixRowViewValueGetter.h
new file mode 100644
index 0000000000..d47a931d72
--- /dev/null
+++ b/src/TNL/Matrices/details/SparseMatrixRowViewValueGetter.h
@@ -0,0 +1,76 @@
+
+
+/***************************************************************************
+                          SparseMatrixRowViewValueGetter.h  -  description
+                             -------------------
+    begin                : May 4, 2021
+    copyright            : (C) 2021 by Tomas Oberhuber
+    email                : tomas.oberhuber@fjfi.cvut.cz
+ ***************************************************************************/
+
+/* See Copyright Notice in tnl/Copyright */
+
+#pragma once
+
+namespace TNL {
+   namespace Matrices {
+      namespace details {
+
+
+template< typename SegmentView,
+          typename ValuesView,
+          typename ColumnsIndexesView,
+          bool isBinary_ >
+struct SparseMatrixRowViewValueGetter {};
+
+template< typename SegmentView,
+          typename ValuesView,
+          typename ColumnsIndexesView >
+struct SparseMatrixRowViewValueGetter< SegmentView, ValuesView, ColumnsIndexesView, true >
+{
+   using RealType = typename ValuesView::RealType;
+
+   using IndexType = typename ColumnsIndexesView::IndexType;
+
+   using ResultType = bool;
+
+   using ConstResultType = bool;
+
+   __cuda_callable__
+   static bool getValue( const IndexType& globalIdx, const ValuesView& values, const ColumnsIndexesView& columnIndexes, const IndexType& paddingIndex )
+   {
+      if( columnIndexes[ globalIdx ] != paddingIndex )
+         return true;
+      return false;
+   };
+};
+
+template< typename SegmentView,
+          typename ValuesView,
+          typename ColumnsIndexesView >
+struct SparseMatrixRowViewValueGetter< SegmentView, ValuesView, ColumnsIndexesView, false >
+{
+   using RealType = typename ValuesView::RealType;
+
+   using IndexType = typename ColumnsIndexesView::IndexType;
+
+   using ResultType = RealType&;
+
+   using ConstResultType = const RealType&;
+
+   __cuda_callable__
+   static const RealType& getValue( const IndexType& globalIdx, const ValuesView& values, const ColumnsIndexesView& columnIndexes, const IndexType& paddingIndex )
+   {
+      return values[ globalIdx ];
+   };
+
+   __cuda_callable__
+   static RealType& getValue( const IndexType& globalIdx, ValuesView& values, ColumnsIndexesView& columnIndexes, const IndexType& paddingIndex )
+   {
+      return values[ globalIdx ];
+   };
+};
+
+      } //namespace details
+   } //namepsace Matrices
+} //namespace TNL
-- 
GitLab