Morpheus 1.0.0
Dynamic matrix type and algorithms for sparse matrices
Loading...
Searching...
No Matches
Coo/OpenMP/Morpheus_MatrixOperations_Impl.hpp
1
24#ifndef MORPHEUS_COO_OPENMP_MATRIXOPERATIONS_IMPL_HPP
25#define MORPHEUS_COO_OPENMP_MATRIXOPERATIONS_IMPL_HPP
26
27#include <Morpheus_Macros.hpp>
28#if defined(MORPHEUS_ENABLE_OPENMP)
29
30#include <Morpheus_Exceptions.hpp>
31#include <Morpheus_SpaceTraits.hpp>
32#include <Morpheus_FormatTraits.hpp>
33#include <Morpheus_FormatTags.hpp>
34#include <Morpheus_Spaces.hpp>
35
36namespace Morpheus {
37namespace Impl {
38
39template <typename ExecSpace, typename Matrix, typename Vector>
40void update_diagonal(
41 Matrix& A, const Vector& diagonal,
42 typename std::enable_if_t<
43 Morpheus::is_coo_matrix_format_container_v<Matrix> &&
44 Morpheus::is_dense_vector_format_container_v<Vector> &&
45 Morpheus::has_custom_backend_v<ExecSpace> &&
46 Morpheus::has_openmp_execution_space_v<ExecSpace> &&
47 Morpheus::has_access_v<ExecSpace, Matrix, Vector>>* = nullptr) {
48 using size_type = typename Matrix::size_type;
49
50// Note: Assumes only a single entry exists for every diagonal element.
51// i.e a single threads will update a particular non-zero on the diagonal
52#pragma omp parallel for
53 for (size_type n = 0; n < A.nnnz(); n++) {
54 if (A.row_indices(n) == A.column_indices(n)) {
55 A.values(n) = diagonal[A.column_indices(n)];
56 }
57 }
58}
59
60template <typename ExecSpace, typename Matrix, typename Vector>
61void get_diagonal(
62 Matrix& A, const Vector& diagonal,
63 typename std::enable_if_t<
64 Morpheus::is_coo_matrix_format_container_v<Matrix> &&
65 Morpheus::is_dense_vector_format_container_v<Vector> &&
66 Morpheus::has_custom_backend_v<ExecSpace> &&
67 Morpheus::has_openmp_execution_space_v<ExecSpace> &&
68 Morpheus::has_access_v<ExecSpace, Matrix, Vector>>* = nullptr) {
69 throw Morpheus::NotImplementedException("get_diagonal not implemented yet");
70}
71
72template <typename ExecSpace, typename Matrix, typename SizeType,
73 typename ValueType>
74void set_value(Matrix&, SizeType, SizeType, ValueType,
75 typename std::enable_if_t<
76 Morpheus::is_coo_matrix_format_container_v<Matrix> &&
77 Morpheus::has_custom_backend_v<ExecSpace> &&
78 Morpheus::has_openmp_execution_space_v<ExecSpace> &&
79 Morpheus::has_access_v<ExecSpace, Matrix>>* = nullptr) {
80 throw Morpheus::NotImplementedException("set_value not implemented yet");
81}
82
83template <typename ExecSpace, typename Matrix, typename IndexVector,
84 typename ValueVector>
85void set_values(
86 Matrix&, typename IndexVector::value_type, const IndexVector,
87 typename IndexVector::value_type, const IndexVector, const ValueVector,
88 typename std::enable_if_t<
89 Morpheus::is_coo_matrix_format_container_v<Matrix> &&
90 Morpheus::is_dense_vector_format_container_v<IndexVector> &&
91 Morpheus::is_dense_vector_format_container_v<ValueVector> &&
92 Morpheus::has_custom_backend_v<ExecSpace> &&
93 Morpheus::has_openmp_execution_space_v<ExecSpace> &&
94 Morpheus::has_access_v<ExecSpace, Matrix, IndexVector, ValueVector>>* =
95 nullptr) {
96 throw Morpheus::NotImplementedException("set_values not implemented yet");
97}
98
99template <typename ExecSpace, typename Matrix, typename TransposeMatrix>
100void transpose(
101 const Matrix&, TransposeMatrix&,
102 typename std::enable_if_t<
103 Morpheus::is_coo_matrix_format_container_v<Matrix> &&
104 Morpheus::is_coo_matrix_format_container_v<TransposeMatrix> &&
105 Morpheus::has_custom_backend_v<ExecSpace> &&
106 Morpheus::has_openmp_execution_space_v<ExecSpace> &&
107 Morpheus::has_access_v<ExecSpace, Matrix, TransposeMatrix>>* =
108 nullptr) {
109 throw Morpheus::NotImplementedException("transpose not implemented yet");
110}
111
112} // namespace Impl
113} // namespace Morpheus
114
115#endif // MORPHEUS_ENABLE_OPENMP
116#endif // MORPHEUS_COO_OPENMP_MATRIXOPERATIONS_IMPL_HPP
Definition: Morpheus_Exceptions.hpp:43
Generic Morpheus interfaces.
Definition: dummy.cpp:24