Reaktoro 
A unified framework for modeling chemically reactive systems
Utils.hpp
1 // Reaktoro is a unified framework for modeling chemically reactive systems.
2 //
3 // Copyright (C) 2014-2015 Allan Leal
4 //
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program 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
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18 #pragma once
19 
20 // C++ includes
21 #include <functional>
22 
23 // Reaktoro includes
24 #include <Reaktoro/Math/Matrix.hpp>
25 
26 namespace Reaktoro {
27 
33 auto largestStep(const Vector& p, const Vector& dp) -> double;
34 
40 auto fractionToTheBoundary(const Vector& p, const Vector& dp, double tau) -> double;
41 
48 auto fractionToTheBoundary(const Vector& p, const Vector& dp, double tau, Index& ilimiting) -> double;
49 
57 auto fractionToTheBoundary(const Vector& p, const Vector& dp, const Matrix& C, const Vector& r, double tau) -> double;
58 
65 auto fractionToTheLowerBoundary(const Vector& p, const Vector& dp, const Vector& lower, double tau) -> double;
66 
76 auto lessThan(double a, double b, double baseval) -> bool;
77 
87 auto greaterThan(double a, double b, double baseval) -> bool;
88 
90 auto infinity() -> double;
91 
93 auto bfgs() -> std::function<Matrix(const Vector&, const Vector&)>;
94 
96 auto minimizeGoldenSectionSearch(const std::function<double(double)>& f, double a, double b, double tol = 1e-5) -> double;
97 
99 auto minimizeBrent(const std::function<double(double)>& f, double min, double max, double tolerance = 1e-5, unsigned maxiters = 100) -> double;
100 
101 } // namespace Reaktoro
Eigen::MatrixXd Matrix
Define an alias to the matrix type of the Eigen library.
Definition: Matrix.hpp:387
auto infinity() -> double
Return the floating-point representation of positive infinity.
Definition: Utils.cpp:105
auto minimizeBrent(const std::function< double(double)> &f, double min, double max, double tolerance, unsigned maxiters) -> double
Calculate the minimum of a single variable function using the Brent algorithm.
Definition: Utils.cpp:201
auto largestStep(const Vector &p, const Vector &dp) -> double
Compute the largest step length such that is on the lower bound .
Definition: Utils.cpp:25
auto bfgs() -> std::function< Matrix(const Vector &, const Vector &)>
Return an inverse Hessian function based on the BFGS Hessian approximation.
Definition: Utils.cpp:110
Eigen::VectorXd Vector
Define an alias to the vector type of the Eigen library.
Definition: Matrix.hpp:384
std::size_t Index
Define a type that represents an index.
Definition: Index.hpp:26
auto greaterThan(double lhs, double rhs, double baseval) -> bool
Check if a float number is greater than another by a base value.
Definition: Utils.cpp:99
auto lessThan(double lhs, double rhs, double baseval) -> bool
Compute the fraction-to-the-boundary step length given by: , where is the machine double precision...
Definition: Utils.cpp:93
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24