Morpheus 1.0.0
Dynamic matrix type and algorithms for sparse matrices
Loading...
Searching...
No Matches
Coo/Kokkos/Morpheus_MatrixOperations_Impl.hpp
1
24#ifndef MORPHEUS_COO_KOKKOS_MATRIXOPERATIONS_IMPL_HPP
25#define MORPHEUS_COO_KOKKOS_MATRIXOPERATIONS_IMPL_HPP
26
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>
32
33namespace Morpheus {
34namespace Impl {
35
36template <typename ExecSpace, typename Matrix, typename Vector>
37void update_diagonal(
38 Matrix& A, const Vector& diagonal,
39 typename std::enable_if_t<
40 Morpheus::is_coo_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 value_array = typename Matrix::value_array_type::value_array_type;
47 using index_array = typename Matrix::index_array_type::value_array_type;
48
49 using range_policy =
50 Kokkos::RangePolicy<Kokkos::IndexType<size_type>, execution_space>;
51
52 value_array values = A.values().view();
53 index_array column_indices = A.column_indices().view();
54 index_array row_indices = A.row_indices().view();
55 const value_array diagonal_view = diagonal.const_view();
56
57 range_policy policy(0, A.nnnz());
58
59 Kokkos::parallel_for(
60 policy, KOKKOS_LAMBDA(const size_type i) {
61 if (row_indices[i] == column_indices[i])
62 values[i] = diagonal_view[column_indices[i]];
63 });
64}
65
66template <typename ExecSpace, typename Matrix, typename Vector>
67void get_diagonal(
68 Matrix&, const Vector&,
69 typename std::enable_if_t<
70 Morpheus::is_coo_matrix_format_container_v<Matrix> &&
71 Morpheus::is_dense_vector_format_container_v<Vector> &&
72 Morpheus::has_generic_backend_v<ExecSpace> &&
73 Morpheus::has_access_v<ExecSpace, Matrix, Vector>>* = nullptr) {
74 throw Morpheus::NotImplementedException("get_diagonal not implemented yet");
75}
76
77template <typename ExecSpace, typename Matrix, typename SizeType,
78 typename ValueType>
79void set_value(Matrix&, SizeType, SizeType, ValueType,
80 typename std::enable_if_t<
81 Morpheus::is_coo_matrix_format_container_v<Matrix> &&
82 Morpheus::has_generic_backend_v<ExecSpace> &&
83 Morpheus::has_access_v<ExecSpace, Matrix>>* = nullptr) {
84 throw Morpheus::NotImplementedException("set_value not implemented yet");
85}
86
87template <typename ExecSpace, typename Matrix, typename IndexVector,
88 typename ValueVector>
89void set_values(
90 Matrix&, typename IndexVector::value_type, const IndexVector,
91 typename IndexVector::value_type, const IndexVector, const ValueVector,
92 typename std::enable_if_t<
93 Morpheus::is_coo_matrix_format_container_v<Matrix> &&
94 Morpheus::is_dense_vector_format_container_v<IndexVector> &&
95 Morpheus::is_dense_vector_format_container_v<ValueVector> &&
96 Morpheus::has_generic_backend_v<ExecSpace> &&
97 Morpheus::has_access_v<ExecSpace, Matrix, IndexVector, ValueVector>>* =
98 nullptr) {
99 throw Morpheus::NotImplementedException("set_values not implemented yet");
100}
101
102template <typename ExecSpace, typename Matrix, typename TransposeMatrix>
103void transpose(
104 const Matrix&, TransposeMatrix&,
105 typename std::enable_if_t<
106 Morpheus::is_coo_matrix_format_container_v<Matrix> &&
107 Morpheus::is_coo_matrix_format_container_v<TransposeMatrix> &&
108 Morpheus::has_generic_backend_v<ExecSpace> &&
109 Morpheus::has_access_v<ExecSpace, Matrix, TransposeMatrix>>* =
110 nullptr) {
111 throw Morpheus::NotImplementedException("transpose not implemented yet");
112}
113
114} // namespace Impl
115} // namespace Morpheus
116
117#endif // MORPHEUS_COO_KOKKOS_MATRIXOPERATIONS_IMPL_HPP
Definition: Morpheus_Exceptions.hpp:43
Generic Morpheus interfaces.
Definition: dummy.cpp:24