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::SparseRowView< MatrixType > Class Template Reference

View of a row of a sparse matrix. More...

#include <Kokkos_CrsMatrix.hpp>

Public Types

typedef MatrixType::value_type value_type
 The type of the values in the row. More...
 
typedef MatrixType::ordinal_type ordinal_type
 The type of the column indices in the row. More...
 

Public Member Functions

KOKKOS_INLINE_FUNCTION SparseRowView (value_type *const values, ordinal_type *const colidx__, const int stride, const int count)
 Constructor. More...
 
KOKKOS_INLINE_FUNCTION SparseRowView (const typename MatrixType::values_type &values, const typename MatrixType::index_type &colidx__, const int &stride, const int &count, const int &idx)
 Constructor. More...
 
KOKKOS_INLINE_FUNCTION value_typevalue (const int &i) const
 Reference to the value of entry i in this row of the sparse matrix. More...
 
KOKKOS_INLINE_FUNCTION
ordinal_type
colidx (const int &i) const
 Reference to the column index of entry i in this row of the sparse matrix. More...
 

Public Attributes

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

Detailed Description

template<class MatrixType>
class Kokkos::SparseRowView< MatrixType >

View of a row of a sparse matrix.

Template Parameters
MatrixTypeSparse matrix type, such as (but not limited to) CrsMatrix.

This class provides a generic view of a row of a sparse matrix. We intended this class to view a row of a CrsMatrix, but MatrixType 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. Whether the view is const or not, depends on whether MatrixType is a const or nonconst view of the matrix. If you always want a const view, use SparseRowViewConst (see below).

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

typedef typename SparseRowView<MatrixType>::value_type value_type;
typedef typename SparseRowView<MatrixType>::ordinal_type ordinal_type;
SparseRowView<MatrixType> A_i = ...;
const int numEntries = A_i.length;
for (int k = 0; k < numEntries; ++k) {
value_type A_ij = A_i.value (k);
ordinal_type j = A_i.colidx (k);
// ... do something with A_ij and j ...
}

MatrixType must provide the value_type and ordinal_type typedefs. In addition, it must make sense to use SparseRowView to view a row of MatrixType. In particular, the values and column indices of a row must be accessible using the values 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 114 of file Kokkos_CrsMatrix.hpp.

Member Typedef Documentation

template<class MatrixType>
typedef MatrixType::value_type Kokkos::SparseRowView< MatrixType >::value_type

The type of the values in the row.

Definition at line 116 of file Kokkos_CrsMatrix.hpp.

template<class MatrixType>
typedef MatrixType::ordinal_type Kokkos::SparseRowView< MatrixType >::ordinal_type

The type of the column indices in the row.

Definition at line 118 of file Kokkos_CrsMatrix.hpp.

Constructor & Destructor Documentation

template<class MatrixType>
KOKKOS_INLINE_FUNCTION Kokkos::SparseRowView< MatrixType >::SparseRowView ( value_type *const  values,
ordinal_type *const  colidx__,
const int  stride,
const int  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 137 of file Kokkos_CrsMatrix.hpp.

template<class MatrixType>
KOKKOS_INLINE_FUNCTION Kokkos::SparseRowView< MatrixType >::SparseRowView ( const typename MatrixType::values_type &  values,
const typename MatrixType::index_type &  colidx__,
const int &  stride,
const int &  count,
const int &  idx 
)
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 151 of file Kokkos_CrsMatrix.hpp.

Member Function Documentation

template<class MatrixType>
KOKKOS_INLINE_FUNCTION value_type& Kokkos::SparseRowView< MatrixType >::value ( const int &  i) const
inline

Reference to the value 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 171 of file Kokkos_CrsMatrix.hpp.

template<class MatrixType>
KOKKOS_INLINE_FUNCTION ordinal_type& Kokkos::SparseRowView< MatrixType >::colidx ( const int &  i) const
inline

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 180 of file Kokkos_CrsMatrix.hpp.

Member Data Documentation

template<class MatrixType>
const int Kokkos::SparseRowView< MatrixType >::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.

Definition at line 164 of file Kokkos_CrsMatrix.hpp.


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