SynAPSE  0.6.0
Synergistic Analysis of Phase Space Evolution
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
DecompLU.hh
1 // C++ includes
2 #include <iostream>
3 #include <cmath>
4 #include <climits>
5 #include <vector>
6 #include <queue>
7 #include <algorithm>
8 
9 // Other includes
10 #include "Assert.hh"
11 
19 template<typename T> class DecompLU {
20  public:
22  DecompLU();
23 
25  DecompLU(std::vector<std::vector<T>> mat);
26 
28  DecompLU(const DecompLU& decLU);
29 
31  DecompLU& operator=(const DecompLU& decLU);
32 
34  ~DecompLU();
35 
43  void DecomposeCrout(std::vector<std::vector<T>> mat);
44 
48  T Determinant();
49 
57  std::vector<std::vector<T>> NewMatrix(size_t m, size_t n);
58 
60  const T& Factor() { return _fact; }
61 
63  const bool& Complete() { return _complete; }
64 
66  const std::vector<std::vector<T>>& P() { return _P; }
67 
69  const std::vector<T>& Pivots() { return _pivots; }
70 
72  const std::vector<std::vector<T>>& L() { return _L; }
73 
75  const std::vector<std::vector<T>>& U() { return _U; }
76 
77  private:
78 
79  T _fact;
80  bool _complete;
81  std::vector<std::vector<T>> _P;
82  std::vector<T> _pivots;
83  std::vector<std::vector<T>> _L;
84  std::vector<std::vector<T>> _U;
85 };
86 
87 #include "DecompLU-inl.hh"
const bool & Complete()
Gets and returns whether the LU decomposition was successful or not.
Definition: DecompLU.hh:63
Defines the LU decomposition algorithm of a square matrix.
Definition: DecompLU.hh:19
std::vector< std::vector< T > > _L
L Matrix.
Definition: DecompLU.hh:83
std::vector< std::vector< T > > NewMatrix(size_t m, size_t n)
Returns a matrix of m rows and n columns.
Definition: DecompLU-inl.hh:122
std::vector< std::vector< T > > _P
Permutation matrix.
Definition: DecompLU.hh:81
void DecomposeCrout(std::vector< std::vector< T >> mat)
Decomposes a square matrix into a parity matrix P, a lower triangular matrix L and an upper triangula...
Definition: DecompLU-inl.hh:35
std::vector< T > _pivots
Premutation vector (IDs of the rows)
Definition: DecompLU.hh:82
const std::vector< std::vector< T > > & L()
Gets and returns the lower triangular matrix.
Definition: DecompLU.hh:72
DecompLU()
Default constructor, initilizes an empty matrix of dimension 0x0.
Definition: DecompLU-inl.hh:1
T _fact
Parity of the permutation (1 or -1)
Definition: DecompLU.hh:79
const T & Factor()
Gets and returns the parity of the permutations.
Definition: DecompLU.hh:60
~DecompLU()
Destructor.
Definition: DecompLU-inl.hh:33
const std::vector< std::vector< T > > & U()
Gets and returns the upper triangular matrix.
Definition: DecompLU.hh:75
const std::vector< T > & Pivots()
Gets and returns the permutation vector, contains the ids of the rows.
Definition: DecompLU.hh:69
std::vector< std::vector< T > > _U
U Matrix.
Definition: DecompLU.hh:84
T Determinant()
Returns the determinant of the decomposed matrix.
Definition: DecompLU-inl.hh:113
DecompLU & operator=(const DecompLU &decLU)
Equality operator.
Definition: DecompLU-inl.hh:20
bool _complete
True if the decomposition was successful.
Definition: DecompLU.hh:80
const std::vector< std::vector< T > > & P()
Gets and returns the permutation matrix.
Definition: DecompLU.hh:66