NeoN
A framework for CFD software
Loading...
Searching...
No Matches
sparsityView.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 - 2026 NeoN authors
2//
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
7#include "NeoN/core/view.hpp"
8
9namespace NeoN::la
10{
11
21
29template<typename IndexType>
31{
33 : colIdxs(colIdxsView), rowOffs(rowOffsView) {};
34
35
42 KOKKOS_INLINE_FUNCTION
43 IndexType entry(const IndexType i, const IndexType j) const
44 {
45 const IndexType rowSize = rowOffs[i + 1] - rowOffs[i];
46 for (std::remove_const_t<IndexType> ic = 0; ic < rowSize; ++ic)
47 {
48 const IndexType localCol = rowOffs[i] + ic;
49 if (colIdxs[localCol] == j)
50 {
51 return localCol;
52 }
53 if (colIdxs[localCol] > j) break;
54 }
55 Kokkos::abort("Memory not allocated for CSR matrix component.");
56 return 0; // compiler warning suppression.
57 }
58
61};
62
63} // namespace NeoN::la
int32_t localIdx
Definition label.hpp:50
hold the number of rows and columns of a matrix
A view struct to allow easy read/write on all executors.
View< const IndexType > colIdxs
SparsityView(View< const IndexType > colIdxsView, View< const IndexType > rowOffsView)
KOKKOS_INLINE_FUNCTION IndexType entry(const IndexType i, const IndexType j) const
Retrieve a reference to the matrix element at position (i,j).
View< const IndexType > rowOffs