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

This class implements a compressed row storage matrix. More...

#include <CRSMatrix.hpp>

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

Public Types

using EntryType = T
 The type of the entries in the matrix.
 

Public Member Functions

void setName (std::string const &name)
 Set the name associated with this CRSMatrix which is used in the chai callback. More...
 
Constructors and the destructor
 CRSMatrix (INDEX_TYPE const nrows=0, INDEX_TYPE const ncols=0, INDEX_TYPE const initialRowCapacity=0)
 Constructor. More...
 
 CRSMatrix (CRSMatrix const &src)
 Copy constructor, performs a deep copy. More...
 
 CRSMatrix (CRSMatrix &&)=default
 Default move constructor, performs a shallow copy.
 
 ~CRSMatrix ()
 Destructor, frees the entries, values (columns), sizes and offsets Buffers.
 
Methods to construct the matrix from scratch.
CRSMatrixoperator= (CRSMatrix const &src)
 Copy assignment operator, performs a deep copy. More...
 
CRSMatrixoperator= (CRSMatrix &&src)
 Default move assignment operator, performs a shallow copy. More...
 
template<typename POLICY >
void assimilate (SparsityPattern< COL_TYPE, INDEX_TYPE, BUFFER_TYPE > &&src)
 Steal the resources from a SparsityPattern. More...
 
template<typename POLICY >
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. More...
 
CRSMatrixView and SparsityPatternView creation methods
constexpr CRSMatrixView< T, COL_TYPE, INDEX_TYPE const, BUFFER_TYPE > toView () const &
 
constexpr CRSMatrixView< T, COL_TYPE, INDEX_TYPE const, BUFFER_TYPE > toView () const &&=delete
 Overload for rvalues that is deleted. More...
 
constexpr CRSMatrixView< T, COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > toViewConstSizes () const &
 
constexpr CRSMatrixView< T, COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > toViewConstSizes () const &&=delete
 Overload for rvalues that is deleted. More...
 
constexpr CRSMatrixView< T const, COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > toViewConst () const &
 
constexpr CRSMatrixView< T const, COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > toViewConst () const &&=delete
 Overload for rvalues that is deleted. More...
 
constexpr SparsityPatternView< COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > toSparsityPatternView () const &&=delete
 Overload for rvalues that is deleted. More...
 
Methods to change the capacity
void reserveNonZeros (INDEX_TYPE const nnz)
 Reserve space to hold at least the given total number of non zero entries. More...
 
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. More...
 
void setRowCapacity (INDEX_TYPE const row, INDEX_TYPE newCapacity)
 Set the non zero capacity of the given row. More...
 
void resize (INDEX_TYPE const nRows, INDEX_TYPE const nCols, INDEX_TYPE const initialRowCapacity)
 Set the dimensions of the matrix. More...
 
void compress ()
 Compress the CRSMatrix so that the non-zeros and values of each row are contiguous with no extra capacity in between. More...
 
Methods that insert or remove entries from a row.
bool insertNonZero (INDEX_TYPE const row, COL_TYPE const col, T const &entry)
 Insert a non-zero entry at the given position. More...
 
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. 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...
 
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 SparsityPattern to the given memory space and touch the values, sizes and offsets. More...
 

Additional Inherited Members

- Protected Types inherited from LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >
using EntryType = T
 The type of the entries in the matrix.
 
using ColType = COL_TYPE
 The integer type used to enumerate the columns.
 
- 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.
 
- Protected Member Functions inherited from LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >
 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...
 
 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...
 
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 &
 
ArraySlice< T, 1, 0, INDEX_TYPE_NCgetEntries (INDEX_TYPE const row) const
 
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...
 
template<typename POLICY >
void setValues (T const &value) const
 Set all the entries in the matrix to the given value. 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...
 
void move (MemorySpace const space, bool const touch=true) const
 Move this SparsityPattern to the given memory space and touch the values, sizes and offsets. 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
 
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_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 inherited from LvArray::CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >
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
 

Detailed Description

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

This class implements a compressed row storage matrix.

Template Parameters
Tthe type of the entries in the matrix.
COL_TYPEthe integer used to enumerate the columns.
INDEX_TYPEthe integer to use for indexing.

Definition at line 35 of file CRSMatrix.hpp.

Constructor & Destructor Documentation

◆ CRSMatrix() [1/2]

template<typename T , typename COL_TYPE , typename INDEX_TYPE , template< typename > class BUFFER_TYPE>
LvArray::CRSMatrix< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::CRSMatrix ( INDEX_TYPE const  nrows = 0,
INDEX_TYPE const  ncols = 0,
INDEX_TYPE const  initialRowCapacity = 0 
)
inline

Constructor.

Parameters
nrowsthe number of rows in the matrix.
ncolsthe number of columns in the matrix.
initialRowCapacitythe initial non zero capacity of each row.

Definition at line 58 of file CRSMatrix.hpp.

◆ CRSMatrix() [2/2]

template<typename T , typename COL_TYPE , typename INDEX_TYPE , template< typename > class BUFFER_TYPE>
LvArray::CRSMatrix< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::CRSMatrix ( CRSMatrix< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE > const &  src)
inline

Copy constructor, performs a deep copy.

Parameters
srcthe CRSMatrix to copy.

Definition at line 72 of file CRSMatrix.hpp.

Member Function Documentation

◆ addToRow()

template<typename T , typename COL_TYPE , typename INDEX_TYPE , template< typename > class BUFFER_TYPE>
template<typename AtomicPolicy >
void LvArray::CRSMatrix< 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.
Note
This is not brought in with a using statement because it breaks doxygen.

Definition at line 423 of file CRSMatrix.hpp.

◆ addToRowBinarySearch()

template<typename T , typename COL_TYPE , typename INDEX_TYPE , template< typename > class BUFFER_TYPE>
template<typename AtomicPolicy >
void LvArray::CRSMatrix< 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.
Note
This is not brought in with a using statement because it breaks doxygen.

Definition at line 435 of file CRSMatrix.hpp.

◆ addToRowBinarySearchUnsorted()

template<typename T , typename COL_TYPE , typename INDEX_TYPE , template< typename > class BUFFER_TYPE>
template<typename AtomicPolicy >
void LvArray::CRSMatrix< 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, must be sorted, unique and of length nCols.
valsThe values to add, of length nCols.
nColsThe number of columns to add to.
Note
This is not brought in with a using statement because it breaks doxygen.

Definition at line 459 of file CRSMatrix.hpp.

◆ addToRowLinearSearch()

template<typename T , typename COL_TYPE , typename INDEX_TYPE , template< typename > class BUFFER_TYPE>
template<typename AtomicPolicy >
void LvArray::CRSMatrix< 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.
Note
This is not brought in with a using statement because it breaks doxygen.

Definition at line 447 of file CRSMatrix.hpp.

◆ assimilate()

template<typename T , typename COL_TYPE , typename INDEX_TYPE , template< typename > class BUFFER_TYPE>
template<typename POLICY >
void LvArray::CRSMatrix< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::assimilate ( SparsityPattern< COL_TYPE, INDEX_TYPE, BUFFER_TYPE > &&  src)
inline

Steal the resources from a SparsityPattern.

Parameters
srcthe SparsityPattern to convert.
Note
All entries are default initialized. For numeric types this is zero initialization.

Definition at line 133 of file CRSMatrix.hpp.

◆ compress()

template<typename T , typename COL_TYPE , typename INDEX_TYPE , template< typename > class BUFFER_TYPE>
void LvArray::CRSMatrix< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::compress ( )
inline

Compress the CRSMatrix so that the non-zeros and values of each row are contiguous with no extra capacity in between.

Note
This method doesn't free any memory.

Definition at line 360 of file CRSMatrix.hpp.

◆ insertNonZero()

template<typename T , typename COL_TYPE , typename INDEX_TYPE , template< typename > class BUFFER_TYPE>
bool LvArray::CRSMatrix< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::insertNonZero ( INDEX_TYPE const  row,
COL_TYPE const  col,
T const &  entry 
)
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).

Definition at line 378 of file CRSMatrix.hpp.

◆ insertNonZeros()

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

Insert a non-zero entries into the given row.

Parameters
rowthe row to insert into.
colsthe columns to insert at, of length ncols.
entriesToInsertthe entries to insert, of length ncols.
ncolsthe number of columns/entries to insert.
Returns
The number of entries inserted.
Note
The range [ entriesToInsert, entriesToInsert + ncols ) must be sorted and contain no duplicates.

Definition at line 392 of file CRSMatrix.hpp.

◆ move()

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

Move this SparsityPattern 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.
This is just a wrapper around the CRSMatrixView method. The reason it isn't pulled in with a using statement is that it is detected using IS_VALID_EXPRESSION and this fails with NVCC.

Definition at line 478 of file CRSMatrix.hpp.

◆ operator=() [1/2]

template<typename T , typename COL_TYPE , typename INDEX_TYPE , template< typename > class BUFFER_TYPE>
CRSMatrix& LvArray::CRSMatrix< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::operator= ( CRSMatrix< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE > const &  src)
inline

Copy assignment operator, performs a deep copy.

Parameters
srcthe CRSMatrix to copy.
Returns
*this.

Definition at line 101 of file CRSMatrix.hpp.

◆ operator=() [2/2]

template<typename T , typename COL_TYPE , typename INDEX_TYPE , template< typename > class BUFFER_TYPE>
CRSMatrix& LvArray::CRSMatrix< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::operator= ( CRSMatrix< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE > &&  src)
inline

Default move assignment operator, performs a shallow copy.

Parameters
srcThe CRSMatrix to be moved from.
Returns
*this.

Definition at line 119 of file CRSMatrix.hpp.

◆ reserveNonZeros() [1/2]

template<typename T , typename COL_TYPE , typename INDEX_TYPE , template< typename > class BUFFER_TYPE>
void LvArray::CRSMatrix< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::reserveNonZeros ( INDEX_TYPE const  nnz)
inline

Reserve space to hold at least the given total number of non zero entries.

Parameters
nnzthe number of no zero entries to reserve space for.

Definition at line 309 of file CRSMatrix.hpp.

◆ reserveNonZeros() [2/2]

template<typename T , typename COL_TYPE , typename INDEX_TYPE , template< typename > class BUFFER_TYPE>
void LvArray::CRSMatrix< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::reserveNonZeros ( INDEX_TYPE const  row,
INDEX_TYPE const  nnz 
)
inline

Reserve space to hold at least the given number of non zero entries in the given row.

Parameters
rowthe row to reserve space in.
nnzthe number of no zero entries to reserve space for.

Definition at line 318 of file CRSMatrix.hpp.

◆ resize()

template<typename T , typename COL_TYPE , typename INDEX_TYPE , template< typename > class BUFFER_TYPE>
void LvArray::CRSMatrix< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::resize ( INDEX_TYPE const  nRows,
INDEX_TYPE const  nCols,
INDEX_TYPE const  initialRowCapacity 
)
inline

Set the dimensions of the matrix.

Parameters
nRowsthe new number of rows.
nColsthe new number of columns.
initialRowCapacitythe default capacity for each new array.
Note
When shrinking the number of columns this method doesn't get rid of any existing entries. This can leave the matrix in an invalid state where a row has more columns than the matrix or where a specific column is greater than the number of columns in the matrix. If you will be constructing the matrix from scratch it is reccomended to clear it first.

Definition at line 351 of file CRSMatrix.hpp.

◆ resizeFromRowCapacities()

template<typename T , typename COL_TYPE , typename INDEX_TYPE , template< typename > class BUFFER_TYPE>
template<typename POLICY >
void LvArray::CRSMatrix< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::resizeFromRowCapacities ( INDEX_TYPE const  nRows,
INDEX_TYPE const  nCols,
INDEX_TYPE const *const  rowCapacities 
)
inline

Clears the matrix and creates a new matrix with the given number of rows and columns.

Template Parameters
POLICYThe RAJA policy used to convert rowCapacities into the offsets array. Should NOT be a device policy.
Parameters
nRowsThe new number of rows.
nColsThe new number of columns.
rowCapacitiesA pointer to an array of length nRows containing the capacity of each new row.

Definition at line 177 of file CRSMatrix.hpp.

◆ setName()

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

Set the name associated with this CRSMatrix which is used in the chai callback.

Parameters
namethe of the CRSMatrix.

Definition at line 487 of file CRSMatrix.hpp.

◆ setRowCapacity()

template<typename T , typename COL_TYPE , typename INDEX_TYPE , template< typename > class BUFFER_TYPE>
void LvArray::CRSMatrix< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::setRowCapacity ( INDEX_TYPE const  row,
INDEX_TYPE  newCapacity 
)
inline

Set the non zero capacity of the given row.

Parameters
rowthe row to modify.
newCapacitythe new capacity of the row.
Note
If the given capacity is less than the current number of non zero entries the entries are truncated.
Since a row can hold at most numColumns() entries the resulting capacity is min(newCapacity, numColumns()).

Definition at line 335 of file CRSMatrix.hpp.

◆ setValues()

template<typename T , typename COL_TYPE , typename INDEX_TYPE , template< typename > class BUFFER_TYPE>
template<typename POLICY >
void LvArray::CRSMatrix< 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.
Note
This is not brought in with a using statement because it breaks doxygen.

Definition at line 414 of file CRSMatrix.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::CRSMatrix< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::toSparsityPatternView ( ) const &&
inlinedelete

Overload for rvalues that is deleted.

Returns
A null CRSMatrixView.
Note
This cannot be called on a rvalue since the SparsityPatternView would contain the buffers of the current CRSMatrix that is about to be destroyed. This overload prevents that from happening.

◆ toView() [1/2]

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::CRSMatrix< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::toView ( ) const &
inline

Returns
A new CRSMatrixView< T, COL_TYPE, INDEX_TYPE const >.
Note
This is just a wrapper around the CRSMatrixView method. The reason it isn't pulled in with a using statement is that it is detected using IS_VALID_EXPRESSION and this fails with NVCC.

Definition at line 202 of file CRSMatrix.hpp.

◆ toView() [2/2]

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::CRSMatrix< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::toView ( ) const &&
inlinedelete

Overload for rvalues that is deleted.

Returns
A null CRSMatrixView.
Note
This cannot be called on a rvalue since the CRSMatrixView would contain the buffers of the current CRSMatrix that is about to be destroyed. This overload prevents that from happening.

◆ toViewConst() [1/2]

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::CRSMatrix< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::toViewConst ( ) const &
inline

Returns
A new CRSMatrixView< T const, COL_TYPE const, INDEX_TYPE const >.
Note
This is just a wrapper around the CRSMatrixView method. The reason it isn't pulled in with a using statement is that it is detected using IS_VALID_EXPRESSION and this fails with NVCC.

Definition at line 246 of file CRSMatrix.hpp.

◆ toViewConst() [2/2]

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::CRSMatrix< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::toViewConst ( ) const &&
inlinedelete

Overload for rvalues that is deleted.

Returns
A null CRSMatrixView.
Note
This cannot be called on a rvalue since the CRSMatrixView would contain the buffers of the current CRSMatrix that is about to be destroyed. This overload prevents that from happening.

◆ toViewConstSizes() [1/2]

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::CRSMatrix< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::toViewConstSizes ( ) const &
inline

Returns
A new CRSMatrixView< T, COL_TYPE const, INDEX_TYPE const >.
Note
This is just a wrapper around the CRSMatrixView method. The reason it isn't pulled in with a using statement is that it is detected using IS_VALID_EXPRESSION and this fails with NVCC.

Definition at line 224 of file CRSMatrix.hpp.

◆ toViewConstSizes() [2/2]

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::CRSMatrix< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE >::toViewConstSizes ( ) const &&
inlinedelete

Overload for rvalues that is deleted.

Returns
A null CRSMatrixView.
Note
This cannot be called on a rvalue since the CRSMatrixView would contain the buffers of the current CRSMatrix that is about to be destroyed. This overload prevents that from happening.

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