Implementation of the Compressed-Sparse Row (CSR) Sparse Matrix Format Representation.
More...
|
| using | traits = ContainerTraits< CsrMatrix, ValueType, Properties... > |
| |
| using | type = typename traits::type |
| |
|
using | base = MatrixBase< CsrMatrix, ValueType, Properties... > |
| |
| using | tag = typename MatrixFormatTag< Morpheus::CsrFormatTag >::tag |
| |
| using | value_type = typename traits::value_type |
| |
| using | non_const_value_type = typename traits::non_const_value_type |
| |
|
using | size_type = typename traits::size_type |
| |
| using | index_type = typename traits::index_type |
| |
| using | non_const_index_type = typename traits::non_const_index_type |
| |
|
using | array_layout = typename traits::array_layout |
| |
|
using | backend = typename traits::backend |
| |
|
using | memory_space = typename traits::memory_space |
| |
|
using | execution_space = typename traits::execution_space |
| |
|
using | device_type = typename traits::device_type |
| |
|
using | memory_traits = typename traits::memory_traits |
| |
|
using | HostMirror = typename traits::HostMirror |
| |
|
using | pointer = typename traits::pointer |
| |
|
using | const_pointer = typename traits::const_pointer |
| |
|
using | reference = typename traits::reference |
| |
|
using | const_reference = typename traits::const_reference |
| |
| using | index_array_type = Morpheus::DenseVector< index_type, size_type, array_layout, backend, memory_traits > |
| |
|
using | const_index_array_type = const index_array_type |
| |
|
using | index_array_pointer = typename index_array_type::value_array_pointer |
| |
|
using | index_array_reference = typename index_array_type::value_array_reference |
| |
|
using | const_index_array_reference = const index_array_reference |
| |
| using | value_array_type = Morpheus::DenseVector< value_type, size_type, array_layout, backend, memory_traits > |
| |
|
using | const_value_array_type = const value_array_type |
| |
|
using | value_array_pointer = typename value_array_type::value_array_pointer |
| |
|
using | value_array_reference = typename value_array_type::value_array_reference |
| |
|
using | const_value_array_reference = const value_array_reference |
| |
|
using | type = MatrixBase< CsrMatrix, ValueType, Properties... > |
| | The traits associated with the particular container.
|
| |
|
using | traits = ContainerTraits< CsrMatrix, ValueType, Properties... > |
| | The type of the indices held by the container.
|
| |
|
using | size_type = typename traits::size_type |
| |
| enum | { is_hostspace = std::is_same<MemorySpace, Kokkos::HostSpace>::value
} |
| |
| enum | { is_managed = MemoryTraits::is_unmanaged == 0
} |
| |
|
using | value_type = ValueType |
| | The type of values held by the container.
|
| |
|
using | const_value_type = typename std::add_const< ValueType >::type |
| | The const type of values held by the container.
|
| |
|
using | non_const_value_type = typename std::remove_const< ValueType >::type |
| | The non-const type of values held by the container.
|
| |
|
using | index_type = IndexType |
| | The type of indices held by the container.
|
| |
|
using | size_type = size_t |
| | The size type of the container.
|
| |
|
using | non_const_index_type = typename std::remove_const< IndexType >::type |
| | The non-const type of indices held by the container.
|
| |
|
using | array_layout = ArrayLayout |
| | The storage layout of data held by the container.
|
| |
|
using | backend = Backend |
| | The backend out of which algorithms will be dispatched from.
|
| |
|
using | execution_space = ExecutionSpace |
| | The space in which member functions will be executed in.
|
| |
|
using | memory_space = MemorySpace |
| | The space in which data will be stored in.
|
| |
|
using | device_type = Morpheus::Device< execution_space, memory_space, backend > |
| | A device aware of the execution, memory spaces and backend.
|
| |
|
using | memory_traits = MemoryTraits |
| | Represents the user's intended access behaviour.
|
| |
|
using | host_mirror_backend = typename Morpheus::HostMirror< backend >::backend |
| | The host equivalent backend.
|
| |
|
using | type = Container< value_type, index_type, array_layout, backend, memory_traits > |
| | The complete type of the container.
|
| |
| using | HostMirror = Container< non_const_value_type, non_const_index_type, array_layout, Morpheus::Device< typename host_mirror_backend::execution_space, typename host_mirror_backend::memory_space, typename host_mirror_backend::backend >, typename Kokkos::MemoryManaged > |
| | The host mirror equivalent for the container. More...
|
| |
|
using | pointer = typename std::add_pointer< type >::type |
| | The pointer type of the container.
|
| |
|
using | const_pointer = typename std::add_pointer< typename std::add_const< type >::type >::type |
| | The const pointer type of the container.
|
| |
|
using | reference = typename std::add_lvalue_reference< type >::type |
| | The reference type of the container.
|
| |
|
using | const_reference = typename std::add_lvalue_reference< typename std::add_const< type >::type >::type |
| | The const reference type of the container.
|
| |
|
|
| ~CsrMatrix ()=default |
| | The default destructor.
|
| |
|
| CsrMatrix (const CsrMatrix &)=default |
| | The default copy contructor (shallow copy) of a CsrMatrix container from another CsrMatrix container with the same properties.
|
| |
|
| CsrMatrix (CsrMatrix &&)=default |
| | The default move contructor (shallow copy) of a CsrMatrix container from another CsrMatrix container with the same properties.
|
| |
|
CsrMatrix & | operator= (const CsrMatrix &)=default |
| | The default copy assignment (shallow copy) of a CsrMatrix container from another CsrMatrix container with the same properties.
|
| |
|
CsrMatrix & | operator= (CsrMatrix &&)=default |
| | The default move assignment (shallow copy) of a CsrMatrix container from another CsrMatrix container with the same properties.
|
| |
|
| CsrMatrix () |
| | Construct an empty CsrMatrix object.
|
| |
| | CsrMatrix (const size_type num_rows, const size_type num_cols, const size_type num_entries) |
| | Construct a CsrMatrix object with shape (num_rows, num_cols) and number of non-zeros equal to num_entries. More...
|
| |
|
template<typename ValuePtr , typename IndexPtr > |
| | CsrMatrix (const size_type num_rows, const size_type num_cols, const size_type num_entries, IndexPtr roff_ptr, IndexPtr cind_ptr, ValuePtr vals_ptr, typename std::enable_if<(std::is_pointer< ValuePtr >::value &&is_same_value_type< value_type, ValuePtr >::value &&memory_traits::is_unmanaged) &&(std::is_pointer< IndexPtr >::value &&is_same_index_type< index_type, IndexPtr >::value &&memory_traits::is_unmanaged)>::type *=nullptr) |
| |
| template<typename ValueArray , typename IndexArray > |
| | CsrMatrix (const size_type num_rows, const size_type num_cols, const size_type num_entries, IndexArray roff, IndexArray cind, ValueArray vals, typename std::enable_if< is_dense_vector_format_container< ValueArray >::value &&is_dense_vector_format_container< IndexArray >::value &&is_compatible< typename CsrMatrix::value_array_type, ValueArray >::value &&is_compatible< typename CsrMatrix::index_array_type, IndexArray >::value &&!ValueArray::memory_traits::is_unmanaged &&!IndexArray::memory_traits::is_unmanaged >::type *=nullptr) |
| | Construct a CsrMatrix object with shape (num_rows, num_cols) and number of non-zeros equal to num_entries and assign the indices and values from DenseVector arrays. More...
|
| |
| template<class VR , class... PR> |
| | CsrMatrix (const CsrMatrix< VR, PR... > &src, typename std::enable_if< is_format_compatible< CsrMatrix, CsrMatrix< VR, PR... > >::value >::type *=nullptr) |
| | Constructs a CsrMatrix from another compatible CsrMatrix. More...
|
| |
| template<class VR , class... PR> |
| std::enable_if< is_format_compatible< CsrMatrix, CsrMatrix< VR, PR... > >::value, CsrMatrix & >::type | operator= (const CsrMatrix< VR, PR... > &src) |
| | Assigns a CsrMatrix from another compatible CsrMatrix. More...
|
| |
| template<class VR , class... PR> |
| | CsrMatrix (const DynamicMatrix< VR, PR... > &src, typename std::enable_if< is_dynamically_compatible< CsrMatrix, DynamicMatrix< VR, PR... > >::value >::type *=nullptr) |
| | Constructs a CsrMatrix from a compatible DynamicMatrix. More...
|
| |
| template<class VR , class... PR> |
| std::enable_if< is_dynamically_compatible< CsrMatrix, DynamicMatrix< VR, PR... > >::value, CsrMatrix & >::type | operator= (const DynamicMatrix< VR, PR... > &src) |
| | Assigns a CsrMatrix from a compatible DynamicMatrix. More...
|
| |
| template<typename MatrixType > |
| | CsrMatrix (const MatrixType &src)=delete |
| | Construct a CsrMatrix object from another storage format. This functionality is disabled to avoid implicit copies and conversion operations. More...
|
| |
| template<typename MatrixType > |
| reference | operator= (const MatrixType &src)=delete |
| | Assigns to CsrMatrix object from another storage format. This functionality is disabled to avoid implicit copies and conversion operations. More...
|
| |
| void | resize (const size_type num_rows, const size_type num_cols, const size_type num_entries) |
| | Resizes CsrMatrix with shape of (num_rows, num_cols) and sets number of non-zero entries to num_entries. More...
|
| |
| template<class VR , class... PR> |
| void | resize (const CsrMatrix< VR, PR... > &src) |
| | Resizes CsrMatrix with the shape and number of non-zero entries of another CsrMatrix with different parameters. More...
|
| |
| template<class VR , class... PR> |
| CsrMatrix & | allocate (const CsrMatrix< VR, PR... > &src) |
| | Allocates memory from another CsrMatrix container with different properties. More...
|
| |
| formats_e | format_enum () const |
| | Returns the format enum assigned to the CsrMatrix container. More...
|
| |
| int | format_index () const |
| | Returns the equivalent index to the format enum assigned to the CsrMatrix container. More...
|
| |
| MORPHEUS_FORCEINLINE_FUNCTION index_array_reference | row_offsets (size_type n) |
| | Returns a reference to the row offset of the matrix with index n. More...
|
| |
| MORPHEUS_FORCEINLINE_FUNCTION index_array_reference | column_indices (size_type n) |
| | Returns a reference to the column index of the matrix with index n. More...
|
| |
| MORPHEUS_FORCEINLINE_FUNCTION value_array_reference | values (size_type n) |
| | Returns a reference to the value of the matrix with index n. More...
|
| |
| MORPHEUS_FORCEINLINE_FUNCTION const_index_array_reference | crow_offsets (size_type n) const |
| | Returns a const-reference to the row offset of the matrix with index n. More...
|
| |
| MORPHEUS_FORCEINLINE_FUNCTION const_index_array_reference | ccolumn_indices (size_type n) const |
| | Returns a const-reference to the column index of the matrix with index n. More...
|
| |
| MORPHEUS_FORCEINLINE_FUNCTION const_value_array_reference | cvalues (size_type n) const |
| | Returns a const-reference to the value of the matrix with index n. More...
|
| |
| MORPHEUS_FORCEINLINE_FUNCTION index_array_type & | row_offsets () |
| | Returns a reference to the row offsets of the matrix. More...
|
| |
| MORPHEUS_FORCEINLINE_FUNCTION index_array_type & | column_indices () |
| | Returns a reference to the column indices of the matrix. More...
|
| |
| MORPHEUS_FORCEINLINE_FUNCTION value_array_type & | values () |
| | Returns a reference to the values of the matrix. More...
|
| |
| MORPHEUS_FORCEINLINE_FUNCTION const_index_array_type & | crow_offsets () const |
| | Returns a const-reference to the row offsets of the matrix. More...
|
| |
| MORPHEUS_FORCEINLINE_FUNCTION const_index_array_type & | ccolumn_indices () const |
| | Returns a const-reference to the column indices of the matrix. More...
|
| |
| MORPHEUS_FORCEINLINE_FUNCTION const_value_array_type & | cvalues () const |
| | Returns a reference to the values of the matrix. More...
|
| |
| | MatrixBase () |
| | Default constructor. More...
|
| |
| | MatrixBase (size_type rows, size_type cols, size_type entries=0) |
| | Construct a MatrixBase object with shape (num_rows, num_cols) and number of non-zeros equal to num_entries. More...
|
| |
| void | resize (size_type rows, size_type cols, size_type entries) |
| | Resizes MatrixBase with shape of (num_rows, num_cols) and sets number of non-zero entries to num_entries. More...
|
| |
| size_type | nrows () const |
| | Number of rows of the matrix. More...
|
| |
| size_type | ncols () const |
| | Number of columns of the matrix. More...
|
| |
| size_type | nnnz () const |
| | Number of non-zeros of the matrix. More...
|
| |
| void | set_nrows (const size_type rows) |
| | Set the number of rows of the matrix. More...
|
| |
| void | set_ncols (const size_type cols) |
| | Set the number of columns of the matrix. More...
|
| |
| void | set_nnnz (const size_type nnz) |
| | Set the number of non-zeros of the matrix. More...
|
| |
| MatrixStructure | structure () const |
| | The specialized structure of the matrix e.g Symmetric. More...
|
| |
| MatrixOptions | options () const |
| | Information about specific characteristics of the matrix e.g has short rows. More...
|
| |
| void | set_structure (MatrixStructure op) |
| | Set the structure of the matrix. More...
|
| |
| void | set_options (MatrixOptions op) |
| | Set the characteristics of the matrix. More...
|
| |
template<class
ValueType, class... Properties>
class Morpheus::CsrMatrix< ValueType, Properties >
Implementation of the Compressed-Sparse Row (CSR) Sparse Matrix Format Representation.
- Template Parameters
-
| ValueType | Type of values to store |
| Properties | Optional properties to modify the behaviour of the container. Sensible defaults are selected based on the configuration. Please refer to impl/Morpheus_ContainerTraits.hpp to find out more about the valid properties. |
- Overview
- The CsrMatrix container is a two-dimensional container that represents a sparse matrix. This container is the compressed implementation of the COO Format, where the row indices array is compressed. In general, it allows for fast row access and matrix-vector multiplications and it is one of the most widely used formats. It is a polymorphic container in the sense that it can store scalar or integer type values, on host or device depending how the template parameters are selected.
- Example
#include <Morpheus_Core.hpp>
int main(){
off[0] = 0; off[1] = 2; off[2] = 3; off[3] = 4;
j[0] = 0; v[0] = 1;
j[1] = 2; v[1] = 2;
j[2] = 2; v[2] = 3;
j[3] = 1; v[3] = 4;
Matrix A(3, 3, 4, off, j, v);
Morpheus::print(A);
}
Implementation of the Compressed-Sparse Row (CSR) Sparse Matrix Format Representation.
Definition: Morpheus_CsrMatrix.hpp:91