LvArray
CRSMatrixView.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors.
3  * All rights reserved.
4  * See the LICENSE file for details.
5  * SPDX-License-Identifier: (BSD-3-Clause)
6  */
7 
13 #pragma once
14 
15 #include "SparsityPatternView.hpp"
16 #include "arrayManipulation.hpp"
17 #include "ArraySlice.hpp"
18 #include "umpireInterface.hpp"
19 
20 namespace LvArray
21 {
22 
23 namespace internal
24 {
25 
33 template< typename POLICY, typename T >
35 void atomicAdd( POLICY, T * const acc, T const & val )
36 { RAJA::atomicAdd< POLICY >( acc, val ); }
37 
47 template< typename T >
48 LVARRAY_HOST_DEVICE constexpr inline
49 void atomicAdd( RAJA::seq_atomic, T * acc, T const & val )
50 { *acc += val; }
51 
52 } // namespace internal
53 
69 template< typename T,
70  typename COL_TYPE,
71  typename INDEX_TYPE,
72  template< typename > class BUFFER_TYPE
73  >
74 class CRSMatrixView : protected SparsityPatternView< COL_TYPE, INDEX_TYPE, BUFFER_TYPE >
75 {
76 
79 
81  using typename ParentClass::INDEX_TYPE_NC;
82 
83  using typename ParentClass::SIZE_TYPE;
84 
85 public:
86  static_assert( !std::is_const< T >::value ||
87  (std::is_const< COL_TYPE >::value && std::is_const< INDEX_TYPE >::value),
88  "When T is const COL_TYPE and INDEX_TYPE must also be const." );
89 
91  using EntryType = T;
92  using typename ParentClass::ColType;
93  using typename ParentClass::IndexType;
94 
98 
104  CRSMatrixView() = default;
105 
109  CRSMatrixView( CRSMatrixView const & ) = default;
110 
114  inline
115  CRSMatrixView( CRSMatrixView && ) = default;
116 
126  LVARRAY_HOST_DEVICE constexpr inline
127  CRSMatrixView( INDEX_TYPE const nRows,
128  INDEX_TYPE const nCols,
129  BUFFER_TYPE< INDEX_TYPE > const & offsets,
130  BUFFER_TYPE< SIZE_TYPE > const & nnz,
131  BUFFER_TYPE< COL_TYPE > const & columns,
132  BUFFER_TYPE< T > const & entries ):
133  ParentClass( nRows, nCols, offsets, nnz, columns ),
134  m_entries( entries )
135  {}
136 
141  inline
142  CRSMatrixView & operator=( CRSMatrixView const & ) = default;
143 
148  inline
149  CRSMatrixView & operator=( CRSMatrixView && ) = default;
150 
154 
159  LVARRAY_HOST_DEVICE constexpr inline
161  toView() const
162  {
164  numColumns(),
165  this->m_offsets,
166  this->m_sizes,
167  this->m_values,
168  this->m_entries );
169  }
170 
174  LVARRAY_HOST_DEVICE constexpr inline
177  {
179  numColumns(),
180  this->m_offsets,
181  this->m_sizes,
182  this->m_values,
183  this->m_entries );
184  }
185 
189  LVARRAY_HOST_DEVICE constexpr inline
191  toViewConst() const
192  {
194  numColumns(),
195  this->m_offsets,
196  this->m_sizes,
197  this->m_values,
198  this->m_entries );
199  }
200 
204  LVARRAY_HOST_DEVICE constexpr inline
207  {
209  numColumns(),
210  this->m_offsets,
211  this->m_sizes,
212  this->m_values );
213  }
214 
216 
220 
222  using ParentClass::numRows;
223  using ParentClass::numColumns;
224  using ParentClass::numNonZeros;
225  using ParentClass::nonZeroCapacity;
226  using ParentClass::empty;
227 
229 
233 
239  LVARRAY_HOST_DEVICE inline
240  ArraySlice< T, 1, 0, INDEX_TYPE_NC > getEntries( INDEX_TYPE const row ) const
241  {
243  return ArraySlice< T, 1, 0, INDEX_TYPE_NC >( m_entries.data() + this->m_offsets[ row ],
244  &this->m_sizes[ row ],
245  nullptr );
246  }
247 
251  LVARRAY_HOST_DEVICE inline
252  T const * getEntries() const
253  {
254  return m_entries.data();
255  }
256 
257  using ParentClass::getColumns;
258  using ParentClass::getOffsets;
259  using ParentClass::getSizes;
260 
262 
266 
277  LVARRAY_HOST_DEVICE inline
278  bool insertNonZero( INDEX_TYPE const row, COL_TYPE const col, T const & entry ) const
279  { return ParentClass::insertIntoSetImpl( row, col, CallBacks( *this, row, &entry ) ); }
280 
292  LVARRAY_HOST_DEVICE inline
293  INDEX_TYPE_NC insertNonZeros( INDEX_TYPE const row,
294  COL_TYPE const * const LVARRAY_RESTRICT cols,
295  T const * const LVARRAY_RESTRICT entriesToInsert,
296  INDEX_TYPE const ncols ) const
297  { return ParentClass::insertIntoSetImpl( row, cols, cols + ncols, CallBacks( *this, row, entriesToInsert ) ); }
298 
305  LVARRAY_HOST_DEVICE inline
306  bool removeNonZero( INDEX_TYPE const row, COL_TYPE const col ) const
307  { return ParentClass::removeFromSetImpl( row, col, CallBacks( *this, row, nullptr )); }
308 
318  LVARRAY_HOST_DEVICE inline
319  INDEX_TYPE_NC removeNonZeros( INDEX_TYPE const row,
320  COL_TYPE const * const LVARRAY_RESTRICT cols,
321  INDEX_TYPE const ncols ) const
322  {
323  T * const entries = getEntries( row );
324  INDEX_TYPE const rowNNZ = numNonZeros( row );
325  INDEX_TYPE const nRemoved = ParentClass::removeFromSetImpl( row, cols, cols + ncols, CallBacks( *this, row, nullptr ) );
326 
327  arrayManipulation::destroy( entries + rowNNZ - nRemoved, nRemoved );
328 
329  return nRemoved;
330  }
331 
333 
337 
344  template< typename POLICY >
345  inline void setValues( T const & value ) const
346  {
348  RAJA::forall< POLICY >( RAJA::TypedRangeSegment< INDEX_TYPE >( 0, numRows() ),
349  [view, value] LVARRAY_HOST_DEVICE ( INDEX_TYPE const row )
350  {
351  INDEX_TYPE const nnz = view.numNonZeros( row );
352  ArraySlice< T, 1, 0, INDEX_TYPE_NC > const entries = view.getEntries( row );
353 
354  for( INDEX_TYPE_NC i = 0; i < nnz; ++i )
355  { entries[ i ] = value; }
356  } );
357  }
358 
369  inline void zero() const
370  {
371  #if !defined( LVARRAY_USE_UMPIRE )
372  LVARRAY_ERROR_IF_NE_MSG( m_entries.getPreviousSpace(), MemorySpace::host, "Without Umpire only host memory is supported." );
373  #endif
374 
375  if( m_entries.capacity() > 0 )
376  {
377  ParentClass::move( m_entries.getPreviousSpace(), false );
378  m_entries.move( m_entries.getPreviousSpace(), true );
379 
380  size_t const numBytes = m_entries.capacity() * sizeof( T );
381 
382  umpireInterface::memset( m_entries.data(), 0, numBytes );
383 
384  }
385  }
386 
399  template< typename AtomicPolicy >
400  LVARRAY_HOST_DEVICE inline
401  void addToRow( INDEX_TYPE const row,
402  COL_TYPE const * const LVARRAY_RESTRICT cols,
403  T const * const LVARRAY_RESTRICT vals,
404  INDEX_TYPE const nCols ) const
405  {
406  INDEX_TYPE const nnz = numNonZeros( row );
407  if( nCols < nnz / 4 && nnz > 64 )
408  {
409  addToRowBinarySearch< AtomicPolicy >( row, cols, vals, nCols );
410  }
411  else
412  {
413  addToRowLinearSearch< AtomicPolicy >( row, cols, vals, nCols );
414  }
415  }
416 
429  template< typename AtomicPolicy >
430  LVARRAY_HOST_DEVICE inline
431  void addToRowBinarySearch( INDEX_TYPE const row,
432  COL_TYPE const * const LVARRAY_RESTRICT cols,
433  T const * const LVARRAY_RESTRICT vals,
434  INDEX_TYPE const nCols ) const
435  {
437 
438  INDEX_TYPE const nnz = numNonZeros( row );
439  COL_TYPE const * const columns = getColumns( row );
440  T * const entries = getEntries( row );
441 
442  INDEX_TYPE_NC curPos = 0;
443  for( INDEX_TYPE_NC i = 0; i < nCols; ++i )
444  {
445  INDEX_TYPE const pos = sortedArrayManipulation::find( columns + curPos, nnz - curPos, cols[ i ] ) + curPos;
446  LVARRAY_ASSERT_GT( nnz, pos );
447  LVARRAY_ASSERT_EQ( columns[ pos ], cols[ i ] );
448 
449  internal::atomicAdd( AtomicPolicy{}, entries + pos, vals[ i ] );
450  curPos = pos + 1;
451  }
452  }
453 
466  template< typename AtomicPolicy >
467  LVARRAY_HOST_DEVICE inline
468  void addToRowLinearSearch( INDEX_TYPE const row,
469  COL_TYPE const * const LVARRAY_RESTRICT cols,
470  T const * const LVARRAY_RESTRICT vals,
471  INDEX_TYPE const nCols ) const
472  {
474 
475  INDEX_TYPE const nnz = numNonZeros( row );
476  COL_TYPE const * const columns = getColumns( row );
477  T * const entries = getEntries( row );
478 
479  INDEX_TYPE_NC curPos = 0;
480  for( INDEX_TYPE_NC i = 0; i < nCols; ++i )
481  {
482  for( INDEX_TYPE_NC j = curPos; j < nnz; ++j )
483  {
484  if( columns[ j ] == cols[ i ] )
485  {
486  curPos = j;
487  break;
488  }
489  }
490  LVARRAY_ASSERT_EQ( columns[ curPos ], cols[ i ] );
491  internal::atomicAdd( AtomicPolicy{}, entries + curPos, vals[ i ] );
492  ++curPos;
493  }
494  }
495 
507  template< typename AtomicPolicy >
508  LVARRAY_HOST_DEVICE inline
509  void addToRowBinarySearchUnsorted( INDEX_TYPE const row,
510  COL_TYPE const * const LVARRAY_RESTRICT cols,
511  T const * const LVARRAY_RESTRICT vals,
512  INDEX_TYPE const nCols ) const
513  {
514  INDEX_TYPE const nnz = numNonZeros( row );
515  COL_TYPE const * const columns = getColumns( row );
516  T * const entries = getEntries( row );
517 
518  for( INDEX_TYPE_NC i = 0; i < nCols; ++i )
519  {
520  INDEX_TYPE const pos = sortedArrayManipulation::find( columns, nnz, cols[ i ] );
521  LVARRAY_ASSERT_GT( nnz, pos );
522  LVARRAY_ASSERT_EQ( columns[ pos ], cols[ i ] );
523 
524  internal::atomicAdd( AtomicPolicy{}, entries + pos, vals[ i ] );
525  }
526  }
527 
529 
533 
541  void move( MemorySpace const space, bool const touch=true ) const
542  {
543  ParentClass::move( space, touch );
544  m_entries.move( space, touch );
545  }
546 
548 
549 protected:
550 
555  CRSMatrixView( bool ):
556  ParentClass( true ),
557  m_entries( true )
558  {}
559 
565  template< typename U >
566  void setName( std::string const & name )
567  {
568  ParentClass::template setName< U >( name );
569  m_entries.template setName< U >( name + "/entries" );
570  }
571 
573  BUFFER_TYPE< T > m_entries;
574 
575 private:
576 
581  class CallBacks
582  {
583 public:
584 
591  LVARRAY_HOST_DEVICE inline
592  CallBacks( CRSMatrixView const & crsMV,
593  INDEX_TYPE const row, T const * const entriesToInsert ):
594  m_crsMV( crsMV ),
595  m_row( row ),
596  m_rowNNZ( crsMV.numNonZeros( row ) ),
597  m_rowCapacity( crsMV.nonZeroCapacity( row ) ),
598  m_entries( crsMV.getEntries( row ) ),
599  m_entriesToInsert( entriesToInsert )
600  {}
601 
610  LVARRAY_HOST_DEVICE inline
611  COL_TYPE * incrementSize( COL_TYPE * const curPtr, INDEX_TYPE const nToAdd ) const
612  {
613  LVARRAY_UNUSED_VARIABLE( curPtr );
614 #ifdef LVARRAY_BOUNDS_CHECK
615  LVARRAY_ERROR_IF_GT_MSG( m_rowNNZ + nToAdd, m_rowCapacity, "CRSMatrixView cannot do reallocation." );
616 #else
617  LVARRAY_DEBUG_VAR( nToAdd );
618 #endif
619  return m_crsMV.getSetValues( m_row );
620  }
621 
628  LVARRAY_HOST_DEVICE inline
629  void insert( INDEX_TYPE const insertPos ) const
630  { arrayManipulation::emplace( m_entries, m_rowNNZ, insertPos, m_entriesToInsert[0] ); }
631 
640  LVARRAY_HOST_DEVICE inline
641  void set( INDEX_TYPE const pos, INDEX_TYPE const colPos ) const
642  { new (&m_entries[ pos ]) T( m_entriesToInsert[ colPos ] ); }
643 
654  LVARRAY_HOST_DEVICE inline
655  void insert( INDEX_TYPE const nLeftToInsert,
656  INDEX_TYPE const colPos,
657  INDEX_TYPE const pos,
658  INDEX_TYPE const prevPos ) const
659  {
660  arrayManipulation::shiftUp( m_entries, prevPos, pos, nLeftToInsert );
661  new (&m_entries[pos + nLeftToInsert - 1]) T( m_entriesToInsert[colPos] );
662  }
663 
670  LVARRAY_HOST_DEVICE inline
671  void remove( INDEX_TYPE_NC removePos ) const
672  { arrayManipulation::erase( m_entries, m_rowNNZ, removePos ); }
673 
684  LVARRAY_HOST_DEVICE inline
685  void remove( INDEX_TYPE const nRemoved,
686  INDEX_TYPE const curPos,
687  INDEX_TYPE const nextPos ) const
688  { arrayManipulation::shiftDown( m_entries, nextPos, curPos + 1, nRemoved ); }
689 
690 private:
693 
695  INDEX_TYPE const m_row;
696 
698  INDEX_TYPE const m_rowNNZ;
699 
701  INDEX_TYPE const m_rowCapacity;
702 
704  T * const m_entries;
705 
707  T const * const m_entriesToInsert;
708  };
709 
710 };
711 
712 } /* namespace LvArray */
#define LVARRAY_UNUSED_VARIABLE(X)
Mark X as an unused variable, used to silence compiler warnings.
Definition: Macros.hpp:51
#define LVARRAY_ASSERT(EXP)
Assert EXP is true with no message.
Definition: Macros.hpp:184
This class provides a view into a compressed row storage sparsity pattern.
Definition: SparsityPatternView.hpp:61
CRSMatrixView const & m_crsMV
A reference to the associated CRSMatrixView.
Definition: CRSMatrixView.hpp:692
INDEX_TYPE IndexType
The integer type used for indexing.
Definition: ArrayOfArraysView.hpp:188
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void insert(INDEX_TYPE const nLeftToInsert, INDEX_TYPE const colPos, INDEX_TYPE const pos, INDEX_TYPE const prevPos) const
Used with the sortedArrayManipulation::insertSorted routine this callback signals that the given colu...
Definition: CRSMatrixView.hpp:655
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE std::ptrdiff_t find(T const *const LVARRAY_RESTRICT ptr, std::ptrdiff_t const size, T const &value, Compare &&comp=Compare())
Definition: sortedArrayManipulation.hpp:411
#define ARRAYOFARRAYS_CHECK_BOUNDS(i)
Check that i is a valid array index.
Definition: ArrayOfArraysView.hpp:106
LVARRAY_HOST_DEVICE bool removeNonZero(INDEX_TYPE const row, COL_TYPE const col) const
Remove a non-zero entry at the given position.
Definition: CRSMatrixView.hpp:306
LVARRAY_HOST_DEVICE T const * getEntries() const
Definition: CRSMatrixView.hpp:252
LVARRAY_HOST_DEVICE void addToRowBinarySearchUnsorted(INDEX_TYPE const row, COL_TYPE const *const LVARRAY_RESTRICT cols, T const *const LVARRAY_RESTRICT vals, INDEX_TYPE const nCols) const
Add to the given entries, the entries must already exist in the matrix.
Definition: CRSMatrixView.hpp:509
This class serves to provide a sliced multidimensional interface to the family of LvArray classes...
Definition: ArraySlice.hpp:89
LVARRAY_HOST_DEVICE constexpr CRSMatrixView< T, COL_TYPE, INDEX_TYPE const, BUFFER_TYPE > toView() const
Definition: CRSMatrixView.hpp:161
LVARRAY_HOST_DEVICE constexpr CRSMatrixView(INDEX_TYPE const nRows, INDEX_TYPE const nCols, BUFFER_TYPE< INDEX_TYPE > const &offsets, BUFFER_TYPE< SIZE_TYPE > const &nnz, BUFFER_TYPE< COL_TYPE > const &columns, BUFFER_TYPE< T > const &entries)
Construct a new CRSMatrixView from the given buffers.
Definition: CRSMatrixView.hpp:127
CRSMatrixView(bool)
Protected constructor to be used by the CRSMatrix class.
Definition: CRSMatrixView.hpp:555
void move(MemorySpace const space, bool const touch=true) const
Move this matrix to the given memory space and touch the values, sizes and offsets.
Definition: CRSMatrixView.hpp:541
LVARRAY_HOST_DEVICE CallBacks(CRSMatrixView const &crsMV, INDEX_TYPE const row, T const *const entriesToInsert)
Constructor.
Definition: CRSMatrixView.hpp:592
This class provides the callbacks for the sortedArrayManipulation routines.
Definition: CRSMatrixView.hpp:581
#define LVARRAY_ASSERT_GT(lhs, rhs)
Assert that one value compares greater than the other in debug builds.
Definition: Macros.hpp:515
#define LVARRAY_ERROR_IF_NE_MSG(lhs, rhs, msg)
Raise a hard error if two values are not equal.
Definition: Macros.hpp:305
void setValues(T const &value) const
Set all the entries in the matrix to the given value.
Definition: CRSMatrixView.hpp:345
Contains the LvArray umpire interface. This is only used to keep umpire/ResourceManager.hpp out of the includes for most headers.
std::conditional_t< CONST_SIZES, INDEX_TYPE const, INDEX_TYPE_NC > SIZE_TYPE
The type contained by the m_sizes buffer.
Definition: ArrayOfArraysView.hpp:177
T *const m_entries
A pointer to the entries in the row.
Definition: CRSMatrixView.hpp:704
void zero() const
Use memset to set all the values in the matrix to 0.
Definition: CRSMatrixView.hpp:369
LVARRAY_HOST_DEVICE void insert(INDEX_TYPE const insertPos) const
Used with sortedArrayManipulation::insert routine this callback signals that the column was inserted ...
Definition: CRSMatrixView.hpp:629
BUFFER_TYPE< T > m_entries
Holds the entries of the matrix, of length numNonZeros().
Definition: CRSMatrixView.hpp:573
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void erase(T *const LVARRAY_RESTRICT ptr, std::ptrdiff_t const size, std::ptrdiff_t const index, std::ptrdiff_t const n=1)
Shift the values in the array at or above the given position down by the given amount overwriting the...
Definition: arrayManipulation.hpp:396
Contains the implementation of LvArray::ArraySlice.
LVARRAY_HOST_DEVICE constexpr SparsityPatternView< COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > toSparsityPatternView() const &
Definition: CRSMatrixView.hpp:206
LVARRAY_HOST_DEVICE COL_TYPE * incrementSize(COL_TYPE *const curPtr, INDEX_TYPE const nToAdd) const
Callback signaling that the size of the row has increased.
Definition: CRSMatrixView.hpp:611
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE INDEX_TYPE_NC removeNonZeros(INDEX_TYPE const row, COL_TYPE const *const LVARRAY_RESTRICT cols, INDEX_TYPE const ncols) const
Remove non-zero entries from the given row.
Definition: CRSMatrixView.hpp:319
Contains the implementation of LvArray:SparsityPatternView.
INDEX_TYPE const m_row
The associated row.
Definition: CRSMatrixView.hpp:695
LVARRAY_HOST_DEVICE INDEX_TYPE_NC numNonZeros() const
Definition: SparsityPatternView.hpp:208
LVARRAY_HOST_DEVICE void atomicAdd(POLICY, T *const acc, T const &val)
Wrapper around RAJA::atomicAdd.
Definition: CRSMatrixView.hpp:35
void setName(std::string const &name)
Set the name to be displayed whenever the underlying Buffer&#39;s user call back is called.
Definition: CRSMatrixView.hpp:566
INDEX_TYPE const m_rowCapacity
The non zero capacity of the row.
Definition: CRSMatrixView.hpp:701
LVARRAY_HOST_DEVICE void addToRowLinearSearch(INDEX_TYPE const row, COL_TYPE const *const LVARRAY_RESTRICT cols, T const *const LVARRAY_RESTRICT vals, INDEX_TYPE const nCols) const
Add to the given entries, the entries must already exist in the matrix.
Definition: CRSMatrixView.hpp:468
LVARRAY_HOST_DEVICE INDEX_TYPE_NC insertNonZeros(INDEX_TYPE const row, COL_TYPE const *const LVARRAY_RESTRICT cols, T const *const LVARRAY_RESTRICT entriesToInsert, INDEX_TYPE const ncols) const
Insert a non-zero entries into the given row.
Definition: CRSMatrixView.hpp:293
LVARRAY_HOST_DEVICE constexpr CRSMatrixView< T const, COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > toViewConst() const
Definition: CRSMatrixView.hpp:191
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE bool isSortedUnique(ITER first, ITER const last, Compare &&comp=Compare())
Definition: sortedArrayManipulation.hpp:374
camp::resources::Platform MemorySpace
an alias for camp::resources::Platform.
Definition: bufferManipulation.hpp:31
Contains functions for manipulating a contiguous array of values.
#define LVARRAY_DEBUG_VAR(X)
Mark X as an debug variable, used to silence compiler warnings.
Definition: Macros.hpp:57
T const *const m_entriesToInsert
A pointer to the entries to insert.
Definition: CRSMatrixView.hpp:707
The top level namespace.
Definition: Array.hpp:24
LVARRAY_HOST_DEVICE void addToRowBinarySearch(INDEX_TYPE const row, COL_TYPE const *const LVARRAY_RESTRICT cols, T const *const LVARRAY_RESTRICT vals, INDEX_TYPE const nCols) const
Add to the given entries, the entries must already exist in the matrix.
Definition: CRSMatrixView.hpp:431
#define LVARRAY_ERROR_IF_GT_MSG(lhs, rhs, msg)
Raise a hard error if one value compares greater than the other.
Definition: Macros.hpp:337
LVARRAY_HOST_DEVICE void addToRow(INDEX_TYPE const row, COL_TYPE const *const LVARRAY_RESTRICT cols, T const *const LVARRAY_RESTRICT vals, INDEX_TYPE const nCols) const
Add to the given entries, the entries must already exist in the matrix. The columns must be sorted...
Definition: CRSMatrixView.hpp:401
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void shiftDown(T *const LVARRAY_RESTRICT ptr, std::ptrdiff_t const size, std::ptrdiff_t const index, std::ptrdiff_t const n)
Shift the values in the array at or above the given position down by the given amount overwriting the...
Definition: arrayManipulation.hpp:363
COL_TYPE ColType
The integer type used to enumerate the columns.
Definition: SparsityPatternView.hpp:77
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void destroy(T *const LVARRAY_RESTRICT ptr, std::ptrdiff_t const size)
Destory the values in the array.
Definition: arrayManipulation.hpp:152
LVARRAY_HOST_DEVICE bool insertNonZero(INDEX_TYPE const row, COL_TYPE const col, T const &entry) const
Insert a non-zero entry at the given position.
Definition: CRSMatrixView.hpp:278
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void shiftUp(T *const LVARRAY_RESTRICT ptr, std::ptrdiff_t const size, std::ptrdiff_t const index, std::ptrdiff_t const n)
Shift the values in the array at or above the given position up by the given amount. New uninitialized values take their place.
Definition: arrayManipulation.hpp:326
LVARRAY_HOST_DEVICE ArraySlice< T, 1, 0, INDEX_TYPE_NC > getEntries(INDEX_TYPE const row) const
Definition: CRSMatrixView.hpp:240
INDEX_TYPE const m_rowNNZ
The number of non zero entries in the row.
Definition: CRSMatrixView.hpp:698
#define DISABLE_HD_WARNING
Disable host device warnings.
Definition: Macros.hpp:561
LVARRAY_HOST_DEVICE constexpr CRSMatrixView< T, COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > toViewConstSizes() const
Definition: CRSMatrixView.hpp:176
typename ParentClass::INDEX_TYPE_NC INDEX_TYPE_NC
Since INDEX_TYPE should always be const we need an alias for the non const version.
Definition: ArrayOfSetsView.hpp:47
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void emplace(T *const LVARRAY_RESTRICT ptr, std::ptrdiff_t const size, std::ptrdiff_t const index, ARGS &&... args)
Insert into the array constructing the new value in place.
Definition: arrayManipulation.hpp:478
T EntryType
The type of the entries in the matrix.
Definition: CRSMatrixView.hpp:91
#define LVARRAY_ASSERT_EQ(lhs, rhs)
Assert that two values compare equal in debug builds.
Definition: Macros.hpp:485
#define LVARRAY_HOST_DEVICE
Mark a function for both host and device usage.
Definition: Macros.hpp:549
This class provides a view into a compressed row storage matrix.
Definition: CRSMatrixView.hpp:74