Kokkos Core Kernels Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Public Attributes | List of all members
Kokkos::GraphRowViewConst< GraphType > Class Template Reference

View of a row of a sparse graph. More...

#include <Kokkos_StaticCrsGraph.hpp>

Public Types

using ordinal_type = const typename GraphType::data_type
 The type of the column indices in the row. More...
 

Public Member Functions

KOKKOS_INLINE_FUNCTION GraphRowViewConst (ordinal_type *const colidx_in, const ordinal_type &stride, const ordinal_type &count)
 Constructor. More...
 
template<class OffsetType >
KOKKOS_INLINE_FUNCTION GraphRowViewConst (const typename GraphType::entries_type &colidx_in, const ordinal_type &stride, const ordinal_type &count, const OffsetType &idx, const std::enable_if_t< std::is_integral< OffsetType >::value, int > &=0)
 Constructor with offset into colidx array. More...
 
KOKKOS_INLINE_FUNCTION
ordinal_type
colidx (const ordinal_type &i) const
 (Const) reference to the column index of entry i in this row of the sparse matrix. More...
 
KOKKOS_INLINE_FUNCTION
ordinal_type
operator() (const ordinal_type &i) const
 An alias for colidx. More...
 

Public Attributes

const ordinal_type length
 Number of entries in the row. More...
 

Detailed Description

template<class GraphType>
class Kokkos::GraphRowViewConst< GraphType >

View of a row of a sparse graph.

Template Parameters
GraphTypeSparse graph type, such as (but not limited to) StaticCrsGraph.

This class provides a generic view of a row of a sparse graph. We intended this class to view a row of a StaticCrsGraph, but GraphType need not necessarily be CrsMatrix.

The row view is suited for computational kernels like sparse matrix-vector multiply, as well as for modifying entries in the sparse matrix. The view is always const as it does not allow graph modification.

Here is an example loop over the entries in the row:

using ordinal_type = typename GraphRowViewConst<MatrixType>::ordinal_type;
GraphRowView<GraphType> G_i = ...;
const ordinal_type numEntries = G_i.length;
for (ordinal_type k = 0; k < numEntries; ++k) {
ordinal_type j = G_i.colidx (k);
// ... do something with A_ij and j ...
}

GraphType must provide the data_type aliases. In addition, it must make sense to use GraphRowViewConst to view a row of GraphType. In particular, column indices of a row must be accessible using the entries resp. colidx arrays given to the constructor of this class, with a constant stride between successive entries. The stride is one for the compressed sparse row storage format (as is used by CrsMatrix), but may be greater than one for other sparse matrix storage formats (e.g., ELLPACK or jagged diagonal).

Definition at line 147 of file Kokkos_StaticCrsGraph.hpp.

Member Typedef Documentation

template<class GraphType>
using Kokkos::GraphRowViewConst< GraphType >::ordinal_type = const typename GraphType::data_type

The type of the column indices in the row.

Definition at line 149 of file Kokkos_StaticCrsGraph.hpp.

Constructor & Destructor Documentation

template<class GraphType>
KOKKOS_INLINE_FUNCTION Kokkos::GraphRowViewConst< GraphType >::GraphRowViewConst ( ordinal_type *const  colidx_in,
const ordinal_type stride,
const ordinal_type count 
)
inline

Constructor.

Parameters
values[in] Array of the row's values.
colidx[in] Array of the row's column indices.
stride[in] (Constant) stride between matrix entries in each of the above arrays.
count[in] Number of entries in the row.

Definition at line 172 of file Kokkos_StaticCrsGraph.hpp.

template<class GraphType>
template<class OffsetType >
KOKKOS_INLINE_FUNCTION Kokkos::GraphRowViewConst< GraphType >::GraphRowViewConst ( const typename GraphType::entries_type &  colidx_in,
const ordinal_type stride,
const ordinal_type count,
const OffsetType &  idx,
const std::enable_if_t< std::is_integral< OffsetType >::value, int > &  = 0 
)
inline

Constructor with offset into colidx array.

Parameters
colidx[in] Array of the row's column indices.
stride[in] (Constant) stride between matrix entries in each of the above arrays.
count[in] Number of entries in the row.
idx[in] Start offset into colidx array
Template Parameters
OffsetTypeThe type of idx (see above). Must be a built-in integer type. This may differ from ordinal_type. For example, the matrix may have dimensions that fit in int, but a number of entries that does not fit in int.

Definition at line 189 of file Kokkos_StaticCrsGraph.hpp.

Member Function Documentation

template<class GraphType>
KOKKOS_INLINE_FUNCTION ordinal_type& Kokkos::GraphRowViewConst< GraphType >::colidx ( const ordinal_type i) const
inline

(Const) reference to the column index of entry i in this row of the sparse matrix.

"Entry i" is not necessarily the entry with column index i, nor does i necessarily correspond to the (local) row index.

Definition at line 214 of file Kokkos_StaticCrsGraph.hpp.

template<class GraphType>
KOKKOS_INLINE_FUNCTION ordinal_type& Kokkos::GraphRowViewConst< GraphType >::operator() ( const ordinal_type i) const
inline

An alias for colidx.

Definition at line 220 of file Kokkos_StaticCrsGraph.hpp.

Member Data Documentation

template<class GraphType>
const ordinal_type Kokkos::GraphRowViewConst< GraphType >::length

Number of entries in the row.

This is a public const field rather than a public const method, in order to avoid possible overhead of a method call if the compiler is unable to inline that method call.

We assume that rows contain no duplicate entries (i.e., entries with the same column index). Thus, a row may have up to A.numCols() entries. This means that the correct type of 'length' is ordinal_type.

Definition at line 206 of file Kokkos_StaticCrsGraph.hpp.


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