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