Morpheus 1.0.0
Dynamic matrix type and algorithms for sparse matrices
Loading...
Searching...
No Matches
Coo/Serial/Morpheus_MatrixOperations_Impl.hpp
1
24#ifndef MORPHEUS_COO_SERIAL_MATRIXOPERATIONS_IMPL_HPP
25#define MORPHEUS_COO_SERIAL_MATRIXOPERATIONS_IMPL_HPP
26
27#include <Morpheus_Macros.hpp>
28#if defined(MORPHEUS_ENABLE_SERIAL)
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_serial_execution_space_v<ExecSpace> &&
47 Morpheus::has_access_v<ExecSpace, Matrix, Vector>>* = nullptr) {
48 using size_type = typename Matrix::size_type;
49
50 for (size_type n = 0; n < A.nnnz(); n++) {
51 if (A.row_indices(n) == A.column_indices(n)) {
52 A.values(n) = diagonal[A.column_indices(n)];
53 }
54 }
55}
56
57template <typename ExecSpace, typename Matrix, typename Vector>
58void get_diagonal(
59 Matrix&, const Vector&,
60 typename std::enable_if_t<
61 Morpheus::is_coo_matrix_format_container_v<Matrix> &&
62 Morpheus::is_dense_vector_format_container_v<Vector> &&
63 Morpheus::has_custom_backend_v<ExecSpace> &&
64 Morpheus::has_serial_execution_space_v<ExecSpace> &&
65 Morpheus::has_access_v<ExecSpace, Matrix, Vector>>* = nullptr) {
66 throw Morpheus::NotImplementedException("get_diagonal not implemented yet");
67}
68
69template <typename ExecSpace, typename Matrix, typename SizeType,
70 typename ValueType>
71void set_value(Matrix&, SizeType, SizeType, ValueType,
72 typename std::enable_if_t<
73 Morpheus::is_coo_matrix_format_container_v<Matrix> &&
74 Morpheus::has_custom_backend_v<ExecSpace> &&
75 Morpheus::has_serial_execution_space_v<ExecSpace> &&
76 Morpheus::has_access_v<ExecSpace, Matrix>>* = nullptr) {
77 throw Morpheus::NotImplementedException("set_value not implemented yet");
78}
79
80template <typename ExecSpace, typename Matrix, typename IndexVector,
81 typename ValueVector>
82void set_values(
83 Matrix&, typename IndexVector::value_type, const IndexVector,
84 typename IndexVector::value_type, const IndexVector, const ValueVector,
85 typename std::enable_if_t<
86 Morpheus::is_coo_matrix_format_container_v<Matrix> &&
87 Morpheus::is_dense_vector_format_container_v<IndexVector> &&
88 Morpheus::is_dense_vector_format_container_v<ValueVector> &&
89 Morpheus::has_custom_backend_v<ExecSpace> &&
90 Morpheus::has_serial_execution_space_v<ExecSpace> &&
91 Morpheus::has_access_v<ExecSpace, Matrix, IndexVector, ValueVector>>* =
92 nullptr) {
93 throw Morpheus::NotImplementedException("set_values not implemented yet");
94}
95
96template <typename ExecSpace, typename Matrix, typename TransposeMatrix>
97void transpose(
98 const Matrix&, TransposeMatrix&,
99 typename std::enable_if_t<
100 Morpheus::is_coo_matrix_format_container_v<Matrix> &&
101 Morpheus::is_coo_matrix_format_container_v<TransposeMatrix> &&
102 Morpheus::has_custom_backend_v<ExecSpace> &&
103 Morpheus::has_serial_execution_space_v<ExecSpace> &&
104 Morpheus::has_access_v<ExecSpace, Matrix, TransposeMatrix>>* =
105 nullptr) {
106 throw Morpheus::NotImplementedException("transpose not implemented yet");
107}
108
109} // namespace Impl
110} // namespace Morpheus
111
112#endif // MORPHEUS_ENABLE_SERIAL
113#endif // MORPHEUS_COO_SERIAL_MATRIXOPERATIONS_IMPL_HPP
Definition: Morpheus_Exceptions.hpp:43
Generic Morpheus interfaces.
Definition: dummy.cpp:24