Morpheus 1.0.0
Dynamic matrix type and algorithms for sparse matrices
Loading...
Searching...
No Matches
Csr/OpenMP/Morpheus_MatrixOperations_Impl.hpp
1
24#ifndef MORPHEUS_CSR_OPENMP_MATRIXOPERATIONS_IMPL_HPP
25#define MORPHEUS_CSR_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_csr_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 using index_type = typename Matrix::index_type;
50
51#pragma omp parallel for
52 for (size_type i = 0; i < A.nrows(); ++i) {
53 for (index_type jj = A.row_offsets(i); jj < A.row_offsets(i + 1); jj++) {
54 if (A.column_indices(jj) == (index_type)i) {
55 A.values(jj) = diagonal[i];
56 break;
57 }
58 }
59 }
60}
61
62template <typename ExecSpace, typename Matrix, typename Vector>
63void get_diagonal(
64 Matrix&, const Vector&,
65 typename std::enable_if_t<
66 Morpheus::is_csr_matrix_format_container_v<Matrix> &&
67 Morpheus::is_dense_vector_format_container_v<Vector> &&
68 Morpheus::has_custom_backend_v<ExecSpace> &&
69 Morpheus::has_openmp_execution_space_v<ExecSpace> &&
70 Morpheus::has_access_v<ExecSpace, Matrix, Vector>>* = nullptr) {
71 throw Morpheus::NotImplementedException("get_diagonal not implemented yet");
72}
73
74template <typename ExecSpace, typename Matrix, typename SizeType,
75 typename ValueType>
76void set_value(Matrix&, SizeType, SizeType, ValueType,
77 typename std::enable_if_t<
78 Morpheus::is_csr_matrix_format_container_v<Matrix> &&
79 Morpheus::has_custom_backend_v<ExecSpace> &&
80 Morpheus::has_openmp_execution_space_v<ExecSpace> &&
81 Morpheus::has_access_v<ExecSpace, Matrix>>* = nullptr) {
82 throw Morpheus::NotImplementedException("set_value not implemented yet");
83}
84
85template <typename ExecSpace, typename Matrix, typename IndexVector,
86 typename ValueVector>
87void set_values(
88 Matrix&, typename IndexVector::value_type, const IndexVector,
89 typename IndexVector::value_type, const IndexVector, const ValueVector,
90 typename std::enable_if_t<
91 Morpheus::is_csr_matrix_format_container_v<Matrix> &&
92 Morpheus::is_dense_vector_format_container_v<IndexVector> &&
93 Morpheus::is_dense_vector_format_container_v<ValueVector> &&
94 Morpheus::has_custom_backend_v<ExecSpace> &&
95 Morpheus::has_openmp_execution_space_v<ExecSpace> &&
96 Morpheus::has_access_v<ExecSpace, Matrix, IndexVector, ValueVector>>* =
97 nullptr) {
98 throw Morpheus::NotImplementedException("set_values not implemented yet");
99}
100
101template <typename ExecSpace, typename Matrix, typename TransposeMatrix>
102void transpose(
103 const Matrix&, TransposeMatrix&,
104 typename std::enable_if_t<
105 Morpheus::is_csr_matrix_format_container_v<Matrix> &&
106 Morpheus::is_csr_matrix_format_container_v<TransposeMatrix> &&
107 Morpheus::has_custom_backend_v<ExecSpace> &&
108 Morpheus::has_openmp_execution_space_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_ENABLE_OPENMP
118#endif // MORPHEUS_CSR_OPENMP_MATRIXOPERATIONS_IMPL_HPP
Definition: Morpheus_Exceptions.hpp:43
Generic Morpheus interfaces.
Definition: dummy.cpp:24