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