26 template<
typename COL_TYPE,
28 template<
typename >
class BUFFER_TYPE >
29 class SparsityPattern :
protected SparsityPatternView< COL_TYPE, INDEX_TYPE, BUFFER_TYPE >
37 using typename ParentClass::ColTypeNC;
53 ColTypeNC
const ncols=0,
54 INDEX_TYPE initialRowCapacity=0 ):
57 resize( nrows, ncols, initialRowCapacity );
100 src.m_offsets[ src.m_numArrays ],
129 template<
typename POLICY >
134 "COL_TYPE must be able to hold the range of columns: [0, " << nCols - 1 <<
"]." );
137 ParentClass::template resizeFromCapacities< POLICY >( nRows, rowCapacities );
167 toView()
const && =
delete;
293 void resize( INDEX_TYPE
const nRows, ColTypeNC
const nCols, INDEX_TYPE
const initialRowCapacity )
338 template<
typename ITER >
340 INDEX_TYPE
insertNonZeros( INDEX_TYPE
const row, ITER
const first, ITER
const last )
349 template<
typename ITER >
377 { ParentClass::template setName< decltype( *this ) >( name ); }
419 COL_TYPE *
incrementSize( COL_TYPE *
const curPtr, INDEX_TYPE
const nToAdd )
const #define LVARRAY_UNUSED_VARIABLE(X)
Mark X as an unused variable, used to silence compiler warnings.
Definition: Macros.hpp:79
This class implements a compressed row storage sparsity pattern.
Definition: CRSMatrix.hpp:22
SparsityPattern & operator=(SparsityPattern const &src)
Copy assignment operator, performs a deep copy.
Definition: SparsityPattern.hpp:96
LVARRAY_HOST_DEVICE bool removeNonZero(INDEX_TYPE const row, COL_TYPE const col) const
Remove a non-zero entry at the given position.
Definition: SparsityPatternView.hpp:359
This class provides a view into a compressed row storage sparsity pattern.
Definition: SparsityPatternView.hpp:61
LVARRAY_HOST_DEVICE constexpr COL_TYPE const * getColumns() const
Definition: SparsityPatternView.hpp:296
void emplaceBack(BUFFER &buf, std::ptrdiff_t const size, ARGS &&... args)
Construct a new value at the end of the buffer.
Definition: bufferManipulation.hpp:297
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: SparsityPattern.hpp:389
INDEX_TYPE const m_row
The row the call back is associated with.
Definition: SparsityPattern.hpp:436
void reserveRows(INDEX_TYPE const rowCapacity)
Reserve space for the given number of rows.
Definition: SparsityPattern.hpp:226
constexpr SparsityPatternView< COL_TYPE, INDEX_TYPE const, BUFFER_TYPE > toView() const &
Definition: SparsityPattern.hpp:155
void reserve(INDEX_TYPE const newCapacity)
Reserve space for the given number of arrays.
Definition: ArrayOfArraysView.hpp:638
#define LVARRAY_ERROR_IF(EXP, MSG)
Abort execution if EXP is true.
Definition: Macros.hpp:155
SparsityPattern & operator=(SparsityPattern &&src)
Default move assignment operator, performs a shallow copy.
Definition: SparsityPattern.hpp:113
BUFFER_TYPE< INDEX_TYPE > m_offsets
Definition: ArrayOfArraysView.hpp:965
LVARRAY_HOST_DEVICE constexpr ArraySlice< T, 1, 0, INDEX_TYPE_NC > getSetValues(INDEX_TYPE const i) const
Definition: ArrayOfSetsView.hpp:346
void appendRow(INDEX_TYPE const nzCapacity=0)
Append a row with the given capacity.
Definition: SparsityPattern.hpp:302
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 without either r...
Definition: SparsityPattern.hpp:244
void setRowCapacity(INDEX_TYPE const row, INDEX_TYPE newCapacity)
Set the non zero capacity of the given row.
Definition: SparsityPattern.hpp:261
BUFFER_TYPE< SIZE_TYPE > m_sizes
Holds the size of each array.
Definition: ArrayOfArraysView.hpp:968
This class provides the callbacks for the sortedArrayManipulation routines.
Definition: SparsityPattern.hpp:396
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:669
void resize(INDEX_TYPE const nrows, COL_TYPE const ncols, INDEX_TYPE_NC initialRowCapacity, BUFFERS &... buffers)
Resize the SparsityPattern to the given size.
Definition: SparsityPatternView.hpp:437
COL_TYPE_NC m_numCols
The number of columns in the matrix.
Definition: SparsityPatternView.hpp:452
INDEX_TYPE insertNonZeros(INDEX_TYPE const row, ITER const first, ITER const last)
Inserts multiple non-zero entries into the given row.
Definition: SparsityPattern.hpp:340
LVARRAY_HOST_DEVICE constexpr std::enable_if< std::is_signed< INDEX_TYPE >::value, bool >::type isPositive(INDEX_TYPE const i)
Definition: arrayManipulation.hpp:82
void setName(std::string const &name)
Set the name associated with this SparsityPattern which is used in the chai callback.
Definition: SparsityPattern.hpp:376
void compress()
Compress the SparsityPattern so that the non-zeros of each row are contiguous with no extra capacity ...
Definition: SparsityPattern.hpp:273
INDEX_TYPE removeNonZeros(INDEX_TYPE const row, ITER const first, ITER const last) const
Remove multiple non-zero entries from the given row.
Definition: SparsityPattern.hpp:351
This class provides a no-op callbacks interface for the ArrayManipulation sorted routines.
Definition: sortedArrayManipulation.hpp:72
LVARRAY_HOST_DEVICE constexpr INDEX_TYPE_NC const numRows() const
Definition: SparsityPatternView.hpp:197
SparsityPattern(SparsityPattern const &src)
Copy constructor, performs a deep copy.
Definition: SparsityPattern.hpp:66
Contains the implementation of LvArray:SparsityPatternView.
LVARRAY_HOST_DEVICE INDEX_TYPE_NC numNonZeros() const
Definition: SparsityPatternView.hpp:211
~SparsityPattern()
Destructor, frees the values, sizes and offsets Buffers.
Definition: SparsityPattern.hpp:80
INDEX_TYPE IndexType
The integer type used for indexing.
Definition: ArrayOfArraysView.hpp:188
SparsityPattern & m_sp
The SparsityPattern the call back is associated with.
Definition: SparsityPattern.hpp:433
LVARRAY_HOST_DEVICE bool empty() const
Definition: SparsityPatternView.hpp:250
camp::resources::Platform MemorySpace
an alias for camp::resources::Platform.
Definition: bufferManipulation.hpp:31
LVARRAY_HOST_DEVICE constexpr SparsityPatternView< COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > toViewConst() const &
Definition: SparsityPattern.hpp:177
LVARRAY_HOST_DEVICE constexpr INDEX_TYPE_NC const nonZeroCapacity() const
Definition: SparsityPatternView.hpp:234
The top level namespace.
Definition: Array.hpp:24
void resize(INDEX_TYPE const nRows, ColTypeNC const nCols, INDEX_TYPE const initialRowCapacity)
Set the dimensions of the matrix.
Definition: SparsityPattern.hpp:293
SparsityPatternView & operator=(SparsityPatternView const &)=default
Default copy assignment operator, this does a shallow copy.
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:79
LVARRAY_HOST_DEVICE constexpr SparsityPatternView< COL_TYPE, INDEX_TYPE const, BUFFER_TYPE > toView() const
Definition: SparsityPatternView.hpp:163
LVARRAY_HOST_DEVICE constexpr INDEX_TYPE const * getOffsets() const
Definition: SparsityPatternView.hpp:289
INDEX_TYPE_NC m_numArrays
The number of arrays contained.
Definition: ArrayOfArraysView.hpp:961
COL_TYPE * incrementSize(COL_TYPE *const curPtr, INDEX_TYPE const nToAdd) const
Callback signaling that the number of non zeros of the associated row has increased.
Definition: SparsityPattern.hpp:419
void free(BUFFERS &... buffers)
Destroy all the objects held by this array and free all associated memory.
Definition: ArrayOfArraysView.hpp:806
bool insertNonZero(INDEX_TYPE const row, COL_TYPE const col)
Insert a non zero entry in the entry (row, col).
Definition: SparsityPattern.hpp:326
void move(MemorySpace const space, bool const touch=true) const
Move this ArrayOfSets to the given memory space.
Definition: SparsityPatternView.hpp:403
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 COL_TYPE const numColumns() const
Definition: SparsityPatternView.hpp:204
void resizeFromRowCapacities(INDEX_TYPE const nRows, ColTypeNC const nCols, INDEX_TYPE const *const rowCapacities)
Clears the matrix and creates a new matrix with the given number of rows and columns.
Definition: SparsityPattern.hpp:130
SparsityPattern(INDEX_TYPE const nrows=0, ColTypeNC const ncols=0, INDEX_TYPE initialRowCapacity=0)
Constructor.
Definition: SparsityPattern.hpp:52
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE constexpr std::enable_if_t< std::is_arithmetic< T >::value, T > max(T const a, T const b)
Definition: math.hpp:313
void reserveValues(INDEX_TYPE const newValueCapacity, BUFFERS &... buffers)
Reserve space for the given number of values.
Definition: ArrayOfArraysView.hpp:652
CallBacks(SparsityPattern &sp, INDEX_TYPE const row)
Constructor.
Definition: SparsityPattern.hpp:406
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
LVARRAY_HOST_DEVICE constexpr SparsityPatternView< COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > toViewConst() const
Definition: SparsityPatternView.hpp:177
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE INDEX_TYPE_NC removeNonZeros(INDEX_TYPE const row, ITER const first, ITER const last) const
Remove multiple non-zero entries from the given row.
Definition: SparsityPatternView.hpp:378
#define LVARRAY_HOST_DEVICE
Mark a function for both host and device usage.
Definition: Macros.hpp:600
void move(MemorySpace const space, bool const touch=true) const
Move this ArrayOfSets to the given memory space.
Definition: SparsityPattern.hpp:367
void reserveNonZeros(INDEX_TYPE const nnz)
Reserve space to hold at least the given total number of non zero entries without reallocation...
Definition: SparsityPattern.hpp:234