CoolProp  6.6.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 
4 #include "CoolProp.h"
5 #include "CoolPropTools.h"
6 #include "Exceptions.h"
7 
8 #include <vector>
9 #include <string>
10 #include "Solvers.h"
11 #include "MatrixMath.h"
12 #include "unsupported/Eigen/Polynomials"
13 
14 namespace CoolProp {
15 
16 // Just a forward declaration
17 class Poly2DResidual;
18 class Poly2DFracResidual;
19 
21 
25 {
26 
27  public:
30 
32  virtual ~Polynomial2D(){};
33 
34  public:
37  Eigen::MatrixXd convertCoefficients(const std::vector<double>& coefficients) {
38  return vec_to_eigen(coefficients);
39  }
42  Eigen::MatrixXd convertCoefficients(const std::vector<std::vector<double>>& coefficients) {
43  return vec_to_eigen(coefficients);
44  }
45 
47 
52  bool checkCoefficients(const Eigen::MatrixXd& coefficients, const unsigned int rows, const unsigned int columns);
53 
54  public:
56 
67  Eigen::MatrixXd integrateCoeffs(const Eigen::MatrixXd& coefficients, const int& axis, const int& times);
68 
70 
76  Eigen::MatrixXd deriveCoeffs(const Eigen::MatrixXd& coefficients, const int& axis = -1, const int& times = 1);
77 
78  public:
80 
92  double evaluate(const Eigen::MatrixXd& coefficients, const double& x_in);
93 
97  double evaluate(const Eigen::MatrixXd& coefficients, const double& x_in, const double& y_in);
98 
103  double derivative(const Eigen::MatrixXd& coefficients, const double& x_in, const double& y_in, const int& axis);
104 
109  double integral(const Eigen::MatrixXd& coefficients, const double& x_in, const double& y_in, const int& axis);
110 
111  protected:
112  // TODO: Why doe these base definitions not work with derived classes?
117  double solve_limits(Poly2DResidual* res, const double& min, const double& max);
118 
119  // TODO: Why doe these base definitions not work with derived classes?
123  double solve_guess(Poly2DResidual* res, const double& guess);
124 
125  public:
131  Eigen::VectorXd solve(const Eigen::MatrixXd& coefficients, const double& in, const double& z_in, const int& axis);
132 
140  double solve_limits(const Eigen::MatrixXd& coefficients, const double& in, const double& z_in, const double& min, const double& max,
141  const int& axis);
142 
149  double solve_guess(const Eigen::MatrixXd& coefficients, const double& in, const double& z_in, const double& guess, const int& axis);
150 
151  protected:
153 
156  double simplePolynomial(const std::vector<double>& coefficients, double x);
157  DEPRECATED(double simplePolynomial(const std::vector<std::vector<double>>& coefficients, double x, double y));
159 
164  double baseHorner(const std::vector<double>& coefficients, double x);
165  DEPRECATED(double baseHorner(const std::vector<std::vector<double>>& coefficients, double x, double y));
166 
167  bool do_debug(void) {
168  return get_debug_level() >= 500;
169  }
170 };
171 
173 {
174  protected:
175  enum dims
176  {
177  iX,
178  iY
179  };
180  Eigen::MatrixXd coefficients;
181  bool derIsSet;
182  Eigen::MatrixXd coefficientsDer;
183  int axis;
185  double in;
189  double z_in;
190 
191  protected:
193 
194  public:
201  Poly2DResidual(Polynomial2D& poly, const Eigen::MatrixXd& coefficients, const double& in, const double& z_in, const int& axis);
202  virtual ~Poly2DResidual(){};
203 
204  double call(double target);
205  double deriv(double target);
206 };
207 
209 
216 {
217 
218  public:
221 
223  virtual ~Polynomial2DFrac(){};
224 
225  public:
226  // /// Integration functions
227  // /** Integrating coefficients for polynomials is done by dividing the
228  // * original coefficients by (i+1) and elevating the order by 1
229  // * through adding a zero as first coefficient.
230  // * Some reslicing needs to be applied to integrate along the x-axis.
231  // * In the brine/solution equations, reordering of the parameters
232  // * avoids this expensive operation. However, it is included for the
233  // * sake of completeness.
234  // */
235  // /// @param coefficients matrix containing the ordered coefficients
236  // /// @param axis unsigned integer value that represents the desired direction of integration
237  // /// @param times integer value that represents the desired order of integration
238  // /// @param firstExponent integer value that represents the first exponent of the polynomial in axis direction
239  // Eigen::MatrixXd integrateCoeffs(const Eigen::MatrixXd &coefficients, const int &axis, const int &times, const int &firstExponent);
240  //
242 
254  Eigen::MatrixXd deriveCoeffs(const Eigen::MatrixXd& coefficients, const int& axis, const int& times, const int& firstExponent);
255 
256  public:
258 
272  double evaluate(const Eigen::MatrixXd& coefficients, const double& x_in, const int& firstExponent = 0, const double& x_base = 0.0);
273 
281  double evaluate(const Eigen::MatrixXd& coefficients, const double& x_in, const double& y_in, const int& x_exp, const int& y_exp,
282  const double& x_base = 0.0, const double& y_base = 0.0);
283 
292  double derivative(const Eigen::MatrixXd& coefficients, const double& x_in, const double& y_in, const int& axis, const int& x_exp,
293  const int& y_exp, const double& x_base = 0.0, const double& y_base = 0.0);
294 
304  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,
305  const double& x_base = 0.0, const double& y_base = 0.0, const double& ax_val = 0.0);
306 
307  public:
317  Eigen::VectorXd solve(const Eigen::MatrixXd& coefficients, const double& in, const double& z_in, const int& axis, const int& x_exp,
318  const int& y_exp, const double& x_base = 0.0, const double& y_base = 0.0);
319 
331  double solve_limits(const Eigen::MatrixXd& coefficients, const double& in, const double& z_in, const double& min, const double& max,
332  const int& axis, const int& x_exp, const int& y_exp, const double& x_base = 0.0, const double& y_base = 0.0);
333 
344  double solve_guess(const Eigen::MatrixXd& coefficients, const double& in, const double& z_in, const double& guess, const int& axis,
345  const int& x_exp, const int& y_exp, const double& x_base = 0.0, const double& y_base = 0.0);
346 
359  double solve_limitsInt(const Eigen::MatrixXd& coefficients, const double& in, const double& z_in, const double& min, const double& max,
360  const int& axis, const int& x_exp, const int& y_exp, const double& x_base = 0.0, const double& y_base = 0.0,
361  const int& int_axis = 0);
362 
374  double solve_guessInt(const Eigen::MatrixXd& coefficients, const double& in, const double& z_in, const double& guess, const int& axis,
375  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);
376 
377  protected:
379  double factorial(const int& nValue);
380 
383  double binom(const int& nValue, const int& nValue2);
384 
389  Eigen::MatrixXd fracIntCentralDvector(const int& m, const double& x_in, const double& x_base);
390 
395  double fracIntCentral(const Eigen::MatrixXd& coefficients, const double& x_in, const double& x_base);
396 };
397 
399 {
400  protected:
401  int x_exp, y_exp;
402  double x_base, y_base;
405 
406  protected:
408 
409  public:
420  Poly2DFracResidual(Polynomial2DFrac& poly, const Eigen::MatrixXd& coefficients, const double& in, const double& z_in, const int& axis,
421  const int& x_exp, const int& y_exp, const double& x_base, const double& y_base);
422  virtual ~Poly2DFracResidual(){};
423  double call(double target);
424  double deriv(double target);
425 };
426 
428 {
429 
430  protected:
431  int int_axis;
433 
434  public:
446  Poly2DFracIntResidual(Polynomial2DFrac& poly, const Eigen::MatrixXd& coefficients, const double& in, const double& z_in, const int& axis,
447  const int& x_exp, const int& y_exp, const double& x_base, const double& y_base, const int& int_axis);
449  double call(double target);
450  double deriv(double target);
451 };
452 
453 //
454 //
455 //
456 //
457 //
458 //
459 //
460 //
461 //
463 //class BasePolynomial{
464 //
465 //public:
466 // // Constructor
467 // BasePolynomial();
468 // // Destructor. No implementation
469 // virtual ~BasePolynomial(){};
470 //
471 //public:
472 // /// Basic checks for coefficient vectors.
473 // /** Starts with only the first coefficient dimension
474 // * and checks the vector length against parameter n. */
475 // bool checkCoefficients(const Eigen::VectorXd &coefficients, const unsigned int n);
476 // bool checkCoefficients(const Eigen::MatrixXd &coefficients, const unsigned int rows, const unsigned int columns);
477 // bool checkCoefficients(const std::vector<double> &coefficients, const unsigned int n);
478 // bool checkCoefficients(const std::vector< std::vector<double> > &coefficients, const unsigned int rows, const unsigned int columns);
479 //
480 // /** Integrating coefficients for polynomials is done by dividing the
481 // * original coefficients by (i+1) and elevating the order by 1
482 // * through adding a zero as first coefficient.
483 // * Some reslicing needs to be applied to integrate along the x-axis.
484 // * In the brine/solution equations, reordering of the parameters
485 // * avoids this expensive operation. However, it is included for the
486 // * sake of completeness.
487 // */
488 // std::vector<double> integrateCoeffs(const std::vector<double> &coefficients);
489 // std::vector< std::vector<double> > integrateCoeffs(const std::vector< std::vector<double> > &coefficients, bool axis);
490 //
491 // /** Deriving coefficients for polynomials is done by multiplying the
492 // * original coefficients with i and lowering the order by 1.
493 // *
494 // * It is not really deprecated, but untested and therefore a warning
495 // * is issued. Please check this method before you use it.
496 // */
497 // std::vector<double> deriveCoeffs(const std::vector<double> &coefficients);
498 // std::vector< std::vector<double> > deriveCoeffs(const std::vector< std::vector<double> > &coefficients, unsigned int axis);
499 //
500 //private:
501 // /** The core of the polynomial wrappers are the different
502 // * implementations that follow below. In case there are
503 // * new calculation schemes available, please do not delete
504 // * the implementations, but mark them as deprecated.
505 // * The old functions are good for debugging since the
506 // * structure is easier to read than the backward Horner-scheme
507 // * or the recursive Horner-scheme.
508 // */
509 //
510 // /// Simple polynomial function generator. <- Deprecated due to poor performance, use Horner-scheme instead
511 // /** Base function to produce n-th order polynomials
512 // * based on the length of the coefficient vector.
513 // * Starts with only the first coefficient at x^0. */
514 // DEPRECATED(double simplePolynomial(const std::vector<double> &coefficients, double x));
515 // DEPRECATED(double simplePolynomial(const std::vector<std::vector<double> > &coefficients, double x, double y));
516 //
517 // /// Simple integrated polynomial function generator.
518 // /** Base function to produce integrals of n-th order polynomials based on
519 // * the length of the coefficient vector.
520 // * Starts with only the first coefficient at x^0 */
521 // ///Indefinite integral in x-direction
522 // double simplePolynomialInt(const std::vector<double> &coefficients, double x);
523 // ///Indefinite integral in y-direction only
524 // double simplePolynomialInt(const std::vector<std::vector<double> > &coefficients, double x, double y);
525 //
526 // /// Simple integrated polynomial function generator divided by independent variable.
527 // /** Base function to produce integrals of n-th order
528 // * polynomials based on the length of the coefficient
529 // * vector. Starts with only the first coefficient at x^0 */
530 // ///Indefinite integral of a polynomial divided by its independent variable
531 // double simpleFracInt(const std::vector<double> &coefficients, double x);
532 // ///Indefinite integral of a polynomial divided by its 2nd independent variable
533 // double simpleFracInt(const std::vector<std::vector<double> > &coefficients, double x, double y);
534 //
535 // /** Simple integrated centred(!) polynomial function generator divided by independent variable.
536 // * We need to rewrite some of the functions in order to
537 // * use central fit. Having a central temperature xbase
538 // * allows for a better fit, but requires a different
539 // * formulation of the fracInt function group. Other
540 // * functions are not affected.
541 // * Starts with only the first coefficient at x^0 */
542 // ///Helper function to calculate the D vector:
543 // double factorial(double nValue);
544 // double binom(double nValue, double nValue2);
545 // std::vector<double> fracIntCentralDvector(int m, double x, double xbase);
546 // ///Indefinite integral of a centred polynomial divided by its independent variable
547 // double fracIntCentral(const std::vector<double> &coefficients, double x, double xbase);
548 //
549 // /// Horner function generator implementations
550 // /** Represent polynomials according to Horner's scheme.
551 // * This avoids unnecessary multiplication and thus
552 // * speeds up calculation.
553 // */
554 // double baseHorner(const std::vector<double> &coefficients, double x);
555 // double baseHorner(const std::vector< std::vector<double> > &coefficients, double x, double y);
556 // ///Indefinite integral in x-direction
557 // double baseHornerInt(const std::vector<double> &coefficients, double x);
558 // ///Indefinite integral in y-direction only
559 // double baseHornerInt(const std::vector<std::vector<double> > &coefficients, double x, double y);
560 // ///Indefinite integral of a polynomial divided by its independent variable
561 // double baseHornerFracInt(const std::vector<double> &coefficients, double x);
562 // ///Indefinite integral of a polynomial divided by its 2nd independent variable
563 // double baseHornerFracInt(const std::vector<std::vector<double> > &coefficients, double x, double y);
564 //
565 // /** Alternatives
566 // * Simple functions that heavily rely on other parts of this file.
567 // * We still need to check which combinations yield the best
568 // * performance.
569 // */
570 // ///Derivative in x-direction
571 // double deriveIn2Steps(const std::vector<double> &coefficients, double x); // TODO: Check results!
572 // ///Derivative in terms of x(axis=true) or y(axis=false).
573 // double deriveIn2Steps(const std::vector< std::vector<double> > &coefficients, double x, double y, bool axis); // TODO: Check results!
574 // ///Indefinite integral in x-direction
575 // double integrateIn2Steps(const std::vector<double> &coefficients, double x);
576 // ///Indefinite integral in terms of x(axis=true) or y(axis=false).
577 // double integrateIn2Steps(const std::vector< std::vector<double> > &coefficients, double x, double y, bool axis);
578 // ///Indefinite integral in x-direction of a polynomial divided by its independent variable
579 // double fracIntIn2Steps(const std::vector<double> &coefficients, double x);
580 // ///Indefinite integral in y-direction of a polynomial divided by its 2nd independent variable
581 // double fracIntIn2Steps(const std::vector<std::vector<double> > &coefficients, double x, double y);
582 // ///Indefinite integral of a centred polynomial divided by its 2nd independent variable
583 // double fracIntCentral2Steps(const std::vector<std::vector<double> > &coefficients, double x, double y, double ybase);
584 //
585 //public:
586 // /** Here we define the functions that should be used by the
587 // * respective implementations. Please do no use any other
588 // * method since this would break the purpose of this interface.
589 // * Note that the functions below are supposed to be aliases
590 // * to implementations declared elsewhere in this file.
591 // */
592 //
593 // /** Everything related to the normal polynomials goes in this
594 // * section, holds all the functions for evaluating polynomials.
595 // */
596 // /// Evaluates a one-dimensional polynomial for the given coefficients
597 // /// @param coefficients vector containing the ordered coefficients
598 // /// @param x double value that represents the current input
599 // virtual inline double polyval(const std::vector<double> &coefficients, double x){
600 // return baseHorner(coefficients,x);
601 // }
602 //
603 // /// Evaluates a two-dimensional polynomial for the given coefficients
604 // /// @param coefficients vector containing the ordered coefficients
605 // /// @param x double value that represents the current input in the 1st dimension
606 // /// @param y double value that represents the current input in the 2nd dimension
607 // virtual inline double polyval(const std::vector< std::vector<double> > &coefficients, double x, double y){
608 // return baseHorner(coefficients,x,y);
609 // }
610 //
611 //
612 // /** Everything related to the integrated polynomials goes in this
613 // * section, holds all the functions for evaluating polynomials.
614 // */
615 // /// Evaluates the indefinite integral of a one-dimensional polynomial
616 // /// @param coefficients vector containing the ordered coefficients
617 // /// @param x double value that represents the current input
618 // virtual inline double polyint(const std::vector<double> &coefficients, double x){
619 // return baseHornerInt(coefficients,x);
620 // }
621 //
622 // /// Evaluates the indefinite integral of a two-dimensional polynomial along the 2nd axis (y)
623 // /// @param coefficients vector containing the ordered coefficients
624 // /// @param x double value that represents the current input in the 1st dimension
625 // /// @param y double value that represents the current input in the 2nd dimension
626 // virtual inline double polyint(const std::vector< std::vector<double> > &coefficients, double x, double y){
627 // return baseHornerInt(coefficients,x,y);
628 // }
629 //
630 //
631 // /** Everything related to the derived polynomials goes in this
632 // * section, holds all the functions for evaluating polynomials.
633 // */
634 // /// Evaluates the derivative of a one-dimensional polynomial
635 // /// @param coefficients vector containing the ordered coefficients
636 // /// @param x double value that represents the current input
637 // virtual inline double polyder(const std::vector<double> &coefficients, double x){
638 // return deriveIn2Steps(coefficients,x);
639 // }
640 //
641 // /// Evaluates the derivative of a two-dimensional polynomial along the 2nd axis (y)
642 // /// @param coefficients vector containing the ordered coefficients
643 // /// @param x double value that represents the current input in the 1st dimension
644 // /// @param y double value that represents the current input in the 2nd dimension
645 // virtual inline double polyder(const std::vector< std::vector<double> > &coefficients, double x, double y){
646 // return deriveIn2Steps(coefficients,x,y,false);
647 // }
648 //
649 //
650 // /** Everything related to the polynomials divided by one variable goes in this
651 // * section, holds all the functions for evaluating polynomials.
652 // */
653 // /// Evaluates the indefinite integral of a one-dimensional polynomial divided by its independent variable
654 // /// @param coefficients vector containing the ordered coefficients
655 // /// @param x double value that represents the current position
656 // virtual inline double polyfracval(const std::vector<double> &coefficients, double x){
657 // return baseHorner(coefficients,x)/x;
658 // }
659 //
660 // /// Evaluates the indefinite integral of a two-dimensional polynomial divided by its 2nd independent variable
661 // /// @param coefficients vector containing the ordered coefficients
662 // /// @param x double value that represents the current input in the 1st dimension
663 // /// @param y double value that represents the current input in the 2nd dimension
664 // virtual inline double polyfracval(const std::vector< std::vector<double> > &coefficients, double x, double y){
665 // return baseHorner(coefficients,x,y)/y;
666 // }
667 //
668 //
669 // /** Everything related to the integrated polynomials divided by one variable goes in this
670 // * section, holds all the functions for solving polynomials.
671 // */
672 // /// Evaluates the indefinite integral of a one-dimensional polynomial divided by its independent variable
673 // /// @param coefficients vector containing the ordered coefficients
674 // /// @param x double value that represents the current position
675 // virtual inline double polyfracint(const std::vector<double> &coefficients, double x){
676 // return baseHornerFracInt(coefficients,x);
677 // }
678 //
679 // /// Evaluates the indefinite integral of a two-dimensional polynomial divided by its 2nd independent variable
680 // /// @param coefficients vector containing the ordered coefficients
681 // /// @param x double value that represents the current input in the 1st dimension
682 // /// @param y double value that represents the current input in the 2nd dimension
683 // virtual inline double polyfracint(const std::vector< std::vector<double> > &coefficients, double x, double y){
684 // return baseHornerFracInt(coefficients,x,y);
685 // }
686 //
687 // /// Evaluates the indefinite integral of a centred one-dimensional polynomial divided by its independent variable
688 // /// @param coefficients vector containing the ordered coefficients
689 // /// @param x double value that represents the current position
690 // /// @param xbase central temperature for fitted function
691 // virtual inline double polyfracintcentral(const std::vector<double> &coefficients, double x, double xbase){
692 // return fracIntCentral(coefficients,x,xbase);
693 // }
694 //
695 // /// Evaluates the indefinite integral of a centred two-dimensional polynomial divided by its 2nd independent variable
696 // /// @param coefficients vector containing the ordered coefficients
697 // /// @param x double value that represents the current input in the 1st dimension
698 // /// @param y double value that represents the current input in the 2nd dimension
699 // /// @param ybase central temperature for fitted function
700 // virtual inline double polyfracintcentral(const std::vector< std::vector<double> > &coefficients, double x, double y, double ybase){
701 // return fracIntCentral2Steps(coefficients,x,y,ybase);
702 // }
703 //
704 //
705 // /** Everything related to the derived polynomials divided by one variable goes in this
706 // * section, holds all the functions for solving polynomials.
707 // */
708 // /// Evaluates the derivative of a one-dimensional polynomial divided by its independent variable
709 // /// @param coefficients vector containing the ordered coefficients
710 // /// @param x double value that represents the current position
711 // virtual inline double polyfracder(const std::vector<double> &coefficients, double x){
712 // throw CoolProp::NotImplementedError("Derivatives of polynomials divided by their independent variable have not been implemented."); // TODO: Implement polyfracder1D
713 // }
714 //
715 // /// Evaluates the derivative of a two-dimensional polynomial divided by its 2nd independent variable
716 // /// @param coefficients vector containing the ordered coefficients
717 // /// @param x double value that represents the current input in the 1st dimension
718 // /// @param y double value that represents the current input in the 2nd dimension
719 // virtual inline double polyfracder(const std::vector< std::vector<double> > &coefficients, double x, double y){
720 // throw CoolProp::NotImplementedError("Derivatives of polynomials divided by their independent variable have not been implemented."); // TODO: Implement polyfracder2D
721 // }
722 //
723 // /// Evaluates the derivative of a centred one-dimensional polynomial divided by its independent variable
724 // /// @param coefficients vector containing the ordered coefficients
725 // /// @param x double value that represents the current position
726 // /// @param xbase central temperature for fitted function
727 // virtual inline double polyfracdercentral(const std::vector<double> &coefficients, double x, double xbase){
728 // throw CoolProp::NotImplementedError("Derivatives of polynomials divided by their independent variable have not been implemented."); // TODO: Implement polyfracdercentral1D
729 // }
730 //
731 // /// Evaluates the derivative of a centred two-dimensional polynomial divided by its 2nd independent variable
732 // /// @param coefficients vector containing the ordered coefficients
733 // /// @param x double value that represents the current input in the 1st dimension
734 // /// @param y double value that represents the current input in the 2nd dimension
735 // /// @param ybase central temperature for fitted function
736 // virtual inline double polyfracdercentral(const std::vector< std::vector<double> > &coefficients, double x, double y, double ybase){
737 // throw CoolProp::NotImplementedError("Derivatives of polynomials divided by their independent variable have not been implemented."); // TODO: Implement polyfracdercentral2D
738 // }
739 //};
740 //
741 //
742 //
743 //
745 // * used by the solvers.
746 // * TODO: Make multidimensional
747 // */
748 //class PolyResidual : public FuncWrapper1D {
749 //protected:
750 // enum dims {i1D, i2D};
751 // /// Object that evaluates the equation
752 // BasePolynomial poly;
753 // /// Current output value
754 // double output, firstDim;
755 // int dim;
756 // std::vector< std::vector<double> > coefficients;
757 //private:
758 // PolyResidual();
759 //public:
760 // PolyResidual(const std::vector<double> &coefficients, double y);
761 // PolyResidual(const std::vector< std::vector<double> > &coefficients, double x, double z);
762 // virtual ~PolyResidual(){};
763 // bool is2D(){return (this->dim==i2D);};
764 // virtual double call(double x);
765 // virtual double deriv(double x);
766 //};
767 //class PolyIntResidual : public PolyResidual {
768 //public:
769 // PolyIntResidual(const std::vector<double> &coefficients, double y):PolyResidual(coefficients, y){};
770 // PolyIntResidual(const std::vector< std::vector<double> > &coefficients, double x, double z):PolyResidual(coefficients, x, z){};
771 // virtual double call(double x);
772 // virtual double deriv(double x);
773 //};
774 //class PolyFracIntResidual : public PolyResidual {
775 //public:
776 // PolyFracIntResidual(const std::vector<double> &coefficients, double y):PolyResidual(coefficients, y){};
777 // PolyFracIntResidual(const std::vector< std::vector<double> > &coefficients, double x, double z):PolyResidual(coefficients, x, z){};
778 // virtual double call(double x);
779 // virtual double deriv(double x);
780 //};
781 //class PolyFracIntCentralResidual : public PolyResidual {
782 //protected:
783 // double baseVal;
784 //public:
785 // PolyFracIntCentralResidual(const std::vector<double> &coefficients, double y, double xBase):PolyResidual(coefficients, y){this->baseVal = xBase;};
786 // PolyFracIntCentralResidual(const std::vector< std::vector<double> > &coefficients, double x, double z, double yBase): PolyResidual(coefficients, x, z){this->baseVal = yBase;};
787 // virtual double call(double x);
788 // virtual double deriv(double x);
789 //};
790 //class PolyDerResidual : public PolyResidual {
791 //public:
792 // PolyDerResidual(const std::vector<double> &coefficients, double y):PolyResidual(coefficients, y){};
793 // PolyDerResidual(const std::vector< std::vector<double> > &coefficients, double x, double z):PolyResidual(coefficients, x, z){};
794 // virtual double call(double x);
795 // virtual double deriv(double x);
796 //};
797 //
798 //
799 //
800 //
802 // * but solves the polynomial for the given value
803 // * instead of evaluating it.
804 // * TODO: This class does not check for bijective
805 // * polynomials and is therefore a little
806 // * fragile.
807 // */
808 //class PolynomialSolver : public BasePolynomial{
809 //private:
810 // enum solvers {iNewton, iBrent};
811 // int uses;
812 // double guess, min, max;
813 // double macheps, tol;
814 // int maxiter;
815 //
816 //public:
817 // // Constructor
818 // PolynomialSolver();
819 // // Destructor. No implementation
820 // virtual ~PolynomialSolver(){};
821 //
822 //public:
823 // /** Here we redefine the functions that solve the polynomials.
824 // * These implementations all use the base class to evaluate
825 // * the polynomial during the solution process.
826 // */
827 //
828 // /** Everything related to the normal polynomials goes in this
829 // * section, holds all the functions for solving polynomials.
830 // */
831 // /// Solves a one-dimensional polynomial for the given coefficients
832 // /// @param coefficients vector containing the ordered coefficients
833 // /// @param y double value that represents the current input
834 // virtual double polyval(const std::vector<double> &coefficients, double y);
835 //
836 // /// Solves a two-dimensional polynomial for the given coefficients
837 // /// @param coefficients vector containing the ordered coefficients
838 // /// @param x double value that represents the current input in the 1st dimension
839 // /// @param z double value that represents the current output
840 // virtual double polyval(const std::vector< std::vector<double> > &coefficients, double x, double z);
841 //
842 //
843 // /** Everything related to the integrated polynomials goes in this
844 // * section, holds all the functions for solving polynomials.
845 // */
846 // /// Solves the indefinite integral of a one-dimensional polynomial
847 // /// @param coefficients vector containing the ordered coefficients
848 // /// @param y double value that represents the current output
849 // virtual double polyint(const std::vector<double> &coefficients, double y);
850 //
851 // /// Solves the indefinite integral of a two-dimensional polynomial along the 2nd axis (y)
852 // /// @param coefficients vector containing the ordered coefficients
853 // /// @param x double value that represents the current input in the 1st dimension
854 // /// @param z double value that represents the current output
855 // virtual double polyint(const std::vector< std::vector<double> > &coefficients, double x, double z);
856 //
857 //
858 // /** Everything related to the derived polynomials goes in this
859 // * section, holds all the functions for solving polynomials.
860 // */
861 // /// Solves the derivative of a one-dimensional polynomial
862 // /// @param coefficients vector containing the ordered coefficients
863 // /// @param y double value that represents the current output
864 // virtual double polyder(const std::vector<double> &coefficients, double y);
865 //
866 // /// Solves the derivative of a two-dimensional polynomial along the 2nd axis (y)
867 // /// @param coefficients vector containing the ordered coefficients
868 // /// @param x double value that represents the current input in the 1st dimension
869 // /// @param z double value that represents the current output
870 // virtual double polyder(const std::vector< std::vector<double> > &coefficients, double x, double z);
871 //
872 //
873 // /** Everything related to the polynomials divided by one variable goes in this
874 // * section, holds all the functions for solving polynomials.
875 // */
876 // /// Solves the indefinite integral of a one-dimensional polynomial divided by its independent variable
877 // /// @param coefficients vector containing the ordered coefficients
878 // /// @param y double value that represents the current output
879 // virtual double polyfracval(const std::vector<double> &coefficients, double y);
880 //
881 // /// Solves the indefinite integral of a two-dimensional polynomial divided by its 2nd independent variable
882 // /// @param coefficients vector containing the ordered coefficients
883 // /// @param x double value that represents the current input in the 1st dimension
884 // /// @param z double value that represents the current output
885 // virtual double polyfracval(const std::vector< std::vector<double> > &coefficients, double x, double z);
886 //
887 //
888 // /** Everything related to the integrated polynomials divided by one variable goes in this
889 // * section, holds all the functions for solving polynomials.
890 // */
891 // /// Solves the indefinite integral of a one-dimensional polynomial divided by its independent variable
892 // /// @param coefficients vector containing the ordered coefficients
893 // /// @param y double value that represents the current output
894 // virtual double polyfracint(const std::vector<double> &coefficients, double y);
895 //
896 // /// Solves the indefinite integral of a two-dimensional polynomial divided by its 2nd independent variable
897 // /// @param coefficients vector containing the ordered coefficients
898 // /// @param x double value that represents the current input in the 1st dimension
899 // /// @param z double value that represents the current output
900 // virtual double polyfracint(const std::vector< std::vector<double> > &coefficients, double x, double z);
901 //
902 // /// Solves the indefinite integral of a centred one-dimensional polynomial divided by its independent variable
903 // /// @param coefficients vector containing the ordered coefficients
904 // /// @param y double value that represents the current output
905 // /// @param xbase central x-value for fitted function
906 // virtual double polyfracintcentral(const std::vector<double> &coefficients, double y, double xbase);
907 //
908 // /// Solves the indefinite integral of a centred two-dimensional polynomial divided by its 2nd independent variable
909 // /// @param coefficients vector containing the ordered coefficients
910 // /// @param x double value that represents the current input in the 1st dimension
911 // /// @param z double value that represents the current output
912 // /// @param ybase central y-value for fitted function
913 // virtual double polyfracintcentral(const std::vector< std::vector<double> > &coefficients, double x, double z, double ybase);
914 //
915 //
916 // /** Everything related to the derived polynomials divided by one variable goes in this
917 // * section, holds all the functions for solving polynomials.
918 // */
919 // /// Solves the derivative of a one-dimensional polynomial divided by its independent variable
920 // /// @param coefficients vector containing the ordered coefficients
921 // /// @param y double value that represents the current output
922 // virtual double polyfracder(const std::vector<double> &coefficients, double y);
923 //
924 // /// Solves the derivative of a two-dimensional polynomial divided by its 2nd independent variable
925 // /// @param coefficients vector containing the ordered coefficients
926 // /// @param x double value that represents the current input in the 1st dimension
927 // /// @param z double value that represents the current output
928 // virtual double polyfracder(const std::vector< std::vector<double> > &coefficients, double x, double z);
929 //
930 // /// Solves the derivative of a centred one-dimensional polynomial divided by its independent variable
931 // /// @param coefficients vector containing the ordered coefficients
932 // /// @param y double value that represents the current output
933 // /// @param xbase central x-value for fitted function
934 // virtual double polyfracdercentral(const std::vector<double> &coefficients, double y, double xbase);
935 //
936 // /// Solves the derivative of a centred two-dimensional polynomial divided by its 2nd independent variable
937 // /// @param coefficients vector containing the ordered coefficients
938 // /// @param x double value that represents the current input in the 1st dimension
939 // /// @param z double value that represents the current output
940 // /// @param ybase central y-value for fitted function
941 // virtual double polyfracdercentral(const std::vector< std::vector<double> > &coefficients, double x, double z, double ybase);
942 //
943 //
944 // /** Set the solvers and updates either the guess values or the
945 // * boundaries for the variable to solve for.
946 // */
947 // /// Sets the guess value for the Newton solver and enables it.
948 // /// @param guess double value that represents the guess value
949 // virtual void setGuess(double guess);
950 // /// Sets the limits for the Brent solver and enables it.
951 // /// @param min double value that represents the lower boundary
952 // /// @param max double value that represents the upper boundary
953 // virtual void setLimits(double min, double max);
954 // /// Solves the equations based on previously defined parameters.
955 // /// @param min double value that represents the lower boundary
956 // /// @param max double value that represents the upper boundary
957 // virtual double solve(PolyResidual &res);
958 //};
959 //
960 //
962 //class BaseExponential{
963 //
964 //protected:
965 // BasePolynomial poly;
966 // bool POLYMATH_DEBUG;
967 //
968 //public:
969 // BaseExponential();
970 // virtual ~BaseExponential(){};
971 //
972 //public:
973 // /// Evaluates an exponential function for the given coefficients
974 // /// @param coefficients vector containing the ordered coefficients
975 // /// @param x double value that represents the current input
976 // /// @param n int value that determines the kind of exponential function
977 // double expval(const std::vector<double> &coefficients, double x, int n);
978 //
979 // /// Evaluates an exponential function for the given coefficients
980 // /// @param coefficients vector containing the ordered coefficients
981 // /// @param x double value that represents the current input in the 1st dimension
982 // /// @param y double value that represents the current input in the 2nd dimension
983 // /// @param n int value that determines the kind of exponential function
984 // double expval(const std::vector< std::vector<double> > &coefficients, double x, double y, int n);
985 //};
986 
987 }; /* namespace CoolProp */
988 #endif