LvArray
CRSMatrix.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 "CRSMatrixView.hpp"
16 #include "arrayManipulation.hpp"
17 
18 namespace LvArray
19 {
20 
21 template< typename COL_TYPE, typename INDEX_TYPE, template< typename > class BUFFER_TYPE >
23 
31 template< typename T,
32  typename COL_TYPE,
33  typename INDEX_TYPE,
34  template< typename > class BUFFER_TYPE >
35 class CRSMatrix : protected CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >
36 {
37 
40 
41 public:
42 
43  using typename ParentClass::EntryType;
44  using typename ParentClass::ColType;
45  using typename ParentClass::IndexType;
46 
50 
58  CRSMatrix( INDEX_TYPE const nrows=0,
59  INDEX_TYPE const ncols=0,
60  INDEX_TYPE const initialRowCapacity=0 ):
61  ParentClass( true )
62  {
63  resize( nrows, ncols, initialRowCapacity );
64  setName( "" );
65  }
66 
71  inline
72  CRSMatrix( CRSMatrix const & src ):
73  ParentClass( true )
74  { *this = src; }
75 
79  inline
80  CRSMatrix( CRSMatrix && ) = default;
81 
86  { ParentClass::free( this->m_entries ); }
87 
89 
93 
100  inline
101  CRSMatrix & operator=( CRSMatrix const & src )
102  {
103  this->m_numCols = src.m_numCols;
105  src.m_offsets[ src.m_numArrays ],
106  src.m_offsets,
107  src.m_sizes,
108  src.m_values,
109  typename ParentClass::template PairOfBuffers< T >( this->m_entries, src.m_entries ) );
110  return *this;
111  }
112 
118  inline
120  {
121  ParentClass::free( this->m_entries );
122  ParentClass::operator=( std::move( src ) );
123  return *this;
124  }
125 
131  template< typename POLICY >
132  inline
134  {
135  // Destroy the current entries.
136  if( !std::is_trivially_destructible< T >::value )
137  {
139  RAJA::forall< POLICY >( RAJA::TypedRangeSegment< INDEX_TYPE >( 0, numRows() ),
140  [view] LVARRAY_HOST_DEVICE ( INDEX_TYPE const row )
141  {
142  INDEX_TYPE const nnz = view.numNonZeros( row );
143  T * const entries = view.getEntries( row );
144  arrayManipulation::destroy( entries, nnz );
145  } );
146  }
147 
148  // Reallocate to the appropriate length
149  bufferManipulation::reserve( this->m_entries, 0, MemorySpace::host, src.nonZeroCapacity() );
150 
152 
154  RAJA::forall< POLICY >( RAJA::TypedRangeSegment< INDEX_TYPE >( 0, numRows() ),
155  [view] LVARRAY_HOST_DEVICE ( INDEX_TYPE const row )
156  {
157  T * const rowEntries = view.getEntries( row );
158  for( INDEX_TYPE i = 0; i < view.numNonZeros( row ); ++i )
159  {
160  new ( rowEntries + i ) T();
161  }
162  } );
163 
164  setName( "" );
165  }
166 
176  template< typename POLICY >
177  void resizeFromRowCapacities( INDEX_TYPE const nRows, INDEX_TYPE const nCols, INDEX_TYPE const * const rowCapacities )
178  {
179  LVARRAY_ERROR_IF( !arrayManipulation::isPositive( nCols ), "nCols must be positive." );
181  "COL_TYPE must be able to hold the range of columns: [0, " << nCols - 1 << "]." );
182 
183  this->m_numCols = nCols;
184  ParentClass::template resizeFromCapacities< POLICY >( nRows, rowCapacities, this->m_entries );
185  }
186 
188 
192 
200  constexpr inline
202  toView() const &
203  { return ParentClass::toView(); }
204 
212  constexpr inline
214  toView() const && = delete;
215 
222  LVARRAY_HOST_DEVICE constexpr inline
225  { return ParentClass::toViewConstSizes(); }
226 
234  LVARRAY_HOST_DEVICE constexpr inline
236  toViewConstSizes() const && = delete;
237 
244  LVARRAY_HOST_DEVICE constexpr inline
246  toViewConst() const &
247  { return ParentClass::toViewConst(); }
248 
256  LVARRAY_HOST_DEVICE constexpr inline
258  toViewConst() const && = delete;
259 
261 
269  LVARRAY_HOST_DEVICE constexpr inline
271  toSparsityPatternView() const && = delete;
272 
274 
278 
280  using ParentClass::numRows;
284  using ParentClass::empty;
285 
287 
291 
296 
298 
302 
308  inline
309  void reserveNonZeros( INDEX_TYPE const nnz )
310  { ParentClass::reserveValues( nnz, this->m_entries ); }
311 
317  inline
318  void reserveNonZeros( INDEX_TYPE const row, INDEX_TYPE const nnz )
319  {
320  if( nonZeroCapacity( row ) >= nnz ) return;
321  setRowCapacity( row, nnz );
322  }
323 
334  inline
335  void setRowCapacity( INDEX_TYPE const row, INDEX_TYPE newCapacity )
336  {
337  if( newCapacity > numColumns() ) newCapacity = numColumns();
338  ParentClass::setCapacityOfArray( row, newCapacity, this->m_entries );
339  }
340 
351  void resize( INDEX_TYPE const nRows, INDEX_TYPE const nCols, INDEX_TYPE const initialRowCapacity )
352  { ParentClass::resize( nRows, nCols, initialRowCapacity, this->m_entries ); }
353 
359  inline
360  void compress()
361  { ParentClass::compress( this->m_entries ); }
362 
364 
368 
377  inline
378  bool insertNonZero( INDEX_TYPE const row, COL_TYPE const col, T const & entry )
379  { return ParentClass::insertIntoSetImpl( row, col, CallBacks( *this, row, &entry ) ); }
380 
391  inline
392  INDEX_TYPE insertNonZeros( INDEX_TYPE const row,
393  COL_TYPE const * const cols,
394  T const * const entriesToInsert,
395  INDEX_TYPE const ncols )
396  { return ParentClass::insertIntoSetImpl( row, cols, cols + ncols, CallBacks( *this, row, entriesToInsert ) ); }
397 
400 
402 
406 
412  template< typename POLICY >
413  inline
414  void setValues( T const & value ) const
415  { ParentClass::template setValues< POLICY >( value ); }
416 
417  using ParentClass::zero;
418 
423  template< typename AtomicPolicy >
424  inline
425  void addToRow( INDEX_TYPE const row,
426  COL_TYPE const * const LVARRAY_RESTRICT cols,
427  T const * const LVARRAY_RESTRICT vals,
428  INDEX_TYPE const nCols ) const
429  { ParentClass::template addToRow< AtomicPolicy >( row, cols, vals, nCols ); }
430 
435  template< typename AtomicPolicy >
436  inline
437  void addToRowBinarySearch( INDEX_TYPE const row,
438  COL_TYPE const * const LVARRAY_RESTRICT cols,
439  T const * const LVARRAY_RESTRICT vals,
440  INDEX_TYPE const nCols ) const
441  { ParentClass::template addToRowBinarySearch< AtomicPolicy >( row, cols, vals, nCols ); }
442 
447  template< typename AtomicPolicy >
448  inline
449  void addToRowLinearSearch( INDEX_TYPE const row,
450  COL_TYPE const * const LVARRAY_RESTRICT cols,
451  T const * const LVARRAY_RESTRICT vals,
452  INDEX_TYPE const nCols ) const
453  { ParentClass::template addToRowLinearSearch< AtomicPolicy >( row, cols, vals, nCols ); }
454 
459  template< typename AtomicPolicy >
460  inline
461  void addToRowBinarySearchUnsorted( INDEX_TYPE const row,
462  COL_TYPE const * const LVARRAY_RESTRICT cols,
463  T const * const LVARRAY_RESTRICT vals,
464  INDEX_TYPE const nCols ) const
465  { ParentClass::template addToRowBinarySearchUnsorted< AtomicPolicy >( row, cols, vals, nCols ); }
466 
468 
472 
480  void move( MemorySpace const space, bool const touch=true ) const
481  { return ParentClass::move( space, touch ); }
482 
484 
489  void setName( std::string const & name )
490  { ParentClass::template setName< decltype( *this ) >( name ); }
491 
492 private:
493 
501  void dynamicallyGrowRow( INDEX_TYPE const row, INDEX_TYPE const newNNZ )
502  { setRowCapacity( row, 2 * newNNZ ); }
503 
508  class CallBacks
509  {
510 public:
511 
519  INDEX_TYPE const row, T const * const entriesToInsert ):
520  m_crsM( crsM ),
521  m_row( row ),
522  m_rowNNZ( crsM.numNonZeros( row ) ),
523  m_rowCapacity( crsM.nonZeroCapacity( row ) ),
524  m_entries( nullptr ),
525  m_entriesToInsert( entriesToInsert )
526  {}
527 
536  inline
537  COL_TYPE * incrementSize( COL_TYPE * const curPtr, INDEX_TYPE const nToAdd )
538  {
539  LVARRAY_UNUSED_VARIABLE( curPtr );
540  if( m_rowNNZ + nToAdd > m_rowCapacity )
541  {
543  }
544 
546  return m_crsM.getSetValues( m_row );
547  }
548 
555  inline
556  void insert( INDEX_TYPE const pos ) const
558 
566  inline
567  void set( INDEX_TYPE const pos, INDEX_TYPE const colPos ) const
568  { new (&m_entries[pos]) T( m_entriesToInsert[colPos] ); }
569 
581  inline
582  void insert( INDEX_TYPE const nLeftToInsert,
583  INDEX_TYPE const colPos,
584  INDEX_TYPE const pos,
585  INDEX_TYPE const prevPos ) const
586  {
587  arrayManipulation::shiftUp( m_entries, prevPos, pos, nLeftToInsert );
588  new (&m_entries[pos + nLeftToInsert - 1]) T( m_entriesToInsert[colPos] );
589  }
590 
591 private:
594 
596  INDEX_TYPE const m_row;
597 
599  INDEX_TYPE const m_rowNNZ;
600 
602  INDEX_TYPE const m_rowCapacity;
603 
606 
608  T const * const m_entriesToInsert;
609  };
610 };
611 
612 } /* namespace LvArray */
#define LVARRAY_UNUSED_VARIABLE(X)
Mark X as an unused variable, used to silence compiler warnings.
Definition: Macros.hpp:51
This class implements a compressed row storage sparsity pattern.
Definition: CRSMatrix.hpp:22
void assimilate(SparsityPattern< COL_TYPE, INDEX_TYPE, BUFFER_TYPE > &&src)
Steal the resources from a SparsityPattern.
Definition: CRSMatrix.hpp:133
This class provides a view into a compressed row storage sparsity pattern.
Definition: SparsityPatternView.hpp:61
INDEX_TYPE const m_rowCapacity
The non zero capacity of the row.
Definition: CRSMatrix.hpp:602
LVARRAY_HOST_DEVICE constexpr COL_TYPE const * getColumns() const
Definition: SparsityPatternView.hpp:293
bool insertNonZero(INDEX_TYPE const row, COL_TYPE const col, T const &entry)
Insert a non-zero entry at the given position.
Definition: CRSMatrix.hpp:378
LVARRAY_HOST_DEVICE constexpr SparsityPatternView< COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > toSparsityPatternView() const &&=delete
Overload for rvalues that is deleted.
void resize(INDEX_TYPE const nRows, INDEX_TYPE const nCols, INDEX_TYPE const initialRowCapacity)
Set the dimensions of the matrix.
Definition: CRSMatrix.hpp:351
T const *const m_entriesToInsert
A pointer to the entries to insert.
Definition: CRSMatrix.hpp:608
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
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: CRSMatrix.hpp:582
CRSMatrix(INDEX_TYPE const nrows=0, INDEX_TYPE const ncols=0, INDEX_TYPE const initialRowCapacity=0)
Constructor.
Definition: CRSMatrix.hpp:58
#define LVARRAY_ERROR_IF(EXP, MSG)
Abort execution if EXP is true.
Definition: Macros.hpp:122
void setName(std::string const &name)
Set the name associated with this CRSMatrix which is used in the chai callback.
Definition: CRSMatrix.hpp:489
LVARRAY_HOST_DEVICE constexpr CRSMatrixView< T, COL_TYPE, INDEX_TYPE const, BUFFER_TYPE > toView() const
Definition: CRSMatrixView.hpp:161
BUFFER_TYPE< INDEX_TYPE > m_offsets
Definition: ArrayOfArraysView.hpp:965
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
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: CRSMatrix.hpp:437
LVARRAY_HOST_DEVICE constexpr ArraySlice< T, 1, 0, INDEX_TYPE_NC > getSetValues(INDEX_TYPE const i) const
Definition: ArrayOfSetsView.hpp:346
void assimilate(SparsityPatternView &&src)
Steal the resources of src, clearing it in the process.
Definition: SparsityPatternView.hpp:419
CRSMatrix & m_crsM
The CRSMatrix the call back is associated with.
Definition: CRSMatrix.hpp:593
BUFFER_TYPE< T > m_values
Definition: ArrayOfArraysView.hpp:972
INDEX_TYPE insertNonZeros(INDEX_TYPE const row, COL_TYPE const *const cols, T const *const entriesToInsert, INDEX_TYPE const ncols)
Insert a non-zero entries into the given row.
Definition: CRSMatrix.hpp:392
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: CRSMatrix.hpp:461
CRSMatrix & operator=(CRSMatrix &&src)
Default move assignment operator, performs a shallow copy.
Definition: CRSMatrix.hpp:119
BUFFER_TYPE< SIZE_TYPE > m_sizes
Holds the size of each array.
Definition: ArrayOfArraysView.hpp:968
COL_TYPE * incrementSize(COL_TYPE *const curPtr, INDEX_TYPE const nToAdd)
Callback signaling that the size of the row has increased.
Definition: CRSMatrix.hpp:537
void compress(BUFFERS &... buffers)
Compress the arrays so that the values of each array are contiguous with no extra capacity in between...
Definition: ArrayOfArraysView.hpp:665
Contains the implementation of LvArray::CRSMatrixView.
LVARRAY_HOST_DEVICE constexpr std::enable_if< std::is_signed< INDEX_TYPE >::value, bool >::type isPositive(INDEX_TYPE const i)
Definition: arrayManipulation.hpp:82
INDEX_TYPE const m_rowNNZ
The number of non zeros in the row.
Definition: CRSMatrix.hpp:599
~CRSMatrix()
Destructor, frees the entries, values (columns), sizes and offsets Buffers.
Definition: CRSMatrix.hpp:85
void zero() const
Use memset to set all the values in the matrix to 0.
Definition: CRSMatrixView.hpp:369
void reserveNonZeros(INDEX_TYPE const nnz)
Reserve space to hold at least the given total number of non zero entries.
Definition: CRSMatrix.hpp:309
BUFFER_TYPE< T > m_entries
Holds the entries of the matrix, of length numNonZeros().
Definition: CRSMatrixView.hpp:573
void resize(INDEX_TYPE const nrows, INDEX_TYPE const ncols, INDEX_TYPE_NC initialRowCapacity, BUFFERS &... buffers)
Resize the SparsityPattern to the given size.
Definition: SparsityPatternView.hpp:434
CRSMatrixView & operator=(CRSMatrixView const &)=default
Default copy assignment operator.
LVARRAY_HOST_DEVICE constexpr SparsityPatternView< COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > toSparsityPatternView() const &
Definition: CRSMatrixView.hpp:206
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
This class provides the callbacks for the ArrayManipulation sorted routines.
Definition: CRSMatrix.hpp:508
void dynamicallyGrowRow(INDEX_TYPE const row, INDEX_TYPE const newNNZ)
Increase the capacity of a row to accommodate at least the given number of non zero entries...
Definition: CRSMatrix.hpp:501
LVARRAY_HOST_DEVICE INDEX_TYPE_NC numNonZeros() const
Definition: SparsityPatternView.hpp:208
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: CRSMatrix.hpp:480
INDEX_TYPE IndexType
The integer type used for indexing.
Definition: ArrayOfArraysView.hpp:188
void insert(INDEX_TYPE const pos) const
Used with sortedArrayManipulation::insert routine this callback signals that the column was inserted ...
Definition: CRSMatrix.hpp:556
LVARRAY_HOST_DEVICE constexpr INDEX_TYPE_NC numRows() const
Definition: SparsityPatternView.hpp:194
void setValues(T const &value) const
Set all the entries in the matrix to the given value.
Definition: CRSMatrix.hpp:414
LVARRAY_HOST_DEVICE constexpr CRSMatrixView< T const, COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > toViewConst() const
Definition: CRSMatrixView.hpp:191
LVARRAY_HOST_DEVICE bool empty() const
Definition: SparsityPatternView.hpp:247
LVARRAY_HOST_DEVICE constexpr CRSMatrixView< T, COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > toViewConstSizes() const &
Definition: CRSMatrix.hpp:224
camp::resources::Platform MemorySpace
an alias for camp::resources::Platform.
Definition: bufferManipulation.hpp:31
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: CRSMatrix.hpp:449
Contains functions for manipulating a contiguous array of values.
constexpr CRSMatrixView< T, COL_TYPE, INDEX_TYPE const, BUFFER_TYPE > toView() const &
Definition: CRSMatrix.hpp:202
The top level namespace.
Definition: Array.hpp:24
LVARRAY_HOST_DEVICE void reserve(BUFFER &buf, std::ptrdiff_t const size, MemorySpace const space, std::ptrdiff_t const newCapacity)
Reserve space in the buffer for at least the given capacity.
Definition: bufferManipulation.hpp:230
CRSMatrix & operator=(CRSMatrix const &src)
Copy assignment operator, performs a deep copy.
Definition: CRSMatrix.hpp:101
INDEX_TYPE_NC m_numCols
The number of columns in the matrix.
Definition: SparsityPatternView.hpp:449
void compress()
Compress the CRSMatrix so that the non-zeros and values of each row are contiguous with no extra capa...
Definition: CRSMatrix.hpp:360
CallBacks(CRSMatrix &crsM, INDEX_TYPE const row, T const *const entriesToInsert)
Constructor.
Definition: CRSMatrix.hpp:518
void setEqualTo(INDEX_TYPE const srcNumArrays, INDEX_TYPE const srcMaxOffset, BUFFER_TYPE< INDEX_TYPE > const &srcOffsets, BUFFER_TYPE< INDEX_TYPE > const &srcSizes, BUFFER_TYPE< COL_TYPE > const &srcValues, PAIRS_OF_BUFFERS &&... pairs)
Set this ArrayOfArraysView equal to the provided arrays.
Definition: ArrayOfArraysView.hpp:830
COL_TYPE ColType
The integer type used to enumerate the columns.
Definition: SparsityPatternView.hpp:77
LVARRAY_HOST_DEVICE constexpr INDEX_TYPE const * getOffsets() const
Definition: SparsityPatternView.hpp:286
INDEX_TYPE_NC m_numArrays
The number of arrays contained.
Definition: ArrayOfArraysView.hpp:961
void free(BUFFERS &... buffers)
Destroy all the objects held by this array and free all associated memory.
Definition: ArrayOfArraysView.hpp:806
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
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
void setCapacityOfArray(INDEX_TYPE const i, INDEX_TYPE const newCapacity, BUFFERS &... buffers)
Set the capacity of the given array.
Definition: ArrayOfArraysView.hpp:877
LVARRAY_HOST_DEVICE constexpr std::enable_if_t< std::is_arithmetic< T >::value, T > max(T const a, T const b)
Definition: math.hpp:311
LVARRAY_HOST_DEVICE constexpr INDEX_TYPE_NC nonZeroCapacity() const
Definition: SparsityPatternView.hpp:231
CRSMatrix(CRSMatrix const &src)
Copy constructor, performs a deep copy.
Definition: CRSMatrix.hpp:72
void resizeFromRowCapacities(INDEX_TYPE const nRows, INDEX_TYPE const nCols, INDEX_TYPE const *const rowCapacities)
Clears the matrix and creates a new matrix with the given number of rows and columns.
Definition: CRSMatrix.hpp:177
LVARRAY_HOST_DEVICE ArraySlice< T, 1, 0, INDEX_TYPE_NC > getEntries(INDEX_TYPE const row) const
Definition: CRSMatrixView.hpp:240
std::pair< BUFFER_TYPE< U > &, BUFFER_TYPE< U > const & > PairOfBuffers
Alias for a std::pair of buffers.
Definition: ArrayOfArraysView.hpp:604
void reserveNonZeros(INDEX_TYPE const row, INDEX_TYPE const nnz)
Reserve space to hold at least the given number of non zero entries in the given row.
Definition: CRSMatrix.hpp:318
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: CRSMatrix.hpp:425
LVARRAY_HOST_DEVICE constexpr CRSMatrixView< T const, COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > toViewConst() const &
Definition: CRSMatrix.hpp:246
LVARRAY_HOST_DEVICE constexpr INDEX_TYPE_NC numColumns() const
Definition: SparsityPatternView.hpp:201
LVARRAY_HOST_DEVICE constexpr CRSMatrixView< T, COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > toViewConstSizes() const
Definition: CRSMatrixView.hpp:176
void setRowCapacity(INDEX_TYPE const row, INDEX_TYPE newCapacity)
Set the non zero capacity of the given row.
Definition: CRSMatrix.hpp:335
void reserveValues(INDEX_TYPE const newValueCapacity, BUFFERS &... buffers)
Reserve space for the given number of values.
Definition: ArrayOfArraysView.hpp:648
T * m_entries
A pointer to the entries of the row.
Definition: CRSMatrix.hpp:605
INDEX_TYPE const m_row
The row the call back is assocated with.
Definition: CRSMatrix.hpp:596
LVARRAY_HOST_DEVICE bool insertIntoSetImpl(INDEX_TYPE const i, COL_TYPE const &value, CALLBACKS &&cbacks) const
Helper function to insert a value into the given set.
Definition: ArrayOfSetsView.hpp:364
This class implements a compressed row storage matrix.
Definition: CRSMatrix.hpp:35
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_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