GEOSX
Classes | Public Types | Protected Member Functions | Protected Attributes | List of all members
LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE > Class Template Reference

This class provides a view into a compressed row storage matrix. More...

#include <CRSMatrixView.hpp>

Inheritance diagram for LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >:
Inheritance graph
[legend]

Public Types

using EntryType = T
 The type of the entries in the matrix.
 
using ColType = COL_TYPE
 The integer type used to enumerate the columns.
 

Public Member Functions

Constructors, destructor and assignment operators
 CRSMatrixView ()=default
 A constructor to create an uninitialized CRSMatrixView. More...
 
 CRSMatrixView (CRSMatrixView const &)=default
 Default copy constructor.
 
 CRSMatrixView (CRSMatrixView &&)=default
 Default move constructor.
 
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. More...
 
CRSMatrixViewoperator= (CRSMatrixView const &)=default
 Default copy assignment operator. More...
 
CRSMatrixViewoperator= (CRSMatrixView &&)=default
 Default move assignment operator. More...
 
CRSMatrixView and SparsityPatternView creation methods
constexpr CRSMatrixView< T, COL_TYPE, INDEX_TYPE const, BUFFER_TYPE > toView () const
 
constexpr CRSMatrixView< T, COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > toViewConstSizes () const
 
constexpr CRSMatrixView< T const, COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > toViewConst () const
 
constexpr SparsityPatternView< COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > toSparsityPatternView () const &
 
Methods that provide access to the data
ArraySlice< T, 1, 0, INDEX_TYPE_NCgetEntries (INDEX_TYPE const row) const
 
T const * getEntries () const
 
Methods that insert or remove entries from a row.
bool insertNonZero (INDEX_TYPE const row, COL_TYPE const col, T const &entry) const
 Insert a non-zero entry at the given position. More...
 
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. More...
 
bool removeNonZero (INDEX_TYPE const row, COL_TYPE const col) const
 Remove a non-zero entry at the given position. More...
 
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. More...
 
Methods that modify the entires of the matrix
template<typename POLICY >
void setValues (T const &value) const
 Set all the entries in the matrix to the given value. More...
 
void zero () const
 Use memset to set all the values in the matrix to 0. More...
 
template<typename AtomicPolicy >
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. More...
 
template<typename AtomicPolicy >
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. More...
 
template<typename AtomicPolicy >
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. More...
 
template<typename AtomicPolicy >
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. More...
 
Methods dealing with memory spaces
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. More...
 

Protected Member Functions

 CRSMatrixView (bool)
 Protected constructor to be used by the CRSMatrix class. More...
 
template<typename U >
void setName (std::string const &name)
 Set the name to be displayed whenever the underlying Buffer's user call back is called. More...
 
- Protected Member Functions inherited from LvArray::SparsityPatternView< COL_TYPE, INDEX_TYPE, BUFFER_TYPE >
 SparsityPatternView (bool)
 Protected constructor to be used by parent classes. More...
 
void assimilate (SparsityPatternView &&src)
 Steal the resources of src, clearing it in the process. More...
 
template<class ... BUFFERS>
void resize (INDEX_TYPE const nrows, INDEX_TYPE const ncols, INDEX_TYPE_NC initialRowCapacity, BUFFERS &... buffers)
 Resize the SparsityPattern to the given size. More...
 
 SparsityPatternView ()=default
 A constructor to create an uninitialized SparsityPatternView. More...
 
 SparsityPatternView (SparsityPatternView const &)=default
 Default copy constructor. More...
 
 SparsityPatternView (SparsityPatternView &&src)
 Move constructor. More...
 
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. More...
 
SparsityPatternViewoperator= (SparsityPatternView const &)=default
 Default copy assignment operator, this does a shallow copy. More...
 
SparsityPatternViewoperator= (SparsityPatternView &&src)
 Move assignment operator, this does a shallow copy. More...
 
constexpr SparsityPatternView< COL_TYPE, INDEX_TYPE const, BUFFER_TYPE > toView () const
 
constexpr SparsityPatternView< COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > toViewConst () const
 
constexpr INDEX_TYPE_NC numRows () const
 
constexpr INDEX_TYPE_NC numColumns () const
 
INDEX_TYPE_NC numNonZeros () const
 
constexpr INDEX_TYPE_NC numNonZeros (INDEX_TYPE const row) const
 
constexpr INDEX_TYPE_NC nonZeroCapacity () const
 
constexpr INDEX_TYPE_NC nonZeroCapacity (INDEX_TYPE const row) const
 
bool empty () const
 
constexpr bool empty (INDEX_TYPE const row) const
 
bool empty (INDEX_TYPE const row, COL_TYPE const col) const
 
constexpr ArraySlice< COL_TYPE const, 1, 0, INDEX_TYPE_NCgetColumns (INDEX_TYPE const row) const
 
constexpr INDEX_TYPE const * getOffsets () const
 
constexpr COL_TYPE const * getColumns () const
 
bool insertNonZero (INDEX_TYPE const row, COL_TYPE const col) const
 Insert a non-zero entry at the given position. More...
 
template<typename ITER >
INDEX_TYPE_NC insertNonZeros (INDEX_TYPE const row, ITER const first, ITER const last) const
 Inserts multiple non-zero entries into the given row. More...
 
bool removeNonZero (INDEX_TYPE const row, COL_TYPE const col) const
 Remove a non-zero entry at the given position. More...
 
template<typename ITER >
INDEX_TYPE_NC removeNonZeros (INDEX_TYPE const row, ITER const first, ITER const last) const
 Remove multiple non-zero entries from the given row. More...
 
void move (MemorySpace const space, bool const touch=true) const
 Move this ArrayOfSets to the given memory space. More...
 
- Protected Member Functions inherited from LvArray::ArrayOfSetsView< COL_TYPE, INDEX_TYPE, BUFFER_TYPE >
 ArrayOfSetsView (bool)
 Protected constructor to be used by parent classes. More...
 
constexpr ArraySlice< COL_TYPE, 1, 0, INDEX_TYPE_NCgetSetValues (INDEX_TYPE const i) const
 
bool insertIntoSetImpl (INDEX_TYPE const i, COL_TYPE const &value, CALLBACKS &&cbacks) const
 Helper function to insert a value into the given set. More...
 
INDEX_TYPE_NC insertIntoSetImpl (INDEX_TYPE const i, ITER const first, ITER const last, CALLBACKS &&cbacks) const
 Inserts multiple values into the given set. More...
 
bool removeFromSetImpl (INDEX_TYPE const i, COL_TYPE const &value, CALLBACKS &&cbacks) const
 Helper function to remove a value from the given set. More...
 
INDEX_TYPE_NC removeFromSetImpl (INDEX_TYPE const i, ITER const first, ITER const last, CALLBACKS &&cbacks) const
 Removes multiple values from the given set. More...
 
 ArrayOfSetsView ()=default
 A constructor to create an uninitialized ArrayOfSetsView. More...
 
 ArrayOfSetsView (ArrayOfSetsView const &)=default
 Default copy constructor. Performs a shallow copy and calls the chai::ManagedArray copy constructor.
 
 ArrayOfSetsView (ArrayOfSetsView &&)=default
 Default move constructor.
 
constexpr ArrayOfSetsView (INDEX_TYPE const numArrays, BUFFER_TYPE< INDEX_TYPE > const &offsets, BUFFER_TYPE< SIZE_TYPE > const &sizes, BUFFER_TYPE< COL_TYPE > const &values)
 Construct a new ArrayOfArraysView from the given buffers. More...
 
ArrayOfSetsViewoperator= (ArrayOfSetsView const &)=default
 Default copy assignment operator, this does a shallow copy. More...
 
ArrayOfSetsViewoperator= (ArrayOfSetsView &&)=default
 Default move assignment operator, this does a shallow copy. More...
 
constexpr ArrayOfSetsView< COL_TYPE, INDEX_TYPE const, BUFFER_TYPE > toView () const
 
constexpr ArrayOfSetsView< COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > toViewConst () const
 
constexpr ArrayOfArraysView< COL_TYPE const, INDEX_TYPE const, true, BUFFER_TYPE > toArrayOfArraysView () const
 
constexpr INDEX_TYPE_NC sizeOfSet (INDEX_TYPE const i) const
 
constexpr INDEX_TYPE_NC capacityOfSet (INDEX_TYPE const i) const
 
bool contains (INDEX_TYPE const i, COL_TYPE const &value) const
 
void consistencyCheck () const
 Verify that the capacity of each set is greater than or equal to the size and that each set is sorted unique. More...
 
constexpr ArraySlice< COL_TYPE const, 1, 0, INDEX_TYPE_NCoperator[] (INDEX_TYPE const i) const
 
constexpr COL_TYPE const & operator() (INDEX_TYPE const i, INDEX_TYPE const j) const
 
bool insertIntoSet (INDEX_TYPE const i, COL_TYPE const &value) const
 Insert a value into the given set. More...
 
INDEX_TYPE_NC insertIntoSet (INDEX_TYPE const i, ITER const first, ITER const last) const
 Inserts multiple values into the given set. More...
 
bool removeFromSet (INDEX_TYPE const i, COL_TYPE const &value) const
 Remove a value from the given set. More...
 
INDEX_TYPE_NC removeFromSet (INDEX_TYPE const i, ITER const first, ITER const last) const
 Removes multiple values from the given set. More...
 
void move (MemorySpace const space, bool const touch=true) const
 Move this ArrayOfSets to the given memory space. More...
 
- Protected Member Functions inherited from LvArray::ArrayOfArraysView< COL_TYPE, INDEX_TYPE, std::is_const< COL_TYPE >::value, BUFFER_TYPE >
 ArrayOfArraysView (bool)
 Protected constructor to be used by parent classes. More...
 
void resize (INDEX_TYPE const newSize, INDEX_TYPE const defaultArrayCapacity=0)
 Set the number of arrays. More...
 
void reserve (INDEX_TYPE const newCapacity)
 Reserve space for the given number of arrays. More...
 
void reserveValues (INDEX_TYPE const newValueCapacity, BUFFERS &... buffers)
 Reserve space for the given number of values. More...
 
void compress (BUFFERS &... buffers)
 Compress the arrays so that the values of each array are contiguous with no extra capacity in between. More...
 
void resizeFromCapacities (INDEX_TYPE const numSubArrays, INDEX_TYPE const *const capacities, BUFFERS &... buffers)
 Clears the array and creates a new array with the given number of sub-arrays. More...
 
void assimilate (ArrayOfArraysView< COL_TYPE, INDEX_TYPE, CONST_SIZES, BUFFER_TYPE > &&src)
 Steal the resources of src, clearing it in the process. More...
 
void resizeImpl (INDEX_TYPE const newSize, INDEX_TYPE const defaultArrayCapacity, BUFFERS &... buffers)
 Set the number of arrays. More...
 
void free (BUFFERS &... buffers)
 Destroy all the objects held by this array and free all associated memory. More...
 
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. More...
 
void setCapacityOfArray (INDEX_TYPE const i, INDEX_TYPE const newCapacity, BUFFERS &... buffers)
 Set the capacity of the given array. More...
 
void setName (std::string const &name)
 Set the name to be displayed whenever the underlying Buffer's user call back is called. More...
 
 ArrayOfArraysView ()=default
 A constructor to create an uninitialized ArrayOfArraysView. More...
 
 ArrayOfArraysView (ArrayOfArraysView const &)=default
 Default copy constructor. More...
 
constexpr ArrayOfArraysView (ArrayOfArraysView &&src)
 Default move constructor. More...
 
constexpr ArrayOfArraysView (INDEX_TYPE const numArrays, BUFFER_TYPE< INDEX_TYPE > const &offsets, BUFFER_TYPE< SIZE_TYPE > const &sizes, BUFFER_TYPE< COL_TYPE > const &values)
 Construct a new ArrayOfArraysView from the given buffers. More...
 
ArrayOfArraysViewoperator= (ArrayOfArraysView const &)=default
 Default copy assignment operator. More...
 
ArrayOfArraysViewoperator= (ArrayOfArraysView &&src)
 Move assignment operator.. More...
 
constexpr ArrayOfArraysView< COL_TYPE, INDEX_TYPE const, CONST_SIZES, BUFFER_TYPE > toView () const
 
constexpr ArrayOfArraysView< COL_TYPE, INDEX_TYPE const, true, BUFFER_TYPE > toViewConstSizes () const
 
constexpr ArrayOfArraysView< COL_TYPE const, INDEX_TYPE const, true, BUFFER_TYPE > toViewConst () const
 
constexpr INDEX_TYPE_NC size () const
 
constexpr INDEX_TYPE_NC sizeOfArray (INDEX_TYPE const i) const
 
constexpr SIZE_TYPE const * getSizes () const
 
constexpr INDEX_TYPE const * getOffsets () const
 
constexpr COL_TYPE const * getValues () const
 
CONSTEXPR_WITH_NDEBUG INDEX_TYPE_NC capacity () const
 
constexpr INDEX_TYPE_NC capacityOfArray (INDEX_TYPE const i) const
 
constexpr INDEX_TYPE_NC valueCapacity () const
 
constexpr ArraySlice< COL_TYPE, 1, 0, INDEX_TYPE_NCoperator[] (INDEX_TYPE const i) const
 
constexpr COL_TYPE & operator() (INDEX_TYPE const i, INDEX_TYPE const j) const
 
void emplaceBack (INDEX_TYPE const i, ARGS &&... args) const
 Append a value to an array. More...
 
void emplaceBackAtomic (INDEX_TYPE const i, ARGS &&... args) const
 Append a value to an array in a thread safe manner. More...
 
void appendToArray (INDEX_TYPE const i, ITER const first, ITER const last) const
 Append values to an array. More...
 
void emplace (INDEX_TYPE const i, INDEX_TYPE const j, ARGS &&... args) const
 Insert a value into an array. More...
 
void insertIntoArray (INDEX_TYPE const i, INDEX_TYPE const j, ITER const first, ITER const last) const
 Insert values into an array. More...
 
void eraseFromArray (INDEX_TYPE const i, INDEX_TYPE const j, INDEX_TYPE const n=1) const
 Erase values from an array. More...
 
void registerTouch (MemorySpace const space) const
 Touch the memory in space. More...
 
void move (MemorySpace const space, bool touch=true) const
 Move this ArrayOfArrays to the given memory space. More...
 

Protected Attributes

BUFFER_TYPE< T > m_entries
 Holds the entries of the matrix, of length numNonZeros().
 
- Protected Attributes inherited from LvArray::SparsityPatternView< COL_TYPE, INDEX_TYPE, BUFFER_TYPE >
INDEX_TYPE_NC m_numCols
 The number of columns in the matrix.
 
- Protected Attributes inherited from LvArray::ArrayOfArraysView< COL_TYPE, INDEX_TYPE, std::is_const< COL_TYPE >::value, BUFFER_TYPE >
INDEX_TYPE_NC m_numArrays
 The number of arrays contained.
 
BUFFER_TYPE< INDEX_TYPE > m_offsets
 
BUFFER_TYPE< SIZE_TYPEm_sizes
 Holds the size of each array.
 
BUFFER_TYPE< COL_TYPE > m_values
 

Additional Inherited Members

- Protected Types inherited from LvArray::SparsityPatternView< COL_TYPE, INDEX_TYPE, BUFFER_TYPE >
using ParentClass = ArrayOfSetsView< COL_TYPE, INDEX_TYPE, BUFFER_TYPE >
 An alias for the parent class.
 
using INDEX_TYPE_NC = typename ParentClass::INDEX_TYPE_NC
 Since INDEX_TYPE should always be const we need an alias for the non const version.
 
using SIZE_TYPE = std::conditional_t< CONST_SIZES, INDEX_TYPE const, INDEX_TYPE_NC >
 The type contained by the m_sizes buffer.
 
using ColType = COL_TYPE
 The integer type used to enumerate the columns.
 
using IndexType = INDEX_TYPE
 The integer type used for indexing.
 
- Protected Types inherited from LvArray::ArrayOfSetsView< COL_TYPE, INDEX_TYPE, BUFFER_TYPE >
using ParentClass = ArrayOfArraysView< COL_TYPE, INDEX_TYPE, std::is_const< COL_TYPE >::value, BUFFER_TYPE >
 Alias for the parent class.
 
using INDEX_TYPE_NC = typename ParentClass::INDEX_TYPE_NC
 Since INDEX_TYPE should always be const we need an alias for the non const version.
 
using SIZE_TYPE = std::conditional_t< CONST_SIZES, INDEX_TYPE const, INDEX_TYPE_NC >
 The type contained by the m_sizes buffer.
 
using ValueType = COL_TYPE
 An alias for the type contained in the inner arrays.
 
using IndexType = INDEX_TYPE
 The integer type used for indexing.
 
using value_type = COL_TYPE
 An alias for the type contained in the inner arrays, here for stl compatability.
 
using size_type = INDEX_TYPE
 The integer type used for indexing, here for stl compatability.
 
- Protected Types inherited from LvArray::ArrayOfArraysView< COL_TYPE, INDEX_TYPE, std::is_const< COL_TYPE >::value, BUFFER_TYPE >
using INDEX_TYPE_NC = std::remove_const_t< INDEX_TYPE >
 Since INDEX_TYPE should always be const we need an alias for the non const version.
 
using SIZE_TYPE = std::conditional_t< CONST_SIZES, INDEX_TYPE const, INDEX_TYPE_NC >
 The type contained by the m_sizes buffer.
 
using PairOfBuffers = std::pair< BUFFER_TYPE< U > &, BUFFER_TYPE< U > const & >
 Alias for a std::pair of buffers. More...
 
using ValueType = COL_TYPE
 An alias for the type contained in the inner arrays.
 
using IndexType = INDEX_TYPE
 The integer type used for indexing.
 
using value_type = COL_TYPE
 An alias for the type contained in the inner arrays, here for stl compatability.
 
using size_type = INDEX_TYPE
 The integer type used for indexing, here for stl compatability.
 

Detailed Description

template<typename T, typename COL_TYPE, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
class LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >

This class provides a view into a compressed row storage matrix.

Template Parameters
Tthe type of the entries of the matrix.
COL_TYPEthe integer used to enumerate the columns.
INDEX_TYPEthe integer to use for indexing.
Note
When INDEX_TYPE is const m_offsets is not copied back from the device. INDEX_TYPE should always be const since CRSMatrixView is not allowed to modify the offsets.
When COL_TYPE is const and INDEX_TYPE is const you cannot insert or remove from the View and. You can however modify the entries of the matrix which is copied back from the device.
When T, COL_TYPE and INDEX_TYPE are const you cannot modify the matrix in any way and nothing is copied back from the device.

Definition at line 74 of file CRSMatrixView.hpp.

Constructor & Destructor Documentation

◆ CRSMatrixView() [1/3]

template<typename T, typename COL_TYPE, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::CRSMatrixView ( )
default

A constructor to create an uninitialized CRSMatrixView.

Note
An uninitialized CRSMatrixView should not be used until it is assigned to.

◆ CRSMatrixView() [2/3]

template<typename T, typename COL_TYPE, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
constexpr LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::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 
)
inline

Construct a new CRSMatrixView from the given buffers.

Parameters
nRowsThe number of rows.
nColsThe number of columns
offsetsThe offsets buffer, of size nRows + 1.
nnzThe buffer containing the number of non zeros in each row, of size nRows.
columnsThe columns buffer, of size offsets[ nRows ].
entriesThe entries buffer, of size offsets[ nRows ].

Definition at line 127 of file CRSMatrixView.hpp.

◆ CRSMatrixView() [3/3]

template<typename T, typename COL_TYPE, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::CRSMatrixView ( bool  )
inlineprotected

Protected constructor to be used by the CRSMatrix class.

Note
The unused boolean parameter is to distinguish this from the default constructor.

Definition at line 555 of file CRSMatrixView.hpp.

Member Function Documentation

◆ addToRow()

template<typename T, typename COL_TYPE, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
template<typename AtomicPolicy >
void LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::addToRow ( INDEX_TYPE const  row,
COL_TYPE const *const LVARRAY_RESTRICT  cols,
T const *const LVARRAY_RESTRICT  vals,
INDEX_TYPE const  nCols 
) const
inline

Add to the given entries, the entries must already exist in the matrix. The columns must be sorted.

Template Parameters
AtomicPolicythe policy to use when adding to the values.
Parameters
rowThe row to access.
colsThe columns to add to, must be sorted, unique and of length nCols.
valsThe values to add, of length nCols.
nColsThe number of columns to add to.
Precondition
The range [ cols, cols + ncols ) must be sorted and contain no duplicates. TODO: Use benchmarks of addToRowBinarySearch and addToRowLinearSearch to develop a better heuristic.

Definition at line 401 of file CRSMatrixView.hpp.

◆ addToRowBinarySearch()

template<typename T, typename COL_TYPE, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
template<typename AtomicPolicy >
void LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::addToRowBinarySearch ( INDEX_TYPE const  row,
COL_TYPE const *const LVARRAY_RESTRICT  cols,
T const *const LVARRAY_RESTRICT  vals,
INDEX_TYPE const  nCols 
) const
inline

Add to the given entries, the entries must already exist in the matrix.

This method uses a binary search to find the entries in the row to add to. This makes the method O( nCols * log( numNonZeros( row ) ) ) and is therefore best to use when nCols is much less than numNonZeros( row ).

Template Parameters
AtomicPolicythe policy to use when adding to the values.
Parameters
rowThe row to access.
colsThe columns to add to, must be sorted, unique and of length nCols.
valsThe values to add, of length nCols.
nColsThe number of columns to add to.
Precondition
The range [ cols, cols + ncols ) must be sorted and contain no duplicates.

Definition at line 431 of file CRSMatrixView.hpp.

◆ addToRowBinarySearchUnsorted()

template<typename T, typename COL_TYPE, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
template<typename AtomicPolicy >
void LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::addToRowBinarySearchUnsorted ( INDEX_TYPE const  row,
COL_TYPE const *const LVARRAY_RESTRICT  cols,
T const *const LVARRAY_RESTRICT  vals,
INDEX_TYPE const  nCols 
) const
inline

Add to the given entries, the entries must already exist in the matrix.

This method uses a binary search to find the entries in the row to add to. This makes the method O( nCols * log( numNonZeros( row ) ) ) and is therefore best to use when nCols is much less than numNonZeros( row ).

Template Parameters
AtomicPolicythe policy to use when adding to the values.
Parameters
rowThe row to access.
colsThe columns to add to, unsorted, of length nCols.
valsThe values to add, of length nCols.
nColsThe number of columns to add to.

Definition at line 509 of file CRSMatrixView.hpp.

◆ addToRowLinearSearch()

template<typename T, typename COL_TYPE, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
template<typename AtomicPolicy >
void LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::addToRowLinearSearch ( INDEX_TYPE const  row,
COL_TYPE const *const LVARRAY_RESTRICT  cols,
T const *const LVARRAY_RESTRICT  vals,
INDEX_TYPE const  nCols 
) const
inline

Add to the given entries, the entries must already exist in the matrix.

This method uses a linear search to find the entries in the row to add to. This makes the method O( numNonZeros( row ) ) and is therefore best to use when nCols is similar to numNonZeros( row ).

Template Parameters
AtomicPolicythe policy to use when adding to the values.
Parameters
rowThe row to access.
colsThe columns to add to, must be sorted, unique and of length nCols.
valsThe values to add, of length nCols.
nColsThe number of columns to add to.
Precondition
The range [ cols, cols + ncols ) must be sorted and contain no duplicates.

Definition at line 468 of file CRSMatrixView.hpp.

◆ getEntries() [1/2]

template<typename T, typename COL_TYPE, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
ArraySlice< T, 1, 0, INDEX_TYPE_NC > LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::getEntries ( INDEX_TYPE const  row) const
inline
Returns
Return an ArraySlice1d to the matrix entries of the given row.
Parameters
rowThe row to access.

Definition at line 240 of file CRSMatrixView.hpp.

◆ getEntries() [2/2]

template<typename T, typename COL_TYPE, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
T const* LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::getEntries ( ) const
inline
Returns
A pointer to the values of m_entires(data) of the matrix.

Definition at line 252 of file CRSMatrixView.hpp.

◆ insertNonZero()

template<typename T, typename COL_TYPE, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
bool LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::insertNonZero ( INDEX_TYPE const  row,
COL_TYPE const  col,
T const &  entry 
) const
inline

Insert a non-zero entry at the given position.

Parameters
rowThe row to insert in.
colThe column to insert at.
entryThe entry to insert.
Returns
True iff the entry was inserted (the entry was zero before).
Precondition
Since the CRSMatrixView can't do reallocation or shift the offsets it is up to the user to ensure that the given row has enough space for the new entry.

Definition at line 278 of file CRSMatrixView.hpp.

◆ insertNonZeros()

template<typename T, typename COL_TYPE, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
INDEX_TYPE_NC LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::insertNonZeros ( INDEX_TYPE const  row,
COL_TYPE const *const LVARRAY_RESTRICT  cols,
T const *const LVARRAY_RESTRICT  entriesToInsert,
INDEX_TYPE const  ncols 
) const
inline

Insert a non-zero entries into the given row.

Parameters
rowThe row to insert into.
colsThe columns to insert at, of length ncols. Must be sorted.
entriesToInsertThe entries to insert, of length ncols.
ncolsThe number of columns/entries to insert.
Returns
The number of entries inserted.
Precondition
The range [ cols, cols + ncols ) must be sorted and contain no duplicates.
Since the CRSMatrixView can't do reallocation or shift the offsets it is up to the user to ensure that the given row has enough space for the new entries.

Definition at line 293 of file CRSMatrixView.hpp.

◆ move()

template<typename T, typename COL_TYPE, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
void LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::move ( MemorySpace const  space,
bool const  touch = true 
) const
inline

Move this matrix to the given memory space and touch the values, sizes and offsets.

Parameters
spacethe memory space to move to.
touchIf true touch the values, sizes and offsets in the new space.
Note
When moving to the GPU since the offsets can't be modified on device they are not touched.

Definition at line 541 of file CRSMatrixView.hpp.

◆ operator=() [1/2]

template<typename T, typename COL_TYPE, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
CRSMatrixView& LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::operator= ( CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE > const &  )
inlinedefault

Default copy assignment operator.

Returns
*this.

◆ operator=() [2/2]

template<typename T, typename COL_TYPE, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
CRSMatrixView& LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::operator= ( CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE > &&  )
inlinedefault

Default move assignment operator.

Returns
*this.

◆ removeNonZero()

template<typename T, typename COL_TYPE, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
bool LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::removeNonZero ( INDEX_TYPE const  row,
COL_TYPE const  col 
) const
inline

Remove a non-zero entry at the given position.

Parameters
rowThe row to remove from.
colThe column to remove.
Returns
True iff the entry was removed (the entry was non-zero before).

Definition at line 306 of file CRSMatrixView.hpp.

◆ removeNonZeros()

template<typename T, typename COL_TYPE, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
INDEX_TYPE_NC LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::removeNonZeros ( INDEX_TYPE const  row,
COL_TYPE const *const LVARRAY_RESTRICT  cols,
INDEX_TYPE const  ncols 
) const
inline

Remove non-zero entries from the given row.

Parameters
rowThe row to remove from.
colsThe columns to remove, of length ncols.
ncolsThe number of columns to remove.
Returns
True iff the entry was removed (the entry was non-zero before).
Precondition
The range [ cols, cols + ncols ) must be sorted and contain no duplicates.

Definition at line 319 of file CRSMatrixView.hpp.

◆ setName()

template<typename T, typename COL_TYPE, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
template<typename U >
void LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::setName ( std::string const &  name)
inlineprotected

Set the name to be displayed whenever the underlying Buffer's user call back is called.

Template Parameters
UThe type of the owning object.
Parameters
namethe name to display.

Definition at line 566 of file CRSMatrixView.hpp.

◆ setValues()

template<typename T, typename COL_TYPE, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
template<typename POLICY >
void LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::setValues ( T const &  value) const
inline

Set all the entries in the matrix to the given value.

Template Parameters
POLICYThe kernel launch policy to use.
Parameters
valueThe value to set entries in the matrix to.

Definition at line 345 of file CRSMatrixView.hpp.

◆ toSparsityPatternView()

template<typename T, typename COL_TYPE, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
constexpr SparsityPatternView< COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::toSparsityPatternView ( ) const &
inline
Returns
A reference to *this reinterpreted as a SparsityPatternView< COL_TYPE const, INDEX_TYPE const >.

Definition at line 206 of file CRSMatrixView.hpp.

◆ toView()

template<typename T, typename COL_TYPE, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
constexpr CRSMatrixView< T, COL_TYPE, INDEX_TYPE const, BUFFER_TYPE > LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::toView ( ) const
inline
Returns
A new CRSMatrixView< T, COL_TYPE, INDEX_TYPE const >.

Definition at line 161 of file CRSMatrixView.hpp.

◆ toViewConst()

template<typename T, typename COL_TYPE, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
constexpr CRSMatrixView< T const, COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::toViewConst ( ) const
inline
Returns
A new CRSMatrixView< T const, COL_TYPE const, INDEX_TYPE const >.

Definition at line 191 of file CRSMatrixView.hpp.

◆ toViewConstSizes()

template<typename T, typename COL_TYPE, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
constexpr CRSMatrixView< T, COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::toViewConstSizes ( ) const
inline
Returns
A new CRSMatrixView< T, COL_TYPE const, INDEX_TYPE const >.

Definition at line 176 of file CRSMatrixView.hpp.

◆ zero()

template<typename T, typename COL_TYPE, typename INDEX_TYPE, template< typename > class BUFFER_TYPE>
void LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::zero ( ) const
inline

Use memset to set all the values in the matrix to 0.

This is preferred over setValues< POLICY >( 0 ) for numeric types since it is much faster in most cases. If the buffer is allocated using Umpire then the Umpire ResouceManager is used, otherwise std::memset is used. This zeroes out all of the memory spanned by m_entries including values that are part of overallocated capacity so if you have a small matrix with a huge capacity it won't be as quick as you might like.

Note
The memset occurs in the last space the matrix was used in and the matrix is moved and the entries are touched in that space.

Definition at line 369 of file CRSMatrixView.hpp.


The documentation for this class was generated from the following file: