Reaktoro
A unified framework for modeling chemically reactive systems
LU.hpp
1 // Reaktoro is a unified framework for modeling chemically reactive systems.
2 //
3 // Copyright (C) 2014-2018 Allan Leal
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library. If not, see <http://www.gnu.org/licenses/>.
17 
18 #pragma once
19 
20 // Reaktoro includes
21 #include <Reaktoro/Common/Index.hpp>
22 #include <Reaktoro/Math/Matrix.hpp>
23 
24 namespace Reaktoro {
25 
27 struct LU
28 {
30  LU();
31 
33  explicit LU(MatrixConstRef A);
34 
37 
39  auto empty() const -> bool;
40 
42  auto compute(MatrixConstRef A) -> void;
43 
45  auto compute(MatrixConstRef A, VectorConstRef W) -> void;
46 
48  auto solve(MatrixConstRef b) -> Matrix;
49 
51  auto trsolve(MatrixConstRef B) -> Matrix;
52 
55 
57  Vector W_last;
58 
61 
64 
67 
70 
73 };
74 
75 } // namespace Reaktoro
PermutationMatrix P
The permutation matrix P in the LU decomposition of the matrix PAQ = LU.
Definition: LU.hpp:66
LU()
Construct a default LU instance.
Definition: LU.cpp:35
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
Matrix U
The upper triangular matrix U in the LU decomposition of the matrix PAQ = LU.
Definition: LU.hpp:63
PermutationMatrix Q
The permutation matrix Q in the LU decomposition of the matrix PAQ = LU.
Definition: LU.hpp:69
Index rank
The rank of the matrix A
Definition: LU.hpp:72
Matrix A_last
The last decomposed matrix A.
Definition: LU.hpp:54
The class that computes the full pivoting Auxiliary struct for storing the LU decomposition of a matr...
Definition: LU.hpp:28
std::size_t Index
Define a type that represents an index.
Definition: Index.hpp:26
Eigen::PermutationMatrix< Eigen::Dynamic, Eigen::Dynamic > PermutationMatrix
Define an alias to a permutation matrix type of the Eigen library.
Definition: Matrix.hpp:89
Vector W_last
The last weights used for column scaling.
Definition: LU.hpp:57
auto empty() const -> bool
Return true if empty.
Definition: LU.cpp:48
auto solve(MatrixConstRef b) -> Matrix
Solve the linear system AX = B using the calculated LU decomposition.
Definition: LU.cpp:115
Eigen::MatrixXd Matrix
Alias to Eigen type MatrixXd.
Definition: Matrix.hpp:42
Eigen::Ref< const Eigen::MatrixXd > MatrixConstRef
Alias to Eigen type Ref<const MatrixXd>.
Definition: Matrix.hpp:44
auto compute(MatrixConstRef A) -> void
Compute the LU decomposition of the given matrix.
Definition: LU.cpp:53
Eigen::Ref< const Eigen::VectorXd > VectorConstRef
< Alias to Eigen type Ref<VectorXd>.
Definition: Matrix.hpp:31
Matrix L
The lower triangular matrix L in the LU decomposition of the matrix PAQ = LU.
Definition: LU.hpp:60
auto trsolve(MatrixConstRef B) -> Matrix
Solve the linear system tr(A)X = B using the calculated LU decomposition.
Definition: LU.cpp:136