Reaktoro
A unified framework for modeling chemically reactive systems
MathUtils.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 
30 
35 
41 
47 
52 
59 auto rationalize(double x, unsigned maxden) -> std::tuple<long, long>;
60 
64 auto cleanRationalNumbers(double* vals, long size, long maxden = 6) -> void;
65 
69 auto cleanRationalNumbers(MatrixRef A, long maxden = 6) -> void;
70 
72 auto dot3p(VectorConstRef x, VectorConstRef y, double s) -> double;
73 
76 
77 } // namespace Reaktoro
Eigen::Ref< Eigen::MatrixXd > MatrixRef
Alias to Eigen type Ref<MatrixXd>.
Definition: Matrix.hpp:43
auto linearlyIndependentRows(MatrixConstRef A) -> Indices
Determine the set of linearly independent rows in a matrix.
Definition: MathUtils.cpp:38
auto linearlyIndependentCols(MatrixConstRef A) -> Indices
Determine the set of linearly independent columns in a matrix using a column pivoting QR algorithm.
Definition: MathUtils.cpp:28
auto cleanRationalNumbers(double *vals, long size, long maxden) -> void
Clean an array that is known to have rational numbers from round-off errors.
Definition: MathUtils.cpp:114
auto rationalize(double x, unsigned maxden) -> std::tuple< long, long >
Calculates the rational number that approximates a given real number.
Definition: MathUtils.cpp:101
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
auto dot3p(VectorConstRef x, VectorConstRef y, double s) -> double
Return the dot product s + dot(x, y) of two vectors with triple-precision.
Definition: MathUtils.cpp:154
std::vector< Index > Indices
Define a type that represents a collection of indices.
Definition: Index.hpp:29
Eigen::MatrixXd Matrix
Alias to Eigen type MatrixXd.
Definition: Matrix.hpp:42
auto inverseShermanMorrison(MatrixConstRef invA, VectorConstRef D) -> Matrix
Calculate the inverse of A + D where inv(A) is already known and D is a diagonal matrix.
Definition: MathUtils.cpp:64
Eigen::Ref< const Eigen::MatrixXd > MatrixConstRef
Alias to Eigen type Ref<const MatrixXd>.
Definition: Matrix.hpp:44
Eigen::Ref< const Eigen::VectorXd > VectorConstRef
< Alias to Eigen type Ref<VectorXd>.
Definition: Matrix.hpp:31
auto residual3p(MatrixConstRef A, VectorConstRef x, VectorConstRef b) -> Vector
Return the residual of the equation A*x - b with triple-precision.
Definition: MathUtils.cpp:159