sfof
band_matrix.hpp
Go to the documentation of this file.
1 /*
2  * @file spline.hpp
3  *
4  * @author Tino Kluge, Samuel Farrens
5  */
6 
7 #ifndef BAND_MATRIX_H
8 #define BAND_MATRIX_H
9 
18 #include <cstdio>
19 #include <cassert>
20 #include <vector>
21 #include <algorithm>
22 
23 // band matrix solver
24 class Band_Matrix {
25 private:
26  std::vector< std::vector<double> > m_upper; // upper band
27  std::vector< std::vector<double> > m_lower; // lower band
28 public:
29  Band_Matrix() {}; // constructor
30  Band_Matrix(int dim, int n_u, int n_l) {
31  resize(dim, n_u, n_l);
32  }
33  ~Band_Matrix() {}; // destructor
34  void resize(int dim, int n_u, int n_l); // init with dim,n_u,n_l
35  int dim() const; // matrix dimension
36  int num_upper() const {
37  return m_upper.size() - 1;
38  }
39  int num_lower() const {
40  return m_lower.size() - 1;
41  }
42  // access operator
43  double & operator () (int i, int j); // write
44  double operator () (int i, int j) const; // read
45  // we can store an additional diogonal (in m_lower)
46  double & saved_diag(int i);
47  double saved_diag(int i) const;
48  void lu_decompose();
49  std::vector<double> r_solve(const std::vector<double>& b) const;
50  std::vector<double> l_solve(const std::vector<double>& b) const;
51  std::vector<double> lu_solve(const std::vector<double>& b,
52  bool is_lu_decomposed=false);
53 };
54 
55 #endif // BAND_MATRIX_H
Band_Matrix::resize
void resize(int dim, int n_u, int n_l)
Definition: band_matrix.cpp:5
Band_Matrix::operator()
double & operator()(int i, int j)
Definition: band_matrix.cpp:29
Band_Matrix::Band_Matrix
Band_Matrix(int dim, int n_u, int n_l)
Definition: band_matrix.hpp:30
Band_Matrix
Band Martix solver for cubic spline interpolation.
Definition: band_matrix.hpp:24
Band_Matrix::dim
int dim() const
Definition: band_matrix.cpp:19
Band_Matrix::lu_decompose
void lu_decompose()
Definition: band_matrix.cpp:59
Band_Matrix::m_upper
std::vector< std::vector< double > > m_upper
Definition: band_matrix.hpp:26
Band_Matrix::~Band_Matrix
~Band_Matrix()
Definition: band_matrix.hpp:33
Band_Matrix::m_lower
std::vector< std::vector< double > > m_lower
Definition: band_matrix.hpp:27
Band_Matrix::lu_solve
std::vector< double > lu_solve(const std::vector< double > &b, bool is_lu_decomposed=false)
Definition: band_matrix.cpp:123
Band_Matrix::saved_diag
double & saved_diag(int i)
Definition: band_matrix.cpp:53
Band_Matrix::r_solve
std::vector< double > r_solve(const std::vector< double > &b) const
Definition: band_matrix.cpp:109
Band_Matrix::num_lower
int num_lower() const
Definition: band_matrix.hpp:39
Band_Matrix::num_upper
int num_upper() const
Definition: band_matrix.hpp:36
Band_Matrix::Band_Matrix
Band_Matrix()
Definition: band_matrix.hpp:29
Band_Matrix::l_solve
std::vector< double > l_solve(const std::vector< double > &b) const
Definition: band_matrix.cpp:94