24#ifndef MORPHEUS_DIA_KOKKOS_MATRIXOPERATIONS_IMPL_HPP
25#define MORPHEUS_DIA_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_dia_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 value_array_type =
typename Matrix::value_array_type::value_array_type;
46 using index_array_type =
typename Matrix::index_array_type::value_array_type;
47 using array_type =
typename Vector::value_array_type;
48 using size_type =
typename Matrix::size_type;
49 using index_type =
typename Matrix::index_type;
50 using value_type =
typename Matrix::value_type;
52 Kokkos::RangePolicy<Kokkos::IndexType<size_type>, execution_space>;
54 value_array_type values = A.values().view();
55 index_array_type diagonal_offsets = A.diagonal_offsets().view();
56 const array_type diagonal_view = diagonal.const_view();
58 size_type ndiag = A.values().ncols(), ncols = A.ncols();
60 range_policy policy(0, A.nrows());
63 policy, KOKKOS_LAMBDA(
const size_type row) {
64 for (size_type n = 0; n < ndiag; n++) {
65 const index_type col = row + diagonal_offsets[n];
67 if ((col >= 0 && col < (index_type)ncols) &&
68 (col == (index_type)row)) {
70 (values(row, n) == value_type(0)) ? 0 : diagonal_view[col];
76template <
typename ExecSpace,
typename Matrix,
typename Vector>
78 Matrix&,
const Vector&,
79 typename std::enable_if_t<
80 Morpheus::is_dia_matrix_format_container_v<Matrix> &&
81 Morpheus::is_dense_vector_format_container_v<Vector> &&
82 Morpheus::has_generic_backend_v<ExecSpace> &&
83 Morpheus::has_access_v<ExecSpace, Matrix, Vector>>* =
nullptr) {
87template <
typename ExecSpace,
typename Matrix,
typename SizeType,
89void set_value(Matrix&, SizeType, SizeType, ValueType,
90 typename std::enable_if_t<
91 Morpheus::is_dia_matrix_format_container_v<Matrix> &&
92 Morpheus::has_generic_backend_v<ExecSpace> &&
93 Morpheus::has_access_v<ExecSpace, Matrix>>* =
nullptr) {
97template <
typename ExecSpace,
typename Matrix,
typename IndexVector,
100 Matrix&,
typename IndexVector::value_type,
const IndexVector,
101 typename IndexVector::value_type,
const IndexVector,
const ValueVector,
102 typename std::enable_if_t<
103 Morpheus::is_dia_matrix_format_container_v<Matrix> &&
104 Morpheus::is_dense_vector_format_container_v<IndexVector> &&
105 Morpheus::is_dense_vector_format_container_v<ValueVector> &&
106 Morpheus::has_generic_backend_v<ExecSpace> &&
107 Morpheus::has_access_v<ExecSpace, Matrix, IndexVector, ValueVector>>* =
112template <
typename ExecSpace,
typename Matrix,
typename TransposeMatrix>
114 const Matrix&, TransposeMatrix&,
115 typename std::enable_if_t<
116 Morpheus::is_dia_matrix_format_container_v<Matrix> &&
117 Morpheus::is_dia_matrix_format_container_v<TransposeMatrix> &&
118 Morpheus::has_generic_backend_v<ExecSpace> &&
119 Morpheus::has_access_v<ExecSpace, Matrix, TransposeMatrix>>* =
Definition: Morpheus_Exceptions.hpp:43
Generic Morpheus interfaces.
Definition: dummy.cpp:24