KokkosSparse::CrsMatrix ####################### .. toctree:: :maxdepth: 1 :hidden: CrsMatrix_constructors sparse_row_view Defined in header ``KokkosSparse_CrsMatrix.hpp`` .. code:: c++ template class CrsMatrix; ``KokkosSparse::CrsMatrix`` provides a compressed sparse row implementation of a sparse matrix, as described, for example, in Saad (2nd ed.). Template Parameters =================== :ScalarType: type of the values stored in the matrix. :OrdinalType: type of the indices storied in the matrix (column indices). :Device: type of the ``Kokkos::Device`` of the matrix :MemoryTraits: type of Kokkos memory traits used for the views of the matrix. :SizeType: type used to store row offsets. Member Types ============ .. list-table:: :widths: 30 70 :header-rows: 1 :align: left * - Member type - Definition * - execution_space - Alias for Device::execution_space. * - memory_space - Alias for Device::memory_space. * - device_type - Device associated with the matrix. * - value_type - Type of the values stored in the matrix, alias for ScalarType. * - ordinal_type - Type of the indices stored in the matrix, alias for OrdinalType. * - size_type - Type of the offsets stored in the matrix, alias for SizeType. * - memory_traits - Alias for MemoryTraits. * - host_mirror_type - CrsMatrix type templated on ScalarType, OrdinalType, host_mirror_space, MemoryTraits and SizeType. * - StaticCrsGraph - Type of the underlying static crs graph. * - staticcsrgraph - Alias for StaticCrsGraph. * - index_type - Type of the view storing the column indices in the underlying static crs graph. * - const_ordinal_type - Const variant for the type of the column indices stored in index_type. * - non_const_ordinal_type - Non-const variant for the type of the column indices stored in index_type. * - row_map_type - Type of the view storing the row offsets in the underlying static crs graph. * - const_size_type - Const variant for the type of the offsets stored in row_map_type. * - non_const_size_type - Non-const variant for the type of the offsets stored in row_map_type. * - values_type - Type of the view storing the values stored in the matrix. * - const_value_type - Const variant for the type of the values stored in values_type. * - non_const_value_type - Non-const variant for the type of the values stored in values_type. * - const_type - Type of an indentical matrix storing const values. Data Members ============ .. list-table:: :widths: 30 70 :header-rows: 1 :align: left * - Data Member - Definition * - staticcrsgraph_type graph - The underlying static crs graph of the matrix storing its sparsity pattern. * - values_type values - The values stored in the matrix. Member Functions ================ .. list-table:: :widths: 30 70 :header-rows: 1 :align: left * - Name - Definition * - `constructor `_ - Construct a CrsMatrix from inputs, this can perform shallow or deep copies of input parameters depending on inputs and semantic. * - :ref:`operator= ` - Assignment operator, will attempt to assign the data (graph and values) of the right hand side to the left hand side. If the assignment operator of graph or values fail, matrix assignment fails. * - :ref:`numRows ` - Returns the number of rows in the matrix. * - :ref:`numCols ` - Returns the number of columns in the matrix. * - :ref:`setNumCols ` - Modify the number of columns in the matrix. * - :ref:`numPointRows ` - Equivalent to `numRows()`. * - :ref:`numPointCols ` - Equivalent to `numCols()`. * - :ref:`nnz ` - Returns the number of structural non-zero values in the matrix (some of these might actually store zero). * - :ref:`row ` - Returns a SparseRowView object from a row of the matrix. * - :ref:`rowConst ` - Returns a SparseRowViewConst object from a row of the matrix. .. _crsmatrix_operator=: operator= ^^^^^^^^^ .. code:: c++ template CrsMatrix& operator=(const CrsMatrix& mtx); Attempts to assign the underlying ``graph`` and ``values`` of the input matrix ``mtx`` to the matrix. .. _crsmatrix_numRows: numRows ^^^^^^^ .. code:: c++ KOKKOS_INLINE_FUNCTION ordinal_type numRows() const; Returns the number of rows in the matrix. .. _crsmatrix_numCols: numCols ^^^^^^^ .. code:: c++ KOKKOS_INLINE_FUNCTION ordinal_type numCols() const; Returns the number of columns in the matrix. .. _crsmatrix_setNumCols: setNumCols ^^^^^^^^^^ .. code:: c++ void setNumCols(ordinal_type c); Modify the number of columns in the sparse matrix. This invalidates any algorithm handles which previously used this matrix. .. _crsmatrix_numPointRows: numPointRows ^^^^^^^^^^^^ .. code:: c++ KOKKOS_INLINE_FUNCTION ordinal_type numPointRows() const; Equivalent to `numRows()`, since this is not a block matrix type. .. _crsmatrix_numPointCols: numPointCols ^^^^^^^^^^^^ .. code:: c++ KOKKOS_INLINE_FUNCTION ordinal_type numPointCols() const; Equivalent to `numCols()`, since this is not a block matrix type. .. _crsmatrix_nnz: nnz ^^^ .. code:: c++ KOKKOS_INLINE_FUNCTION size_type nnz() const; Returns the number of non-zero entries in the matrix. .. _crsmatrix_row: row ^^^ .. code:: c++ KOKKOS_INLINE_FUNCTION SparseRowView row(const ordinal_type i) const; Returns a view of the i-th row of the matrix as a :doc:`SparseRowView `. .. _crsmatrix_rowConst: rowConst ^^^^^^^^ .. code:: c++ KOKKOS_INLINE_FUNCTION SparseRowViewConst row(const ordinal_type i) const; Returns a view of the i-th row of the matrix as a :doc:`SparseRowViewConst `. Example ======= .. literalinclude:: ../../../../example/wiki/sparse/KokkosSparse_wiki_crsmatrix.cpp :language: c++