62class CSRRowColumnIterator
64 template <
typename T>
friend class CSRRow;
65 using IndexType = IndexType_;
69 CSRRowColumnIterator() =
default;
73 explicit constexpr CSRRowColumnIterator(IndexType index)
80 constexpr void operator++() { ++m_index; }
83 operator!=(
const CSRRowColumnIterator& lhs,
const CSRRowColumnIterator& rhs)
85 return lhs.m_index != rhs.m_index;
87 constexpr bool isValid()
const {
return m_index != (-1); }
91 IndexType m_index = -1;
158class CSRRowRangeIterator
160 template <
typename V,
typename C,
typename R>
161 friend class CSRMatrixView;
162 template <
typename T>
163 friend class CSRRowRange;
167 using IndexType = IndexType_;
168 using ThatClass = CSRRowRangeIterator<IndexType>;
175 friend CSRRowRangeIterator<IndexType>;
179 explicit Sentinel(IndexType v)
185 constexpr IndexType end()
const {
return m_end; }
189 IndexType m_end = -1;
194 CSRRowRangeIterator() =
default;
198 constexpr CSRRowRangeIterator(IndexType* row_indexes, IndexType index)
199 : m_row_indexes(row_indexes)
207 return CSRRow(m_row_indexes[m_index], m_row_indexes[m_index + 1]);
209 constexpr ThatClass& operator++()
214 constexpr ThatClass operator++(
int)
216 return ThatClass(m_row_indexes, m_index++);
218 friend bool operator!=(
const CSRRowRangeIterator& a,
const Sentinel& b)
220 return a.m_index != b.end();
225 IndexType* m_row_indexes =
nullptr;
226 IndexType m_index = -1;
237 template <
typename ValueType_,
typename ColumnType_,
typename RowIndexType_>
238 friend class CSRMatrixView;
242 using IndexType = IndexType_;
244 using SentinelType = IteratorType::Sentinel;
248 CSRRowRange() =
default;
252 constexpr ARCCORE_HOST_DEVICE CSRRowRange(IndexType* row_indexes, IndexType begin, IndexType end)
253 : m_row_indexes(row_indexes)
260 constexpr IteratorType begin()
const
262 return IteratorType(m_row_indexes, m_begin);
264 constexpr SentinelType end()
const
266 return SentinelType(m_end);
271 IndexType* m_row_indexes =
nullptr;
272 IndexType m_begin = -1;
273 IndexType m_end = -1;
286 typedef ValueType_ value_type;
287 typedef ValueType_ val_type;
288 typedef ColumnType_ col_type;
289 using ptr_type = RowIndexType_;
290 using RowIndexType = RowIndexType_;
296 CSRMatrixView() =
default;
298 CSRMatrixView(
Int32 nb_row, RowIndexType nb_non_zero, ptr_type* ptr_range, col_type* col_range, val_type* val_range)
299 : m_values(val_range)
300 , m_row_indexes(ptr_range)
301 , m_columns(col_range)
303 , m_nb_non_zero(nb_non_zero)
312 constexpr RowIndexType
nbNonZero() const noexcept {
return m_nb_non_zero; }
317 ARCCORE_CHECK_AT(row, m_nb_row);
318 return m_row_indexes[row + 1] - m_row_indexes[row];
322 ColumnSpanType columns() const noexcept {
return { m_columns, m_nb_non_zero }; }
323 ValueSpanType values() const noexcept {
return { m_values, m_nb_non_zero }; }
327 [[nodiscard]]
constexpr CSRRow<RowIndexType> rowRange(
Int32 row)
const
329 auto begin = m_row_indexes[row];
330 auto end = m_row_indexes[row + 1];
331 return { begin, end };
348 ARCCORE_CHECK_AT(i, m_nb_row + 1);
349 return m_row_indexes[i];
351 constexpr col_type col(RowIndexType i)
const
353 ARCCORE_CHECK_AT(i, m_nb_non_zero);
356 constexpr val_type val(RowIndexType i)
const
358 ARCCORE_CHECK_AT(i, m_nb_non_zero);
362 ptr_type& ptr(
Int32 i)
364 ARCCORE_CHECK_AT(i, m_nb_row + 1);
365 return m_row_indexes[i];
367 col_type& col(RowIndexType i)
369 ARCCORE_CHECK_AT(i, m_nb_non_zero);
372 val_type& val(RowIndexType i)
374 ARCCORE_CHECK_AT(i, m_nb_non_zero);
381 return m_values[rc_index];
386 return m_columns[rc_index];
391 val_type* m_values =
nullptr;
392 RowIndexType* m_row_indexes =
nullptr;
395 RowIndexType m_nb_non_zero = 0;