CoolProp 8.0.0
An open-source fluid property and humid air property database
PolyMath.h
Go to the documentation of this file.
1#ifndef POLYMATH_H
2#define POLYMATH_H
3
6
7#include <vector>
10#include "unsupported/Eigen/Polynomials"
11
12namespace CoolProp {
13
14// Forward declaration of get_debug_level (defined in CoolProp.h / CoolProp.cpp);
15// pulled in here so PolyMath.h does not have to #include the much heavier CoolProp.h
16// just for the one-line do_debug() helper below.
17int get_debug_level();
18
19// Just a forward declaration
20class Poly2DResidual;
21class Poly2DFracResidual;
22
24
28{
29
30 public:
32 Polynomial2D() = default;
33
35 virtual ~Polynomial2D() = default;
36
37 public:
40 Eigen::MatrixXd convertCoefficients(const std::vector<double>& coefficients) {
41 return vec_to_eigen(coefficients);
42 }
45 Eigen::MatrixXd convertCoefficients(const std::vector<std::vector<double>>& coefficients) {
46 return vec_to_eigen(coefficients);
47 }
48
50
55 bool checkCoefficients(const Eigen::MatrixXd& coefficients, const unsigned int rows, const unsigned int columns);
56
57 public:
59
70 Eigen::MatrixXd integrateCoeffs(const Eigen::MatrixXd& coefficients, const int& axis, const int& times);
71
73
79 Eigen::MatrixXd deriveCoeffs(const Eigen::MatrixXd& coefficients, const int& axis = -1, const int& times = 1);
80
81 public:
83
95 double evaluate(const Eigen::MatrixXd& coefficients, const double& x_in);
96
100 double evaluate(const Eigen::MatrixXd& coefficients, const double& x_in, const double& y_in);
101
106 double derivative(const Eigen::MatrixXd& coefficients, const double& x_in, const double& y_in, const int& axis);
107
112 double integral(const Eigen::MatrixXd& coefficients, const double& x_in, const double& y_in, const int& axis);
113
114 protected:
115 // TODO: Why doe these base definitions not work with derived classes?
120 double solve_limits(Poly2DResidual* res, const double& min, const double& max);
121
122 // TODO: Why doe these base definitions not work with derived classes?
126 double solve_guess(Poly2DResidual* res, const double& guess);
127
128 public:
134 Eigen::VectorXd solve(const Eigen::MatrixXd& coefficients, const double& in, const double& z_in, const int& axis);
135
143 double solve_limits(const Eigen::MatrixXd& coefficients, const double& in, const double& z_in, const double& min, const double& max,
144 const int& axis);
145
152 double solve_guess(const Eigen::MatrixXd& coefficients, const double& in, const double& z_in, const double& guess, const int& axis);
153
154 protected:
156
159 double simplePolynomial(const std::vector<double>& coefficients, double x);
160 [[deprecated("Poor performance; use Horner-scheme instead")]] double simplePolynomial(const std::vector<std::vector<double>>& coefficients,
161 double x, double y);
163
168 double baseHorner(const std::vector<double>& coefficients, double x);
169 [[deprecated("Deprecated since move to Eigen framework; use Eigen-based routines instead")]] double
170 baseHorner(const std::vector<std::vector<double>>& coefficients, double x, double y);
171
172 bool do_debug() {
173 return get_debug_level() >= 500;
174 }
175};
176
178{
179 protected:
180 enum dims
181 {
183 iY
184 };
185 Eigen::MatrixXd coefficients;
187 Eigen::MatrixXd coefficientsDer;
188 int axis;
190 double in;
194 double z_in;
195
196 protected:
198
199 public:
206 Poly2DResidual(Polynomial2D& poly, const Eigen::MatrixXd& coefficients, const double& in, const double& z_in, const int& axis);
207 virtual ~Poly2DResidual() = default;
208
209 double call(double target) override;
210 double deriv(double target) override;
211};
212
214
221{
222
223 public:
225 Polynomial2DFrac() = default;
226
228 virtual ~Polynomial2DFrac() = default;
229
230 public:
231 // /// Integration functions
232 // /** Integrating coefficients for polynomials is done by dividing the
233 // * original coefficients by (i+1) and elevating the order by 1
234 // * through adding a zero as first coefficient.
235 // * Some reslicing needs to be applied to integrate along the x-axis.
236 // * In the brine/solution equations, reordering of the parameters
237 // * avoids this expensive operation. However, it is included for the
238 // * sake of completeness.
239 // */
240 // /// @param coefficients matrix containing the ordered coefficients
241 // /// @param axis unsigned integer value that represents the desired direction of integration
242 // /// @param times integer value that represents the desired order of integration
243 // /// @param firstExponent integer value that represents the first exponent of the polynomial in axis direction
244 // Eigen::MatrixXd integrateCoeffs(const Eigen::MatrixXd &coefficients, const int &axis, const int &times, const int &firstExponent);
245 //
247
259 Eigen::MatrixXd deriveCoeffs(const Eigen::MatrixXd& coefficients, const int& axis, const int& times, const int& firstExponent);
260
261 public:
263
277 double evaluate(const Eigen::MatrixXd& coefficients, const double& x_in, const int& firstExponent = 0, const double& x_base = 0.0);
278
286 double evaluate(const Eigen::MatrixXd& coefficients, const double& x_in, const double& y_in, const int& x_exp, const int& y_exp,
287 const double& x_base = 0.0, const double& y_base = 0.0);
288
297 double derivative(const Eigen::MatrixXd& coefficients, const double& x_in, const double& y_in, const int& axis, const int& x_exp,
298 const int& y_exp, const double& x_base = 0.0, const double& y_base = 0.0);
299
309 double integral(const Eigen::MatrixXd& coefficients, const double& x_in, const double& y_in, const int& axis, const int& x_exp, const int& y_exp,
310 const double& x_base = 0.0, const double& y_base = 0.0, const double& ax_val = 0.0);
311
312 public:
322 Eigen::VectorXd solve(const Eigen::MatrixXd& coefficients, const double& in, const double& z_in, const int& axis, const int& x_exp,
323 const int& y_exp, const double& x_base = 0.0, const double& y_base = 0.0);
324
336 double solve_limits(const Eigen::MatrixXd& coefficients, const double& in, const double& z_in, const double& min, const double& max,
337 const int& axis, const int& x_exp, const int& y_exp, const double& x_base = 0.0, const double& y_base = 0.0);
338
349 double solve_guess(const Eigen::MatrixXd& coefficients, const double& in, const double& z_in, const double& guess, const int& axis,
350 const int& x_exp, const int& y_exp, const double& x_base = 0.0, const double& y_base = 0.0);
351
364 double solve_limitsInt(const Eigen::MatrixXd& coefficients, const double& in, const double& z_in, const double& min, const double& max,
365 const int& axis, const int& x_exp, const int& y_exp, const double& x_base = 0.0, const double& y_base = 0.0,
366 const int& int_axis = 0);
367
379 double solve_guessInt(const Eigen::MatrixXd& coefficients, const double& in, const double& z_in, const double& guess, const int& axis,
380 const int& x_exp, const int& y_exp, const double& x_base = 0.0, const double& y_base = 0.0, const int& int_axis = 0);
381
382 protected:
384 double factorial(const int& nValue);
385
388 double binom(const int& nValue, const int& nValue2);
389
394 Eigen::MatrixXd fracIntCentralDvector(const int& m, const double& x_in, const double& x_base);
395
400 double fracIntCentral(const Eigen::MatrixXd& coefficients, const double& x_in, const double& x_base);
401};
402
404{
405 protected:
407 double x_base, y_base;
410
411 protected:
413
414 public:
425 Poly2DFracResidual(Polynomial2DFrac& poly, const Eigen::MatrixXd& coefficients, const double& in, const double& z_in, const int& axis,
426 const int& x_exp, const int& y_exp, const double& x_base, const double& y_base);
427 virtual ~Poly2DFracResidual() = default;
428 double call(double target) override;
429 double deriv(double target) override;
430};
431
433{
434
435 protected:
438
439 public:
451 Poly2DFracIntResidual(Polynomial2DFrac& poly, const Eigen::MatrixXd& coefficients, const double& in, const double& z_in, const int& axis,
452 const int& x_exp, const int& y_exp, const double& x_base, const double& y_base, const int& int_axis);
453 virtual ~Poly2DFracIntResidual() = default;
454 double call(double target) override;
455 double deriv(double target) override;
456};
457
458//
459//
460//
461//
462//
463//
464//
465//
466//
468//class BasePolynomial{
469//
470//public:
471// // Constructor
472// BasePolynomial();
473// // Destructor. No implementation
474// virtual ~BasePolynomial(){};
475//
476//public:
477// /// Basic checks for coefficient vectors.
478// /** Starts with only the first coefficient dimension
479// * and checks the vector length against parameter n. */
480// bool checkCoefficients(const Eigen::VectorXd &coefficients, const unsigned int n);
481// bool checkCoefficients(const Eigen::MatrixXd &coefficients, const unsigned int rows, const unsigned int columns);
482// bool checkCoefficients(const std::vector<double> &coefficients, const unsigned int n);
483// bool checkCoefficients(const std::vector< std::vector<double> > &coefficients, const unsigned int rows, const unsigned int columns);
484//
485// /** Integrating coefficients for polynomials is done by dividing the
486// * original coefficients by (i+1) and elevating the order by 1
487// * through adding a zero as first coefficient.
488// * Some reslicing needs to be applied to integrate along the x-axis.
489// * In the brine/solution equations, reordering of the parameters
490// * avoids this expensive operation. However, it is included for the
491// * sake of completeness.
492// */
493// std::vector<double> integrateCoeffs(const std::vector<double> &coefficients);
494// std::vector< std::vector<double> > integrateCoeffs(const std::vector< std::vector<double> > &coefficients, bool axis);
495//
496// /** Deriving coefficients for polynomials is done by multiplying the
497// * original coefficients with i and lowering the order by 1.
498// *
499// * It is not really deprecated, but untested and therefore a warning
500// * is issued. Please check this method before you use it.
501// */
502// std::vector<double> deriveCoeffs(const std::vector<double> &coefficients);
503// std::vector< std::vector<double> > deriveCoeffs(const std::vector< std::vector<double> > &coefficients, unsigned int axis);
504//
505//private:
506// /** The core of the polynomial wrappers are the different
507// * implementations that follow below. In case there are
508// * new calculation schemes available, please do not delete
509// * the implementations, but mark them as deprecated.
510// * The old functions are good for debugging since the
511// * structure is easier to read than the backward Horner-scheme
512// * or the recursive Horner-scheme.
513// */
514//
515// /// Simple polynomial function generator. <- Deprecated due to poor performance, use Horner-scheme instead
516// /** Base function to produce n-th order polynomials
517// * based on the length of the coefficient vector.
518// * Starts with only the first coefficient at x^0. */
519// DEPRECATED(double simplePolynomial(const std::vector<double> &coefficients, double x));
520// DEPRECATED(double simplePolynomial(const std::vector<std::vector<double> > &coefficients, double x, double y));
521//
522// /// Simple integrated polynomial function generator.
523// /** Base function to produce integrals of n-th order polynomials based on
524// * the length of the coefficient vector.
525// * Starts with only the first coefficient at x^0 */
526// ///Indefinite integral in x-direction
527// double simplePolynomialInt(const std::vector<double> &coefficients, double x);
528// ///Indefinite integral in y-direction only
529// double simplePolynomialInt(const std::vector<std::vector<double> > &coefficients, double x, double y);
530//
531// /// Simple integrated polynomial function generator divided by independent variable.
532// /** Base function to produce integrals of n-th order
533// * polynomials based on the length of the coefficient
534// * vector. Starts with only the first coefficient at x^0 */
535// ///Indefinite integral of a polynomial divided by its independent variable
536// double simpleFracInt(const std::vector<double> &coefficients, double x);
537// ///Indefinite integral of a polynomial divided by its 2nd independent variable
538// double simpleFracInt(const std::vector<std::vector<double> > &coefficients, double x, double y);
539//
540// /** Simple integrated centred(!) polynomial function generator divided by independent variable.
541// * We need to rewrite some of the functions in order to
542// * use central fit. Having a central temperature xbase
543// * allows for a better fit, but requires a different
544// * formulation of the fracInt function group. Other
545// * functions are not affected.
546// * Starts with only the first coefficient at x^0 */
547// ///Helper function to calculate the D vector:
548// double factorial(double nValue);
549// double binom(double nValue, double nValue2);
550// std::vector<double> fracIntCentralDvector(int m, double x, double xbase);
551// ///Indefinite integral of a centred polynomial divided by its independent variable
552// double fracIntCentral(const std::vector<double> &coefficients, double x, double xbase);
553//
554// /// Horner function generator implementations
555// /** Represent polynomials according to Horner's scheme.
556// * This avoids unnecessary multiplication and thus
557// * speeds up calculation.
558// */
559// double baseHorner(const std::vector<double> &coefficients, double x);
560// double baseHorner(const std::vector< std::vector<double> > &coefficients, double x, double y);
561// ///Indefinite integral in x-direction
562// double baseHornerInt(const std::vector<double> &coefficients, double x);
563// ///Indefinite integral in y-direction only
564// double baseHornerInt(const std::vector<std::vector<double> > &coefficients, double x, double y);
565// ///Indefinite integral of a polynomial divided by its independent variable
566// double baseHornerFracInt(const std::vector<double> &coefficients, double x);
567// ///Indefinite integral of a polynomial divided by its 2nd independent variable
568// double baseHornerFracInt(const std::vector<std::vector<double> > &coefficients, double x, double y);
569//
570// /** Alternatives
571// * Simple functions that heavily rely on other parts of this file.
572// * We still need to check which combinations yield the best
573// * performance.
574// */
575// ///Derivative in x-direction
576// double deriveIn2Steps(const std::vector<double> &coefficients, double x); // TODO: Check results!
577// ///Derivative in terms of x(axis=true) or y(axis=false).
578// double deriveIn2Steps(const std::vector< std::vector<double> > &coefficients, double x, double y, bool axis); // TODO: Check results!
579// ///Indefinite integral in x-direction
580// double integrateIn2Steps(const std::vector<double> &coefficients, double x);
581// ///Indefinite integral in terms of x(axis=true) or y(axis=false).
582// double integrateIn2Steps(const std::vector< std::vector<double> > &coefficients, double x, double y, bool axis);
583// ///Indefinite integral in x-direction of a polynomial divided by its independent variable
584// double fracIntIn2Steps(const std::vector<double> &coefficients, double x);
585// ///Indefinite integral in y-direction of a polynomial divided by its 2nd independent variable
586// double fracIntIn2Steps(const std::vector<std::vector<double> > &coefficients, double x, double y);
587// ///Indefinite integral of a centred polynomial divided by its 2nd independent variable
588// double fracIntCentral2Steps(const std::vector<std::vector<double> > &coefficients, double x, double y, double ybase);
589//
590//public:
591// /** Here we define the functions that should be used by the
592// * respective implementations. Please do no use any other
593// * method since this would break the purpose of this interface.
594// * Note that the functions below are supposed to be aliases
595// * to implementations declared elsewhere in this file.
596// */
597//
598// /** Everything related to the normal polynomials goes in this
599// * section, holds all the functions for evaluating polynomials.
600// */
601// /// Evaluates a one-dimensional polynomial for the given coefficients
602// /// @param coefficients vector containing the ordered coefficients
603// /// @param x double value that represents the current input
604// virtual inline double polyval(const std::vector<double> &coefficients, double x){
605// return baseHorner(coefficients,x);
606// }
607//
608// /// Evaluates a two-dimensional polynomial for the given coefficients
609// /// @param coefficients vector containing the ordered coefficients
610// /// @param x double value that represents the current input in the 1st dimension
611// /// @param y double value that represents the current input in the 2nd dimension
612// virtual inline double polyval(const std::vector< std::vector<double> > &coefficients, double x, double y){
613// return baseHorner(coefficients,x,y);
614// }
615//
616//
617// /** Everything related to the integrated polynomials goes in this
618// * section, holds all the functions for evaluating polynomials.
619// */
620// /// Evaluates the indefinite integral of a one-dimensional polynomial
621// /// @param coefficients vector containing the ordered coefficients
622// /// @param x double value that represents the current input
623// virtual inline double polyint(const std::vector<double> &coefficients, double x){
624// return baseHornerInt(coefficients,x);
625// }
626//
627// /// Evaluates the indefinite integral of a two-dimensional polynomial along the 2nd axis (y)
628// /// @param coefficients vector containing the ordered coefficients
629// /// @param x double value that represents the current input in the 1st dimension
630// /// @param y double value that represents the current input in the 2nd dimension
631// virtual inline double polyint(const std::vector< std::vector<double> > &coefficients, double x, double y){
632// return baseHornerInt(coefficients,x,y);
633// }
634//
635//
636// /** Everything related to the derived polynomials goes in this
637// * section, holds all the functions for evaluating polynomials.
638// */
639// /// Evaluates the derivative of a one-dimensional polynomial
640// /// @param coefficients vector containing the ordered coefficients
641// /// @param x double value that represents the current input
642// virtual inline double polyder(const std::vector<double> &coefficients, double x){
643// return deriveIn2Steps(coefficients,x);
644// }
645//
646// /// Evaluates the derivative of a two-dimensional polynomial along the 2nd axis (y)
647// /// @param coefficients vector containing the ordered coefficients
648// /// @param x double value that represents the current input in the 1st dimension
649// /// @param y double value that represents the current input in the 2nd dimension
650// virtual inline double polyder(const std::vector< std::vector<double> > &coefficients, double x, double y){
651// return deriveIn2Steps(coefficients,x,y,false);
652// }
653//
654//
655// /** Everything related to the polynomials divided by one variable goes in this
656// * section, holds all the functions for evaluating polynomials.
657// */
658// /// Evaluates the indefinite integral of a one-dimensional polynomial divided by its independent variable
659// /// @param coefficients vector containing the ordered coefficients
660// /// @param x double value that represents the current position
661// virtual inline double polyfracval(const std::vector<double> &coefficients, double x){
662// return baseHorner(coefficients,x)/x;
663// }
664//
665// /// Evaluates the indefinite integral of a two-dimensional polynomial divided by its 2nd independent variable
666// /// @param coefficients vector containing the ordered coefficients
667// /// @param x double value that represents the current input in the 1st dimension
668// /// @param y double value that represents the current input in the 2nd dimension
669// virtual inline double polyfracval(const std::vector< std::vector<double> > &coefficients, double x, double y){
670// return baseHorner(coefficients,x,y)/y;
671// }
672//
673//
674// /** Everything related to the integrated polynomials divided by one variable goes in this
675// * section, holds all the functions for solving polynomials.
676// */
677// /// Evaluates the indefinite integral of a one-dimensional polynomial divided by its independent variable
678// /// @param coefficients vector containing the ordered coefficients
679// /// @param x double value that represents the current position
680// virtual inline double polyfracint(const std::vector<double> &coefficients, double x){
681// return baseHornerFracInt(coefficients,x);
682// }
683//
684// /// Evaluates the indefinite integral of a two-dimensional polynomial divided by its 2nd independent variable
685// /// @param coefficients vector containing the ordered coefficients
686// /// @param x double value that represents the current input in the 1st dimension
687// /// @param y double value that represents the current input in the 2nd dimension
688// virtual inline double polyfracint(const std::vector< std::vector<double> > &coefficients, double x, double y){
689// return baseHornerFracInt(coefficients,x,y);
690// }
691//
692// /// Evaluates the indefinite integral of a centred one-dimensional polynomial divided by its independent variable
693// /// @param coefficients vector containing the ordered coefficients
694// /// @param x double value that represents the current position
695// /// @param xbase central temperature for fitted function
696// virtual inline double polyfracintcentral(const std::vector<double> &coefficients, double x, double xbase){
697// return fracIntCentral(coefficients,x,xbase);
698// }
699//
700// /// Evaluates the indefinite integral of a centred two-dimensional polynomial divided by its 2nd independent variable
701// /// @param coefficients vector containing the ordered coefficients
702// /// @param x double value that represents the current input in the 1st dimension
703// /// @param y double value that represents the current input in the 2nd dimension
704// /// @param ybase central temperature for fitted function
705// virtual inline double polyfracintcentral(const std::vector< std::vector<double> > &coefficients, double x, double y, double ybase){
706// return fracIntCentral2Steps(coefficients,x,y,ybase);
707// }
708//
709//
710// /** Everything related to the derived polynomials divided by one variable goes in this
711// * section, holds all the functions for solving polynomials.
712// */
713// /// Evaluates the derivative of a one-dimensional polynomial divided by its independent variable
714// /// @param coefficients vector containing the ordered coefficients
715// /// @param x double value that represents the current position
716// virtual inline double polyfracder(const std::vector<double> &coefficients, double x){
717// throw CoolProp::NotImplementedError("Derivatives of polynomials divided by their independent variable have not been implemented."); // TODO: Implement polyfracder1D
718// }
719//
720// /// Evaluates the derivative of a two-dimensional polynomial divided by its 2nd independent variable
721// /// @param coefficients vector containing the ordered coefficients
722// /// @param x double value that represents the current input in the 1st dimension
723// /// @param y double value that represents the current input in the 2nd dimension
724// virtual inline double polyfracder(const std::vector< std::vector<double> > &coefficients, double x, double y){
725// throw CoolProp::NotImplementedError("Derivatives of polynomials divided by their independent variable have not been implemented."); // TODO: Implement polyfracder2D
726// }
727//
728// /// Evaluates the derivative of a centred one-dimensional polynomial divided by its independent variable
729// /// @param coefficients vector containing the ordered coefficients
730// /// @param x double value that represents the current position
731// /// @param xbase central temperature for fitted function
732// virtual inline double polyfracdercentral(const std::vector<double> &coefficients, double x, double xbase){
733// throw CoolProp::NotImplementedError("Derivatives of polynomials divided by their independent variable have not been implemented."); // TODO: Implement polyfracdercentral1D
734// }
735//
736// /// Evaluates the derivative of a centred two-dimensional polynomial divided by its 2nd independent variable
737// /// @param coefficients vector containing the ordered coefficients
738// /// @param x double value that represents the current input in the 1st dimension
739// /// @param y double value that represents the current input in the 2nd dimension
740// /// @param ybase central temperature for fitted function
741// virtual inline double polyfracdercentral(const std::vector< std::vector<double> > &coefficients, double x, double y, double ybase){
742// throw CoolProp::NotImplementedError("Derivatives of polynomials divided by their independent variable have not been implemented."); // TODO: Implement polyfracdercentral2D
743// }
744//};
745//
746//
747//
748//
750// * used by the solvers.
751// * TODO: Make multidimensional
752// */
753//class PolyResidual : public FuncWrapper1D {
754//protected:
755// enum dims {i1D, i2D};
756// /// Object that evaluates the equation
757// BasePolynomial poly;
758// /// Current output value
759// double output, firstDim;
760// int dim;
761// std::vector< std::vector<double> > coefficients;
762//private:
763// PolyResidual();
764//public:
765// PolyResidual(const std::vector<double> &coefficients, double y);
766// PolyResidual(const std::vector< std::vector<double> > &coefficients, double x, double z);
767// virtual ~PolyResidual(){};
768// bool is2D(){return (this->dim==i2D);};
769// virtual double call(double x);
770// virtual double deriv(double x);
771//};
772//class PolyIntResidual : public PolyResidual {
773//public:
774// PolyIntResidual(const std::vector<double> &coefficients, double y):PolyResidual(coefficients, y){};
775// PolyIntResidual(const std::vector< std::vector<double> > &coefficients, double x, double z):PolyResidual(coefficients, x, z){};
776// virtual double call(double x);
777// virtual double deriv(double x);
778//};
779//class PolyFracIntResidual : public PolyResidual {
780//public:
781// PolyFracIntResidual(const std::vector<double> &coefficients, double y):PolyResidual(coefficients, y){};
782// PolyFracIntResidual(const std::vector< std::vector<double> > &coefficients, double x, double z):PolyResidual(coefficients, x, z){};
783// virtual double call(double x);
784// virtual double deriv(double x);
785//};
786//class PolyFracIntCentralResidual : public PolyResidual {
787//protected:
788// double baseVal;
789//public:
790// PolyFracIntCentralResidual(const std::vector<double> &coefficients, double y, double xBase):PolyResidual(coefficients, y){this->baseVal = xBase;};
791// PolyFracIntCentralResidual(const std::vector< std::vector<double> > &coefficients, double x, double z, double yBase): PolyResidual(coefficients, x, z){this->baseVal = yBase;};
792// virtual double call(double x);
793// virtual double deriv(double x);
794//};
795//class PolyDerResidual : public PolyResidual {
796//public:
797// PolyDerResidual(const std::vector<double> &coefficients, double y):PolyResidual(coefficients, y){};
798// PolyDerResidual(const std::vector< std::vector<double> > &coefficients, double x, double z):PolyResidual(coefficients, x, z){};
799// virtual double call(double x);
800// virtual double deriv(double x);
801//};
802//
803//
804//
805//
807// * but solves the polynomial for the given value
808// * instead of evaluating it.
809// * TODO: This class does not check for bijective
810// * polynomials and is therefore a little
811// * fragile.
812// */
813//class PolynomialSolver : public BasePolynomial{
814//private:
815// enum solvers {iNewton, iBrent};
816// int uses;
817// double guess, min, max;
818// double macheps, tol;
819// int maxiter;
820//
821//public:
822// // Constructor
823// PolynomialSolver();
824// // Destructor. No implementation
825// virtual ~PolynomialSolver(){};
826//
827//public:
828// /** Here we redefine the functions that solve the polynomials.
829// * These implementations all use the base class to evaluate
830// * the polynomial during the solution process.
831// */
832//
833// /** Everything related to the normal polynomials goes in this
834// * section, holds all the functions for solving polynomials.
835// */
836// /// Solves a one-dimensional polynomial for the given coefficients
837// /// @param coefficients vector containing the ordered coefficients
838// /// @param y double value that represents the current input
839// virtual double polyval(const std::vector<double> &coefficients, double y);
840//
841// /// Solves a two-dimensional polynomial for the given coefficients
842// /// @param coefficients vector containing the ordered coefficients
843// /// @param x double value that represents the current input in the 1st dimension
844// /// @param z double value that represents the current output
845// virtual double polyval(const std::vector< std::vector<double> > &coefficients, double x, double z);
846//
847//
848// /** Everything related to the integrated polynomials goes in this
849// * section, holds all the functions for solving polynomials.
850// */
851// /// Solves the indefinite integral of a one-dimensional polynomial
852// /// @param coefficients vector containing the ordered coefficients
853// /// @param y double value that represents the current output
854// virtual double polyint(const std::vector<double> &coefficients, double y);
855//
856// /// Solves the indefinite integral of a two-dimensional polynomial along the 2nd axis (y)
857// /// @param coefficients vector containing the ordered coefficients
858// /// @param x double value that represents the current input in the 1st dimension
859// /// @param z double value that represents the current output
860// virtual double polyint(const std::vector< std::vector<double> > &coefficients, double x, double z);
861//
862//
863// /** Everything related to the derived polynomials goes in this
864// * section, holds all the functions for solving polynomials.
865// */
866// /// Solves the derivative of a one-dimensional polynomial
867// /// @param coefficients vector containing the ordered coefficients
868// /// @param y double value that represents the current output
869// virtual double polyder(const std::vector<double> &coefficients, double y);
870//
871// /// Solves the derivative of a two-dimensional polynomial along the 2nd axis (y)
872// /// @param coefficients vector containing the ordered coefficients
873// /// @param x double value that represents the current input in the 1st dimension
874// /// @param z double value that represents the current output
875// virtual double polyder(const std::vector< std::vector<double> > &coefficients, double x, double z);
876//
877//
878// /** Everything related to the polynomials divided by one variable goes in this
879// * section, holds all the functions for solving polynomials.
880// */
881// /// Solves the indefinite integral of a one-dimensional polynomial divided by its independent variable
882// /// @param coefficients vector containing the ordered coefficients
883// /// @param y double value that represents the current output
884// virtual double polyfracval(const std::vector<double> &coefficients, double y);
885//
886// /// Solves the indefinite integral of a two-dimensional polynomial divided by its 2nd independent variable
887// /// @param coefficients vector containing the ordered coefficients
888// /// @param x double value that represents the current input in the 1st dimension
889// /// @param z double value that represents the current output
890// virtual double polyfracval(const std::vector< std::vector<double> > &coefficients, double x, double z);
891//
892//
893// /** Everything related to the integrated polynomials divided by one variable goes in this
894// * section, holds all the functions for solving polynomials.
895// */
896// /// Solves the indefinite integral of a one-dimensional polynomial divided by its independent variable
897// /// @param coefficients vector containing the ordered coefficients
898// /// @param y double value that represents the current output
899// virtual double polyfracint(const std::vector<double> &coefficients, double y);
900//
901// /// Solves the indefinite integral of a two-dimensional polynomial divided by its 2nd independent variable
902// /// @param coefficients vector containing the ordered coefficients
903// /// @param x double value that represents the current input in the 1st dimension
904// /// @param z double value that represents the current output
905// virtual double polyfracint(const std::vector< std::vector<double> > &coefficients, double x, double z);
906//
907// /// Solves the indefinite integral of a centred one-dimensional polynomial divided by its independent variable
908// /// @param coefficients vector containing the ordered coefficients
909// /// @param y double value that represents the current output
910// /// @param xbase central x-value for fitted function
911// virtual double polyfracintcentral(const std::vector<double> &coefficients, double y, double xbase);
912//
913// /// Solves the indefinite integral of a centred two-dimensional polynomial divided by its 2nd independent variable
914// /// @param coefficients vector containing the ordered coefficients
915// /// @param x double value that represents the current input in the 1st dimension
916// /// @param z double value that represents the current output
917// /// @param ybase central y-value for fitted function
918// virtual double polyfracintcentral(const std::vector< std::vector<double> > &coefficients, double x, double z, double ybase);
919//
920//
921// /** Everything related to the derived polynomials divided by one variable goes in this
922// * section, holds all the functions for solving polynomials.
923// */
924// /// Solves the derivative of a one-dimensional polynomial divided by its independent variable
925// /// @param coefficients vector containing the ordered coefficients
926// /// @param y double value that represents the current output
927// virtual double polyfracder(const std::vector<double> &coefficients, double y);
928//
929// /// Solves the derivative of a two-dimensional polynomial divided by its 2nd independent variable
930// /// @param coefficients vector containing the ordered coefficients
931// /// @param x double value that represents the current input in the 1st dimension
932// /// @param z double value that represents the current output
933// virtual double polyfracder(const std::vector< std::vector<double> > &coefficients, double x, double z);
934//
935// /// Solves the derivative of a centred one-dimensional polynomial divided by its independent variable
936// /// @param coefficients vector containing the ordered coefficients
937// /// @param y double value that represents the current output
938// /// @param xbase central x-value for fitted function
939// virtual double polyfracdercentral(const std::vector<double> &coefficients, double y, double xbase);
940//
941// /// Solves the derivative of a centred two-dimensional polynomial divided by its 2nd independent variable
942// /// @param coefficients vector containing the ordered coefficients
943// /// @param x double value that represents the current input in the 1st dimension
944// /// @param z double value that represents the current output
945// /// @param ybase central y-value for fitted function
946// virtual double polyfracdercentral(const std::vector< std::vector<double> > &coefficients, double x, double z, double ybase);
947//
948//
949// /** Set the solvers and updates either the guess values or the
950// * boundaries for the variable to solve for.
951// */
952// /// Sets the guess value for the Newton solver and enables it.
953// /// @param guess double value that represents the guess value
954// virtual void setGuess(double guess);
955// /// Sets the limits for the Brent solver and enables it.
956// /// @param min double value that represents the lower boundary
957// /// @param max double value that represents the upper boundary
958// virtual void setLimits(double min, double max);
959// /// Solves the equations based on previously defined parameters.
960// /// @param min double value that represents the lower boundary
961// /// @param max double value that represents the upper boundary
962// virtual double solve(PolyResidual &res);
963//};
964//
965//
967//class BaseExponential{
968//
969//protected:
970// BasePolynomial poly;
971// bool POLYMATH_DEBUG;
972//
973//public:
974// BaseExponential();
975// virtual ~BaseExponential(){};
976//
977//public:
978// /// Evaluates an exponential function for the given coefficients
979// /// @param coefficients vector containing the ordered coefficients
980// /// @param x double value that represents the current input
981// /// @param n int value that determines the kind of exponential function
982// double expval(const std::vector<double> &coefficients, double x, int n);
983//
984// /// Evaluates an exponential function for the given coefficients
985// /// @param coefficients vector containing the ordered coefficients
986// /// @param x double value that represents the current input in the 1st dimension
987// /// @param y double value that represents the current input in the 2nd dimension
988// /// @param n int value that determines the kind of exponential function
989// double expval(const std::vector< std::vector<double> > &coefficients, double x, double y, int n);
990//};
991
992}; /* namespace CoolProp */
993#endif