suanPan
Preconditioner.hpp
Go to the documentation of this file.
1/*******************************************************************************
2 * Copyright (C) 2017-2024 Theodore Chang
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 ******************************************************************************/
29#ifndef PRECONDITIONER_HPP
30#define PRECONDITIONER_HPP
31
32#include <suanPan.h>
33
34template<sp_d data_t> class Preconditioner {
35public:
36 Preconditioner() = default;
37 Preconditioner(const Preconditioner&) = default;
38 Preconditioner(Preconditioner&&) noexcept = default;
39 Preconditioner& operator=(const Preconditioner&) = default;
40 Preconditioner& operator=(Preconditioner&&) noexcept = default;
41 virtual ~Preconditioner() = default;
42
43 virtual int init() { return SUANPAN_SUCCESS; }
44
45 [[nodiscard]] virtual Col<data_t> apply(const Col<data_t>&) = 0;
46};
47
48template<sp_d data_t> class UnityPreconditioner final : public Preconditioner<data_t> {
49public:
50 [[nodiscard]] Col<data_t> apply(const Col<data_t>&) override;
51};
52
53template<sp_d data_t> Col<data_t> UnityPreconditioner<data_t>::apply(const Col<data_t>& in) { return in; }
54
55#endif
56
A Preconditioner class.
Definition: Preconditioner.hpp:34
Preconditioner()=default
virtual int init()
Definition: Preconditioner.hpp:43
Preconditioner(const Preconditioner &)=default
virtual Col< data_t > apply(const Col< data_t > &)=0
Preconditioner(Preconditioner &&) noexcept=default
Definition: Preconditioner.hpp:48
Col< data_t > apply(const Col< data_t > &) override
Definition: Preconditioner.hpp:53
constexpr auto SUANPAN_SUCCESS
Definition: suanPan.h:172