Gyselalib++
 
Loading...
Searching...
No Matches
matrix.hpp
1#pragma once
2
3#include <iosfwd>
4#include <memory>
5
6#include "sll/view.hpp"
7
8class Matrix
9{
10public:
11 Matrix(int mat_size) : n(mat_size) {}
12 virtual ~Matrix() = default;
13 virtual double get_element(int i, int j) const = 0;
14 virtual void set_element(int i, int j, double aij) = 0;
15 virtual void factorize();
16 virtual DSpan1D solve_inplace(DSpan1D b) const;
17 virtual DSpan1D solve_transpose_inplace(DSpan1D b) const;
18 virtual DSpan2D solve_multiple_inplace(DSpan2D bx) const;
19 int get_size() const
20 {
21 return n;
22 }
23 static std::unique_ptr<Matrix> make_new_banded(int n, int kl, int ku, bool pds);
24 static std::unique_ptr<Matrix> make_new_periodic_banded(int n, int kl, int ku, bool pds);
25 static std::unique_ptr<Matrix> make_new_block_with_banded_region(
26 int n,
27 int kl,
28 int ku,
29 bool pds,
30 int block1_size,
31 int block2_size = 0);
32
33protected:
34 virtual int factorize_method() = 0;
35 virtual int solve_inplace_method(double* b, char transpose, int n_equations) const = 0;
36 int const n; // matrix size
37};
38
39std::ostream& operator<<(std::ostream& o, Matrix const& m);
Definition matrix.hpp:9