Repository navigation
Expand file tree
/
Copy pathSolvers.h
More file actions
46 lines (37 loc) · 1.73 KB
/
Copy pathSolvers.h
File metadata and controls
46 lines (37 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef SOLVERS_H
#define SOLVERS_H
#include <vector>
#include <string>
#include "Exceptions.h"
namespace CoolProp
{
class FuncWrapper1D
{
public:
FuncWrapper1D(){};
virtual ~FuncWrapper1D(){};
virtual double call(double) = 0;
virtual double deriv(double){throw NotImplementedError("deriv function not implemented");};
};
class FuncWrapperND
{
public:
FuncWrapperND(){};
virtual ~FuncWrapperND(){};
virtual std::vector<double> call(std::vector<double>) = 0;// must be provided
virtual std::vector<std::vector<double> > Jacobian(std::vector<double>);
};
// Single-Dimensional solvers, pointer versions
double Brent(FuncWrapper1D* f, double a, double b, double macheps, double t, int maxiter, std::string &errstr);
double Secant(FuncWrapper1D* f, double x0, double dx, double ftol, int maxiter, std::string &errstring);
double BoundedSecant(FuncWrapper1D* f, double x0, double xmin, double xmax, double dx, double ftol, int maxiter, std::string &errstring);
double Newton(FuncWrapper1D* f, double x0, double ftol, int maxiter, std::string &errstring);
// Single-Dimensional solvers
double Brent(FuncWrapper1D &f, double a, double b, double macheps, double t, int maxiter, std::string &errstr);
double Secant(FuncWrapper1D &f, double x0, double dx, double ftol, int maxiter, std::string &errstring);
double BoundedSecant(FuncWrapper1D &f, double x0, double xmin, double xmax, double dx, double ftol, int maxiter, std::string &errstring);
double Newton(FuncWrapper1D &f, double x0, double ftol, int maxiter, std::string &errstring);
// Multi-Dimensional solvers
std::vector<double> NDNewtonRaphson_Jacobian(FuncWrapperND *f, std::vector<double> x0, double tol, int maxiter, std::string *errstring);
}; /*namespace CoolProp*/
#endif