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 IndexType m_end = -1;
190 CSRRowRangeIterator() =
default;
194 constexpr CSRRowRangeIterator(IndexType* row_indexes, IndexType index)
195 : m_row_indexes(row_indexes)
203 return CSRRow(m_row_indexes[m_index], m_row_indexes[m_index + 1]);
205 constexpr ThatClass& operator++()
210 constexpr ThatClass operator++(
int)
212 return ThatClass(m_row_indexes, m_index++);
214 friend bool operator!=(
const CSRRowRangeIterator& a,
const Sentinel& b)
216 return a.m_index != b.m_end;
221 IndexType* m_row_indexes =
nullptr;
222 IndexType m_index = -1;
233 template <
typename ValueType_,
typename ColumnType_,
typename RowIndexType_>
234 friend class CSRMatrixView;
238 using IndexType = IndexType_;
240 using SentinelType = IteratorType::Sentinel;
244 CSRRowRange() =
default;
248 constexpr ARCCORE_HOST_DEVICE CSRRowRange(IndexType* row_indexes, IndexType begin, IndexType end)
249 : m_row_indexes(row_indexes)
256 constexpr IteratorType begin()
const
258 return IteratorType(m_row_indexes, m_begin);
260 constexpr SentinelType end()
const
262 return SentinelType(m_end);
267 IndexType* m_row_indexes =
nullptr;
268 IndexType m_begin = -1;
269 IndexType m_end = -1;
282 typedef ValueType_ value_type;
283 typedef ValueType_ val_type;
284 typedef ColumnType_ col_type;
285 using ptr_type = RowIndexType_;
286 using RowIndexType = RowIndexType_;
292 CSRMatrixView() =
default;
294 CSRMatrixView(
Int32 nb_row, RowIndexType nb_non_zero, ptr_type* ptr_range, col_type* col_range, val_type* val_range)
295 : m_values(val_range)
296 , m_row_indexes(ptr_range)
297 , m_columns(col_range)
299 , m_nb_non_zero(nb_non_zero)
308 constexpr RowIndexType
nbNonZero() const noexcept {
return m_nb_non_zero; }
313 ARCCORE_CHECK_AT(row, m_nb_row);
314 return m_row_indexes[row + 1] - m_row_indexes[row];
318 ColumnSpanType columns() const noexcept {
return { m_columns, m_nb_non_zero }; }
319 ValueSpanType values() const noexcept {
return { m_values, m_nb_non_zero }; }
323 [[nodiscard]]
constexpr CSRRow<RowIndexType> rowRange(
Int32 row)
const
325 auto begin = m_row_indexes[row];
326 auto end = m_row_indexes[row + 1];
327 return { begin, end };
344 ARCCORE_CHECK_AT(i, m_nb_row + 1);
345 return m_row_indexes[i];
347 constexpr col_type col(RowIndexType i)
const
349 ARCCORE_CHECK_AT(i, m_nb_non_zero);
352 constexpr val_type val(RowIndexType i)
const
354 ARCCORE_CHECK_AT(i, m_nb_non_zero);
358 ptr_type& ptr(
Int32 i)
360 ARCCORE_CHECK_AT(i, m_nb_row + 1);
361 return m_row_indexes[i];
363 col_type& col(RowIndexType i)
365 ARCCORE_CHECK_AT(i, m_nb_non_zero);
368 val_type& val(RowIndexType i)
370 ARCCORE_CHECK_AT(i, m_nb_non_zero);
377 return m_values[rc_index];
382 return m_columns[rc_index];
387 val_type* m_values =
nullptr;
388 RowIndexType* m_row_indexes =
nullptr;
391 RowIndexType m_nb_non_zero = 0;