Lagrangian Particle Code for The Simulation of 2D/3D Fluid Dynamics
 All Classes Files Functions Variables Typedefs Friends Pages
ls_solver.h
Go to the documentation of this file.
1 
20 #ifndef __LS_SOLVER_H__
21 #define __LS_SOLVER_H__
22 
23 #include <cstddef>
24 #include <vector>
25 
26 
27 
45 class LSSolver {
46 public:
54  virtual ~LSSolver() {}
55 
66  virtual int solve(double* result, double* b) = 0;
67 
68 protected:
69  std::size_t m_iNumRow;
70  std::size_t m_iNumCol;
71  double *m_vA;
72  double *m_vb;
73 };
74 
75 
76 
77 
78 
79 
97 class QRSolver : public LSSolver {
98 public:
110  QRSolver(std::size_t numRow, std::size_t numCol, double *A, double limitR=1e-3) {
111  m_iNumRow = numRow;
112  m_iNumCol = numCol;
113  m_vA = A;
114  isDecomposed = false; // The matrix A is not decomposed into QR at initialization
115  m_fLimitR = limitR;
116  }
117 
141  virtual int solve(double* result, double* b);
142 
143 private:
144  bool isDecomposed;
145  double m_fLimitR;
146  std::vector<int> m_vJPVT;
147  std::vector<double> m_vTAU;
148 };
149 
150 
151 #endif // __LS_SOLVER_H__
std::size_t m_iNumRow
The number of rows in matrix A.
Definition: ls_solver.h:69
An abstract class for the family of solvers for the least squares problem.
Definition: ls_solver.h:45
double * m_vb
The vector b (the right-hand-side)
Definition: ls_solver.h:72
std::size_t m_iNumCol
The number of columns in matrix A.
Definition: ls_solver.h:70
QRSolver(std::size_t numRow, std::size_t numCol, double *A, double limitR=1e-3)
Constructor.
Definition: ls_solver.h:110
virtual int solve(double *result, double *b)=0
Solves the least squares problem Ax = b.
A class which solves the least squares problem by the QR decomposition method.
Definition: ls_solver.h:97
virtual int solve(double *result, double *b)
returns 0 if success and result will be non-empty returns k<0 if the kth argument is illegal...
Definition: ls_solver.cpp:33
double * m_vA
The matrix A.
Definition: ls_solver.h:71
virtual ~LSSolver()
Destructor.
Definition: ls_solver.h:54