1 : |
agomez |
1 |
#ifndef ludecomposition_h
|
2 : |
|
|
#define ludecomposition_h
|
3 : |
|
|
|
4 : |
|
|
#include "doublematrix.h" |
5 : |
|
|
|
6 : |
|
|
/**
|
7 : |
|
|
* \class LUDecomposition
|
8 : |
|
|
* \brief This is the class used to calculate a LU decomposition of a rectangular matrix to solve the matrix equation A = bx
|
9 : |
|
|
*/
|
10 : |
|
|
class LUDecomposition {
|
11 : |
|
|
public:
|
12 : |
|
|
/**
|
13 : |
|
|
* \brief This is the default LUDecomposition constructor
|
14 : |
|
|
*/
|
15 : |
|
|
LUDecomposition() {};
|
16 : |
|
|
/**
|
17 : |
|
|
* \brief This is the LUDecomposition constructor for a given DoubleMatrix
|
18 : |
|
|
* \param A is the DoubleMatrix that will be decomposed into a lower triangular matrix L and an upper triangular matrix U
|
19 : |
|
|
*/
|
20 : |
|
|
LUDecomposition(const DoubleMatrix& A);
|
21 : |
|
|
/**
|
22 : |
|
|
* \brief This is the default LUDecomposition destructor
|
23 : |
|
|
*/
|
24 : |
|
|
~LUDecomposition() {};
|
25 : |
|
|
/**
|
26 : |
|
|
* \brief This function will solve the matrix equation A = bx and return the resulting DoubleVector
|
27 : |
|
|
* \param b is the DoubleVector that is to be used to solve the matrix equation A = bx
|
28 : |
|
|
* \return x, the solution of the matrix equation A = bx
|
29 : |
|
|
*/
|
30 : |
|
|
DoubleVector Solve(const DoubleVector& b);
|
31 : |
|
|
/**
|
32 : |
|
|
* \brief This function will return the log of the determinate of the matrix
|
33 : |
|
|
* \return logdet
|
34 : |
|
|
*/
|
35 : |
|
|
double getLogDet() { return logdet; };
|
36 : |
|
|
/**
|
37 : |
|
|
* \brief This function will return the flag to denote whether the algorithm will fail
|
38 : |
|
|
* \return illegal
|
39 : |
|
|
*/
|
40 : |
|
|
int isIllegal() { return illegal; };
|
41 : |
|
|
private:
|
42 : |
|
|
/**
|
43 : |
|
|
* \brief This is the lower triangular DoubleMatrix
|
44 : |
|
|
*/
|
45 : |
|
|
DoubleMatrix L;
|
46 : |
|
|
/**
|
47 : |
|
|
* \brief This is the upper triangular DoubleMatrix
|
48 : |
|
|
*/
|
49 : |
|
|
DoubleMatrix U;
|
50 : |
|
|
/**
|
51 : |
|
|
* \brief This is the log of the determinate of the matrix
|
52 : |
|
|
*/
|
53 : |
|
|
double logdet;
|
54 : |
|
|
/**
|
55 : |
|
|
* \brief This is the size of the matrix
|
56 : |
|
|
*/
|
57 : |
|
|
int size;
|
58 : |
|
|
/**
|
59 : |
|
|
* \brief This is the flag to denote that the matrix has a non-positive number of the diagonal which will cause the LUDecomposition algorithm to fail
|
60 : |
|
|
*/
|
61 : |
|
|
int illegal;
|
62 : |
|
|
};
|
63 : |
|
|
|
64 : |
|
|
#endif
|