Chombo + EB  3.2
LSquares.H
Go to the documentation of this file.
1 #ifdef CH_LANG_CC
2 /*
3  * _______ __
4  * / ___/ / ___ __ _ / / ___
5  * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6  * \___/_//_/\___/_/_/_/_.__/\___/
7  * Please refer to Copyright.txt, in Chombo's root directory.
8  */
9 #endif
10 
11 #ifndef _LSQUARES_H_
12 #define _LSQUARES_H_
13 
14 #include "Vector.H"
15 #include "REAL.H"
16 #include "RealVect.H"
17 #include "NamespaceHeader.H"
18 ///
19 /**
20  This class solves least squares problems
21  */
22 class LSquares
23 {
24 public:
25  void LeastSquares(Real** A,
26  Vector<Real>&x,
27  const Vector<Real>&rhs);
28 
29  /// gaussian elimination with partial pivoting
30  int gaussElim(Real**A,
31  Vector<Real>& rhs);
32 
33  void swapRows(Real** A,
34  const int& rowi,
35  const int& rowj,
36  const int&numberOfCols);
37 
38  void swapRows(Vector<Real>& rhs,
39  const int& currRow,
40  const int& pivot);
41 
42  int findPivot(Real** A,
43  const int& currCol,
44  const int& currRow,
45  const int& numRows,
46  int& pivot);
47 
48  void addRows(Vector<Real>& rhs,
49  const int& rowi,
50  const Real& alpha,
51  const int& rowj);
52 
53  void addRows(Real** A,
54  const int& rowi,
55  const Real& alpha,
56  const int& rowj,
57  const int& numberOfCols);
58 
59  void timesBeta(Vector<Real>&rhs,
60  const int& currRow,
61  const Real& Beta);
62 
63  void timesBeta(Real** A,
64  const int& rowi,
65  const Real& Beta,
66  const int& numberOfcols);
67 
68  void transpose(Real** a_A,
69  Real ** a_Atrans,
70  const int& a_numRows,
71  const int& a_numCols);
72 
73  void matMul(Real** a_A,
74  Real** a_B,
75  Real** a_C,
76  const int& a_numRowsA,
77  const int& a_numColsA,
78  const int& a_numColsB);
79 
80  void backSolve(Real** a_A,
81  const Vector<Real>& a_rhs,
82  const int& a_numArows,
83  Vector<Real>& a_x);
84 
85  void AtimesX(Real** A,
86  const Vector<Real>&x,
87  const int& numRowsA,
88  Vector<Real>& Ax);
89 
90  void allocArray(const int& rows,
91  const int& cols,
92  Real**& A);
93 
94  void freeArray(const int& rows,
95  const int& cols,
96  Real**& A);
97 
98  /// outputs a matrix A
99  void output(const int& rows,
100  const int& cols,
101  Real**& A,
102  char* name);
103 };
104 
105 #include "NamespaceFooter.H"
106 #endif
void AtimesX(Real **A, const Vector< Real > &x, const int &numRowsA, Vector< Real > &Ax)
void addRows(Vector< Real > &rhs, const int &rowi, const Real &alpha, const int &rowj)
int findPivot(Real **A, const int &currCol, const int &currRow, const int &numRows, int &pivot)
void matMul(Real **a_A, Real **a_B, Real **a_C, const int &a_numRowsA, const int &a_numColsA, const int &a_numColsB)
void timesBeta(Vector< Real > &rhs, const int &currRow, const Real &Beta)
int gaussElim(Real **A, Vector< Real > &rhs)
gaussian elimination with partial pivoting
void const char const int const int const int const Real const Real * A
Definition: Lapack.H:83
void allocArray(const int &rows, const int &cols, Real **&A)
void backSolve(Real **a_A, const Vector< Real > &a_rhs, const int &a_numArows, Vector< Real > &a_x)
Definition: LSquares.H:22
const char * name(const FArrayBox &a_dummySpecializationArg)
Definition: CH_HDF5.H:864
void freeArray(const int &rows, const int &cols, Real **&A)
double Real
Definition: REAL.H:33
void swapRows(Real **A, const int &rowi, const int &rowj, const int &numberOfCols)
void transpose(Real **a_A, Real **a_Atrans, const int &a_numRows, const int &a_numCols)
void LeastSquares(Real **A, Vector< Real > &x, const Vector< Real > &rhs)
void output(const int &rows, const int &cols, Real **&A, char *name)
outputs a matrix A