#ifndef SOLVERS_H #define SOLVERS_H #include #include #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 call(std::vector) = 0;// must be provided virtual std::vector > Jacobian(std::vector){std::vector > J; return J;}; // optional }; // 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 NDNewtonRaphson_Jacobian(FuncWrapperND *f, std::vector x0, double tol, int maxiter, std::string *errstring); }; /*namespace CoolProp*/ #endif