24#ifndef MORPHEUS_CSR_KOKKOS_MATRIXOPERATIONS_IMPL_HPP
25#define MORPHEUS_CSR_KOKKOS_MATRIXOPERATIONS_IMPL_HPP
27#include <Morpheus_Exceptions.hpp>
28#include <Morpheus_SpaceTraits.hpp>
29#include <Morpheus_FormatTraits.hpp>
30#include <Morpheus_FormatTags.hpp>
31#include <Morpheus_Spaces.hpp>
36template <
typename ExecSpace,
typename Matrix,
typename Vector>
38 Matrix& A,
const Vector& diagonal,
39 typename std::enable_if_t<
40 Morpheus::is_csr_matrix_format_container_v<Matrix> &&
41 Morpheus::is_dense_vector_format_container_v<Vector> &&
42 Morpheus::has_generic_backend_v<ExecSpace> &&
43 Morpheus::has_access_v<ExecSpace, Matrix, Vector>>* =
nullptr) {
44 using execution_space =
typename ExecSpace::execution_space;
45 using size_type =
typename Matrix::size_type;
46 using index_type =
typename Matrix::index_type;
47 using value_array =
typename Matrix::value_array_type::value_array_type;
48 using index_array =
typename Matrix::index_array_type::value_array_type;
51 Kokkos::RangePolicy<Kokkos::IndexType<size_type>, execution_space>;
53 value_array values = A.values().view();
54 index_array column_indices = A.column_indices().view();
55 index_array row_offsets = A.row_offsets().view();
56 const value_array diagonal_view = diagonal.const_view();
58 range_policy policy(0, A.nrows());
61 policy, KOKKOS_LAMBDA(
const size_type i) {
62 for (index_type jj = row_offsets[i]; jj < row_offsets[i + 1]; jj++) {
63 if (column_indices[jj] == (index_type)i) {
64 values[jj] = diagonal_view[i];
71template <
typename ExecSpace,
typename Matrix,
typename Vector>
73 Matrix&,
const Vector&,
74 typename std::enable_if_t<
75 Morpheus::is_csr_matrix_format_container_v<Matrix> &&
76 Morpheus::is_dense_vector_format_container_v<Vector> &&
77 Morpheus::has_generic_backend_v<ExecSpace> &&
78 Morpheus::has_access_v<ExecSpace, Matrix, Vector>>* =
nullptr) {
82template <
typename ExecSpace,
typename Matrix,
typename SizeType,
84void set_value(Matrix&, SizeType, SizeType, ValueType,
85 typename std::enable_if_t<
86 Morpheus::is_csr_matrix_format_container_v<Matrix> &&
87 Morpheus::has_generic_backend_v<ExecSpace> &&
88 Morpheus::has_access_v<ExecSpace, Matrix>>* =
nullptr) {
92template <
typename ExecSpace,
typename Matrix,
typename IndexVector,
95 Matrix&,
typename IndexVector::value_type,
const IndexVector,
96 typename IndexVector::value_type,
const IndexVector,
const ValueVector,
97 typename std::enable_if_t<
98 Morpheus::is_csr_matrix_format_container_v<Matrix> &&
99 Morpheus::is_dense_vector_format_container_v<IndexVector> &&
100 Morpheus::is_dense_vector_format_container_v<ValueVector> &&
101 Morpheus::has_generic_backend_v<ExecSpace> &&
102 Morpheus::has_access_v<ExecSpace, Matrix, IndexVector, ValueVector>>* =
107template <
typename ExecSpace,
typename Matrix,
typename TransposeMatrix>
109 const Matrix&, TransposeMatrix&,
110 typename std::enable_if_t<
111 Morpheus::is_csr_matrix_format_container_v<Matrix> &&
112 Morpheus::is_csr_matrix_format_container_v<TransposeMatrix> &&
113 Morpheus::has_generic_backend_v<ExecSpace> &&
114 Morpheus::has_access_v<ExecSpace, Matrix, TransposeMatrix>>* =
Definition: Morpheus_Exceptions.hpp:43
Generic Morpheus interfaces.
Definition: dummy.cpp:24