21 #ifdef LVARRAY_BOUNDS_CHECK 28 #define SPARSITYPATTERN_COLUMN_CHECK( col ) \ 29 LVARRAY_ERROR_IF( !arrayManipulation::isPositive( col ) || col >= this->numColumns(), \ 30 "Column Check Failed: col=" << col << " numColumns=" << this->numColumns() ) 32 #else // LVARRAY_BOUNDS_CHECK 39 #define SPARSITYPATTERN_COLUMN_CHECK( col ) 58 template<
typename COL_TYPE,
60 template<
typename >
class BUFFER_TYPE >
73 static_assert( std::is_integral< COL_TYPE >::value,
"COL_TYPE must be integral." );
74 static_assert( std::is_integral< INDEX_TYPE >::value,
"INDEX_TYPE must be integral." );
76 "INDEX_TYPE must be able to hold values at least as large as COL_TYPE." );
108 { src.m_numCols = 0; }
120 INDEX_TYPE
const nCols,
121 BUFFER_TYPE< INDEX_TYPE >
const & offsets,
122 BUFFER_TYPE< SIZE_TYPE >
const & nnz,
123 BUFFER_TYPE< COL_TYPE >
const & columns ):
257 bool empty( INDEX_TYPE
const row )
const 266 bool empty( INDEX_TYPE
const row, COL_TYPE
const col )
const 282 {
return (*
this)[row]; }
325 template<
typename ITER >
331 #ifdef LVARRAY_BOUNDS_CHECK 332 for( ITER iter = first; iter != last; ++iter )
363 template<
typename ITER >
369 #ifdef LVARRAY_BOUNDS_CHECK 370 for( ITER iter = first; iter != last; ++iter )
412 *
this = std::move( src );
423 template<
class ... BUFFERS >
425 INDEX_TYPE
const ncols,
427 BUFFERS & ... buffers )
432 "COL_TYPE must be able to hold the range of columns: [0, " << ncols - 1 <<
"]." );
#define SPARSITYPATTERN_COLUMN_CHECK(col)
Check that col is a valid column in the matrix.
This class provides a view into a compressed row storage sparsity pattern.
INDEX_TYPE_NC numNonZeros() const
constexpr INDEX_TYPE_NC numColumns() const
bool empty(INDEX_TYPE const row, COL_TYPE const col) const
#define ARRAYOFARRAYS_CHECK_BOUNDS(i)
Check that i is a valid array index.
SparsityPatternView(SparsityPatternView &&src)
Move constructor.
constexpr SparsityPatternView(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)
Construct a new CRSMatrixView from the given buffers.
#define LVARRAY_ERROR_IF(EXP, MSG)
Abort execution if EXP is true.
This class serves to provide a sliced multidimensional interface to the family of LvArray classes...
constexpr SparsityPatternView< COL_TYPE, INDEX_TYPE const, BUFFER_TYPE > toView() const
BUFFER_TYPE< INDEX_TYPE > m_offsets
constexpr INDEX_TYPE_NC sizeOfSet(INDEX_TYPE const i) const
constexpr INDEX_TYPE_NC size() const
void assimilate(SparsityPatternView &&src)
Steal the resources of src, clearing it in the process.
constexpr INDEX_TYPE_NC nonZeroCapacity(INDEX_TYPE const row) const
BUFFER_TYPE< COL_TYPE > m_values
bool insertIntoSet(INDEX_TYPE const i, COL_TYPE const &value) const
Insert a value into the given set.
BUFFER_TYPE< SIZE_TYPE > m_sizes
Holds the size of each array.
constexpr INDEX_TYPE const * getOffsets() const
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)
constexpr bool empty(INDEX_TYPE const row) const
constexpr INDEX_TYPE_NC numRows() const
constexpr INDEX_TYPE_NC nonZeroCapacity() const
bool insertNonZero(INDEX_TYPE const row, COL_TYPE const col) const
Insert a non-zero entry at the given position.
void resize(INDEX_TYPE const nrows, INDEX_TYPE const ncols, INDEX_TYPE_NC initialRowCapacity, BUFFERS &... buffers)
Resize the SparsityPattern to the given size.
constexpr ArraySlice< COL_TYPE const, 1, 0, INDEX_TYPE_NC > getColumns(INDEX_TYPE const row) const
This class provides a view into an array of sets like object.
SparsityPatternView()=default
A constructor to create an uninitialized SparsityPatternView.
bool contains(INDEX_TYPE const i, COL_TYPE const &value) const
INDEX_TYPE IndexType
The integer type used for indexing.
void resizeImpl(INDEX_TYPE const newSize, INDEX_TYPE const defaultArrayCapacity, BUFFERS &... buffers)
Set the number of arrays.
constexpr INDEX_TYPE_NC capacityOfSet(INDEX_TYPE const i) const
void move(MemorySpace const space, bool const touch=true) const
Move this ArrayOfSets to the given memory space.
constexpr SparsityPatternView< COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > toViewConst() const
MemorySpace
An enum containing the available memory spaces.
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.
globalIndex const 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.
typename ParentClass::INDEX_TYPE_NC INDEX_TYPE_NC
Since INDEX_TYPE should always be const we need an alias for the non const version.
void free(BUFFERS &... buffers)
Destroy all the objects held by this array and free all associated memory.
std::conditional_t< CONST_SIZES, INDEX_TYPE const, INDEX_TYPE_NC > SIZE_TYPE
The type contained by the m_sizes buffer.
std::remove_const_t< INDEX_TYPE > INDEX_TYPE_NC
Since INDEX_TYPE should always be const we need an alias for the non const version.
void move(MemorySpace const space, bool const touch=true) const
Move this ArrayOfSets to the given memory space.
SparsityPatternView & operator=(SparsityPatternView &&src)
Move assignment operator, this does a shallow copy.
ArrayOfSetsView & operator=(ArrayOfSetsView const &)=default
Default copy assignment operator, this does a shallow copy.
Contains the implementation of LvArray::ArrayOfSetsView.
constexpr INDEX_TYPE_NC numNonZeros(INDEX_TYPE const row) const
INDEX_TYPE_NC insertNonZeros(INDEX_TYPE const row, ITER const first, ITER const last) const
Inserts multiple non-zero entries into the given row.
bool removeFromSet(INDEX_TYPE const i, COL_TYPE const &value) const
Remove a value from the given set.
SparsityPatternView(bool)
Protected constructor to be used by parent classes.
#define DISABLE_HD_WARNING
Disable host device warnings.
constexpr std::enable_if_t< std::is_arithmetic< T >::value, T > max(T const a, T const b)
constexpr INDEX_TYPE_NC valueCapacity() const
#define LVARRAY_HOST_DEVICE
Mark a function for both host and device usage.