26 template<
typename COL_TYPE,
28 template<
typename >
class BUFFER_TYPE >
33 using ParentClass = SparsityPatternView< COL_TYPE, INDEX_TYPE, BUFFER_TYPE >;
53 INDEX_TYPE
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, INDEX_TYPE
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 ); }
389 void dynamicallyGrowRow( INDEX_TYPE
const row, INDEX_TYPE
const newNNZ )
419 COL_TYPE * incrementSize( COL_TYPE *
const curPtr, INDEX_TYPE
const nToAdd )
const 422 INDEX_TYPE
const newNNZ = m_sp.numNonZeros( m_row ) + nToAdd;
423 if( newNNZ > m_sp.nonZeroCapacity( m_row ) )
425 m_sp.dynamicallyGrowRow( m_row, newNNZ );
428 return m_sp.getSetValues( m_row );
436 INDEX_TYPE
const m_row;
#define LVARRAY_UNUSED_VARIABLE(X)
Mark X as an unused variable, used to silence compiler warnings.
This class implements a compressed row storage sparsity pattern.
SparsityPattern & operator=(SparsityPattern const &src)
Copy assignment operator, performs a deep copy.
This class provides a view into a compressed row storage sparsity pattern.
INDEX_TYPE_NC numNonZeros() const
void resize(INDEX_TYPE const nRows, INDEX_TYPE const nCols, INDEX_TYPE const initialRowCapacity)
Set the dimensions of the matrix.
constexpr INDEX_TYPE_NC numColumns() const
void emplaceBack(BUFFER &buf, std::ptrdiff_t const size, ARGS &&... args)
Construct a new value at the end of the buffer.
LvArray::SparsityPatternView< COL_INDEX, INDEX_TYPE const, LvArray::ChaiBuffer > SparsityPatternView
Alias for Sparsity pattern View.
void reserveRows(INDEX_TYPE const rowCapacity)
Reserve space for the given number of rows.
bool insertIntoSetImpl(INDEX_TYPE const i, COL_TYPE const &value, CALLBACKS &&cbacks) const
Helper function to insert a value into the given set.
constexpr SparsityPatternView< COL_TYPE, INDEX_TYPE const, BUFFER_TYPE > toView() const &
void reserve(INDEX_TYPE const newCapacity)
Reserve space for the given number of arrays.
#define LVARRAY_ERROR_IF(EXP, MSG)
Abort execution if EXP is true.
SparsityPattern & operator=(SparsityPattern &&src)
Default move assignment operator, performs a shallow copy.
constexpr SparsityPatternView< COL_TYPE, INDEX_TYPE const, BUFFER_TYPE > toView() const
BUFFER_TYPE< INDEX_TYPE > m_offsets
SparsityPattern(INDEX_TYPE const nrows=0, INDEX_TYPE const ncols=0, INDEX_TYPE initialRowCapacity=0)
Constructor.
void appendRow(INDEX_TYPE const nzCapacity=0)
Append a row with the given capacity.
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...
void setRowCapacity(INDEX_TYPE const row, INDEX_TYPE newCapacity)
Set the non zero capacity of the given row.
BUFFER_TYPE< SIZE_TYPE > m_sizes
Holds the size of each array.
constexpr INDEX_TYPE const * getOffsets() const
void compress(BUFFERS &... buffers)
Compress the arrays so that the values of each array are contiguous with no extra capacity in between...
bool removeNonZero(INDEX_TYPE const row, COL_TYPE const col) const
Remove a non-zero entry at the given position.
constexpr std::enable_if< std::is_signed< INDEX_TYPE >::value, bool >::type isPositive(INDEX_TYPE const i)
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.
INDEX_TYPE insertNonZeros(INDEX_TYPE const row, ITER const first, ITER const last)
Inserts multiple non-zero entries into the given row.
constexpr INDEX_TYPE_NC numRows() const
void setName(std::string const &name)
Set the name associated with this SparsityPattern which is used in the chai callback.
void compress()
Compress the SparsityPattern so that the non-zeros of each row are contiguous with no extra capacity ...
constexpr INDEX_TYPE_NC nonZeroCapacity() const
void resize(INDEX_TYPE const nrows, INDEX_TYPE const ncols, INDEX_TYPE_NC initialRowCapacity, BUFFERS &... buffers)
Resize the SparsityPattern to the given size.
INDEX_TYPE removeNonZeros(INDEX_TYPE const row, ITER const first, ITER const last) const
Remove multiple non-zero entries from the given row.
constexpr ArraySlice< COL_TYPE const, 1, 0, INDEX_TYPE_NC > getColumns(INDEX_TYPE const row) const
This class provides a no-op callbacks interface for the ArrayManipulation sorted routines.
SparsityPattern(SparsityPattern const &src)
Copy constructor, performs a deep copy.
Contains the implementation of LvArray:SparsityPatternView.
~SparsityPattern()
Destructor, frees the values, sizes and offsets Buffers.
INDEX_TYPE IndexType
The integer type used for indexing.
constexpr SparsityPatternView< COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > toViewConst() const
MemorySpace
An enum containing the available memory spaces.
constexpr SparsityPatternView< COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > toViewConst() const &
INDEX_TYPE_NC m_numCols
The number of columns in the matrix.
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.
COL_TYPE ColType
The integer type used to enumerate the columns.
INDEX_TYPE_NC removeNonZeros(INDEX_TYPE const row, ITER const first, ITER const last) const
Remove multiple non-zero entries from the given row.
INDEX_TYPE_NC m_numArrays
The number of arrays contained.
void free(BUFFERS &... buffers)
Destroy all the objects held by this array and free all associated memory.
bool insertNonZero(INDEX_TYPE const row, COL_TYPE const col)
Insert a non zero entry in the entry (row, col).
void move(MemorySpace const space, bool const touch=true) const
Move this ArrayOfSets to the given memory space.
void setCapacityOfArray(INDEX_TYPE const i, INDEX_TYPE const newCapacity, BUFFERS &... buffers)
Set the capacity of the given array.
std::string string
String type.
LvArray::SparsityPattern< COL_INDEX, INDEX_TYPE, LvArray::ChaiBuffer > SparsityPattern
Alias for Sparsity pattern class.
constexpr std::enable_if_t< std::is_arithmetic< T >::value, T > max(T const a, T const b)
void reserveValues(INDEX_TYPE const newValueCapacity, BUFFERS &... buffers)
Reserve space for the given number of values.
#define LVARRAY_HOST_DEVICE
Mark a function for both host and device usage.
void move(MemorySpace const space, bool const touch=true) const
Move this ArrayOfSets to the given memory space.
void reserveNonZeros(INDEX_TYPE const nnz)
Reserve space to hold at least the given total number of non zero entries without reallocation...