Repository navigation
Expand file tree
/
Copy pathPolyMath.h
More file actions
974 lines (915 loc) · 54.7 KB
/
Copy pathPolyMath.h
File metadata and controls
974 lines (915 loc) · 54.7 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
#ifndef POLYMATH_H
#define POLYMATH_H
#include "CoolProp.h"
#include "CoolPropTools.h"
#include "Exceptions.h"
#include <vector>
#include <string>
#include "Solvers.h"
#include "MatrixMath.h"
#include "unsupported/Eigen/Polynomials"
namespace CoolProp{
// Just a forward declaration
class Poly2DResidual;
class Poly2DFracResidual;
/// The base class for all Polynomials
/** A clear and straight forward implementation of polynomial operations. Still
* very basic, but serves its purpose.
*/
class Polynomial2D {
public:
/// Constructors
Polynomial2D(){};
/// Destructor. No implementation
virtual ~Polynomial2D(){};
public:
/// Convert the coefficient vector.
/// @param coefficients vector containing the ordered coefficients
Eigen::MatrixXd convertCoefficients(const std::vector<double> &coefficients){return vec_to_eigen(coefficients);}
/// Convert the coefficient matrix.
/// @param coefficients matrix containing the ordered coefficients
Eigen::MatrixXd convertCoefficients(const std::vector<std::vector<double> > &coefficients){return vec_to_eigen(coefficients);}
/// Basic checks for coefficient vectors.
/** Starts with only the first coefficient dimension
* and checks the matrix size against the parameters rows and columns. */
/// @param coefficients matrix containing the ordered coefficients
/// @param rows unsigned integer value that represents the desired degree of the polynomial in the 1st dimension
/// @param columns unsigned integer value that represents the desired degree of the polynomial in the 2nd dimension
bool checkCoefficients(const Eigen::MatrixXd &coefficients, const unsigned int rows, const unsigned int columns);
public:
/// Integration functions
/** Integrating coefficients for polynomials is done by dividing the
* original coefficients by (i+1) and elevating the order by 1
* through adding a zero as first coefficient.
* Some reslicing needs to be applied to integrate along the x-axis.
* In the brine/solution equations, reordering of the parameters
* avoids this expensive operation. However, it is included for the
* sake of completeness.
*/
/// @param coefficients matrix containing the ordered coefficients
/// @param axis unsigned integer value that represents the desired direction of integration
/// @param times integer value that represents the desired order of integration
Eigen::MatrixXd integrateCoeffs(const Eigen::MatrixXd &coefficients, const int &axis, const int ×);
/// Derivative coefficients calculation
/** Deriving coefficients for polynomials is done by multiplying the
* original coefficients with i and lowering the order by 1.
*/
/// @param coefficients matrix containing the ordered coefficients
/// @param axis unsigned integer value that represents the desired direction of derivation
/// @param times integer value that represents the desired order of derivation
Eigen::MatrixXd deriveCoeffs(const Eigen::MatrixXd &coefficients, const int &axis=-1, const int ×=1);
public:
/// The core functions to evaluate the polynomial
/** It is here we implement the different special
* functions that allow us to specify certain
* types of polynomials.
*
* Try to avoid many calls to the derivative and integral functions.
* Both of them have to calculate the new coefficients internally,
* which slows things down. Instead, you should use the deriveCoeffs
* and integrateCoeffs functions and store the coefficient matrix
* you need for future calls to evaluate derivative and integral.
*/
/// @param coefficients vector containing the ordered coefficients
/// @param x_in double value that represents the current input in the 1st dimension
double evaluate(const Eigen::MatrixXd &coefficients, const double &x_in);
/// @param coefficients vector containing the ordered coefficients
/// @param x_in double value that represents the current input in the 1st dimension
/// @param y_in double value that represents the current input in the 2nd dimension
double evaluate(const Eigen::MatrixXd &coefficients, const double &x_in, const double &y_in);
/// @param coefficients vector containing the ordered coefficients
/// @param x_in double value that represents the current input in the 1st dimension
/// @param y_in double value that represents the current input in the 2nd dimension
/// @param axis unsigned integer value that represents the axis to derive for (0=x, 1=y)
double derivative(const Eigen::MatrixXd &coefficients, const double &x_in, const double &y_in, const int &axis);
/// @param coefficients vector containing the ordered coefficients
/// @param x_in double value that represents the current input in the 1st dimension
/// @param y_in double value that represents the current input in the 2nd dimension
/// @param axis unsigned integer value that represents the axis to integrate for (0=x, 1=y)
double integral(const Eigen::MatrixXd &coefficients, const double &x_in, const double &y_in, const int &axis);
protected:
// TODO: Why doe these base definitions not work with derived classes?
/// Uses the Brent solver to find the roots of p(x_in,y_in)-z_in
/// @param res Poly2DResidual object to calculate residuals and derivatives
/// @param min double value that represents the minimum value
/// @param max double value that represents the maximum value
double solve_limits(Poly2DResidual* res, const double &min, const double &max);
// TODO: Why doe these base definitions not work with derived classes?
/// Uses the Newton solver to find the roots of p(x_in,y_in)-z_in
/// @param res Poly2DResidual object to calculate residuals and derivatives
/// @param guess double value that represents the start value
double solve_guess(Poly2DResidual* res, const double &guess);
public:
/// Returns a vector with ALL the real roots of p(x_in,y_in)-z_in
/// @param coefficients vector containing the ordered coefficients
/// @param in double value that represents the current input in x (1st dimension) or y (2nd dimension)
/// @param z_in double value that represents the current output in the 3rd dimension
/// @param axis unsigned integer value that represents the axis to solve for (0=x, 1=y)
Eigen::VectorXd solve(const Eigen::MatrixXd &coefficients, const double &in, const double &z_in, const int &axis);
/// Uses the Brent solver to find the roots of p(x_in,y_in)-z_in
/// @param coefficients vector containing the ordered coefficients
/// @param in double value that represents the current input in x (1st dimension) or y (2nd dimension)
/// @param z_in double value that represents the current output in the 3rd dimension
/// @param min double value that represents the minimum value
/// @param max double value that represents the maximum value
/// @param axis unsigned integer value that represents the axis to solve for (0=x, 1=y)
double solve_limits(const Eigen::MatrixXd &coefficients, const double &in, const double &z_in, const double &min, const double &max, const int &axis);
/// Uses the Newton solver to find the roots of p(x_in,y_in)-z_in
/// @param coefficients vector containing the ordered coefficients
/// @param in double value that represents the current input in x (1st dimension) or y (2nd dimension)
/// @param z_in double value that represents the current output in the 3rd dimension
/// @param guess double value that represents the start value
/// @param axis unsigned integer value that represents the axis to solve for (0=x, 1=y)
double solve_guess(const Eigen::MatrixXd &coefficients, const double &in, const double &z_in, const double &guess, const int &axis);
protected:
/// Simple polynomial function generator. <- Deprecated due to poor performance, use Horner-scheme instead
/** Base function to produce n-th order polynomials
* based on the length of the coefficient vector.
* Starts with only the first coefficient at x^0. */
double simplePolynomial(const std::vector<double> &coefficients, double x);
DEPRECATED(double simplePolynomial(const std::vector<std::vector<double> > &coefficients, double x, double y));
/// Horner function generator implementations
/** Represent polynomials according to Horner's scheme.
* This avoids unnecessary multiplication and thus
* speeds up calculation.
* Deprecated since we moved everything to the Eigen framework.
*/
double baseHorner(const std::vector<double> &coefficients, double x);
DEPRECATED(double baseHorner(const std::vector<std::vector<double> > &coefficients, double x, double y));
bool do_debug(void){return get_debug_level()>=500;}
};
class Poly2DResidual : public FuncWrapper1D {
protected:
enum dims {iX, iY};
Eigen::MatrixXd coefficients;
bool derIsSet;
Eigen::MatrixXd coefficientsDer;
int axis;
/// the fixed input != targetDim
double in;
/// Object that evaluates the equation
Polynomial2D poly;
/// Current output value
double z_in;
protected:
Poly2DResidual();
public:
/// Residual of a polynomial
/// @param poly polynomial object used to evaluate the calls
/// @param coefficients
/// @param in double value that represents the current input in x (1st dimension) or y (2nd dimension)
/// @param z_in double value that represents the current output in the 3rd dimension
/// @param axis unsigned integer value that represents the axis to solve for (0=x, 1=y)
Poly2DResidual(Polynomial2D &poly, const Eigen::MatrixXd &coefficients, const double &in, const double &z_in, const int &axis);
virtual ~Poly2DResidual(){};
double call(double target);
double deriv(double target);
};
/// A class for polynomials starting at an arbitrary degree.
/** It is implemented for the incompressibles and is a little messy, but seems to
* work fine for now. Besides handling arbitrary starting exponents for the
* polynomials, it can also calculate polynomials with a base value. This means
* that the independent variable no longer is x, but (x-x_base). For fitted
* functions, we often see such a design to enhance the fit quality/stability.
*/
class Polynomial2DFrac : public Polynomial2D {
public:
/// Constructors
Polynomial2DFrac(){};
/// Destructor. No implementation
virtual ~Polynomial2DFrac(){};
public:
// /// Integration functions
// /** Integrating coefficients for polynomials is done by dividing the
// * original coefficients by (i+1) and elevating the order by 1
// * through adding a zero as first coefficient.
// * Some reslicing needs to be applied to integrate along the x-axis.
// * In the brine/solution equations, reordering of the parameters
// * avoids this expensive operation. However, it is included for the
// * sake of completeness.
// */
// /// @param coefficients matrix containing the ordered coefficients
// /// @param axis unsigned integer value that represents the desired direction of integration
// /// @param times integer value that represents the desired order of integration
// /// @param firstExponent integer value that represents the first exponent of the polynomial in axis direction
// Eigen::MatrixXd integrateCoeffs(const Eigen::MatrixXd &coefficients, const int &axis, const int ×, const int &firstExponent);
//
/// Derivative coefficients calculation
/** Deriving coefficients for polynomials is done by multiplying the
* original coefficients with i and lowering the order by 1.
*
* Remember that the first exponent might need to be adjusted after derivation.
* It has to be lowered by times:
* derCoeffs = deriveCoeffs(coefficients, axis, times, firstExponent);
* firstExponent -= times;
*/
/// @param coefficients matrix containing the ordered coefficients
/// @param axis unsigned integer value that represents the desired direction of derivation
/// @param times integer value that represents the desired order of derivation
/// @param firstExponent integer value that represents the lowest exponent of the polynomial in axis direction
Eigen::MatrixXd deriveCoeffs(const Eigen::MatrixXd &coefficients, const int &axis, const int ×, const int &firstExponent);
public:
/// The core functions to evaluate the polynomial
/** It is here we implement the different special
* functions that allow us to specify certain
* types of polynomials.
*
* Try to avoid many calls to the derivative and integral functions.
* Both of them have to calculate the new coefficients internally,
* which slows things down. Instead, you should use the deriveCoeffs
* and integrateCoeffs functions and store the coefficient matrix
* you need for future calls to evaluate derivative and integral.
*/
/// @param coefficients vector containing the ordered coefficients
/// @param x_in double value that represents the current input in the 1st dimension
/// @param firstExponent integer value that represents the lowest exponent of the polynomial
/// @param x_base double value that represents the base value for a centered fit in the 1st dimension
double evaluate(const Eigen::MatrixXd &coefficients, const double &x_in, const int &firstExponent=0, const double &x_base=0.0);
/// @param coefficients matrix containing the ordered coefficients
/// @param x_in double value that represents the current input in the 1st dimension
/// @param y_in double value that represents the current input in the 2nd dimension
/// @param x_exp integer value that represents the lowest exponent of the polynomial in the 1st dimension
/// @param y_exp integer value that represents the lowest exponent of the polynomial in the 2nd dimension
/// @param x_base double value that represents the base value for a centered fit in the 1st dimension
/// @param y_base double value that represents the base value for a centered fit in the 2nd dimension
double evaluate(const Eigen::MatrixXd &coefficients, const double &x_in, const double &y_in, const int &x_exp, const int &y_exp, const double &x_base=0.0, const double &y_base=0.0);
/// @param coefficients vector containing the ordered coefficients
/// @param x_in double value that represents the current input in the 1st dimension
/// @param y_in double value that represents the current input in the 2nd dimension
/// @param axis unsigned integer value that represents the axis to derive for (0=x, 1=y)
/// @param x_exp integer value that represents the lowest exponent of the polynomial in the 1st dimension
/// @param y_exp integer value that represents the lowest exponent of the polynomial in the 2nd dimension
/// @param x_base double value that represents the base value for a centred fit in the 1st dimension
/// @param y_base double value that represents the base value for a centred fit in the 2nd dimension
double derivative(const Eigen::MatrixXd &coefficients, const double &x_in, const double &y_in, const int &axis, const int &x_exp, const int &y_exp, const double &x_base=0.0, const double &y_base=0.0);
/// @param coefficients vector containing the ordered coefficients
/// @param x_in double value that represents the current input in the 1st dimension
/// @param y_in double value that represents the current input in the 2nd dimension
/// @param axis unsigned integer value that represents the axis to integrate for (0=x, 1=y)
/// @param x_exp integer value that represents the lowest exponent of the polynomial in the 1st dimension
/// @param y_exp integer value that represents the lowest exponent of the polynomial in the 2nd dimension
/// @param x_base double value that represents the base value for a centred fit in the 1st dimension
/// @param y_base double value that represents the base value for a centred fit in the 2nd dimension
/// @param ax_val double value that represents the base value for the definite integral on the chosen axis.
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, const double &x_base=0.0, const double &y_base=0.0, const double &ax_val=0.0);
public:
/// Returns a vector with ALL the real roots of p(x_in,y_in)-z_in
/// @param coefficients vector containing the ordered coefficients
/// @param in double value that represents the current input in x (1st dimension) or y (2nd dimension)
/// @param z_in double value that represents the current output in the 3rd dimension
/// @param axis unsigned integer value that represents the axis to solve for (0=x, 1=y)
/// @param x_exp integer value that represents the lowest exponent of the polynomial in the 1st dimension
/// @param y_exp integer value that represents the lowest exponent of the polynomial in the 2nd dimension
/// @param x_base double value that represents the base value for a centred fit in the 1st dimension
/// @param y_base double value that represents the base value for a centred fit in the 2nd dimension
Eigen::VectorXd solve(const Eigen::MatrixXd &coefficients, const double &in, const double &z_in, const int &axis, const int &x_exp, const int &y_exp, const double &x_base=0.0, const double &y_base=0.0);
/// Uses the Brent solver to find the roots of p(x_in,y_in)-z_in
/// @param coefficients vector containing the ordered coefficients
/// @param in double value that represents the current input in x (1st dimension) or y (2nd dimension)
/// @param z_in double value that represents the current output in the 3rd dimension
/// @param min double value that represents the minimum value
/// @param max double value that represents the maximum value
/// @param axis unsigned integer value that represents the axis to solve for (0=x, 1=y)
/// @param x_exp integer value that represents the lowest exponent of the polynomial in the 1st dimension
/// @param y_exp integer value that represents the lowest exponent of the polynomial in the 2nd dimension
/// @param x_base double value that represents the base value for a centred fit in the 1st dimension
/// @param y_base double value that represents the base value for a centred fit in the 2nd dimension
double solve_limits(const Eigen::MatrixXd &coefficients, const double &in, const double &z_in, const double &min, const double &max, const int &axis, const int &x_exp, const int &y_exp, const double &x_base=0.0, const double &y_base=0.0);
/// Uses the Newton solver to find the roots of p(x_in,y_in)-z_in
/// @param coefficients vector containing the ordered coefficients
/// @param in double value that represents the current input in x (1st dimension) or y (2nd dimension)
/// @param z_in double value that represents the current output in the 3rd dimension
/// @param guess double value that represents the start value
/// @param axis unsigned integer value that represents the axis to solve for (0=x, 1=y)
/// @param x_exp integer value that represents the lowest exponent of the polynomial in the 1st dimension
/// @param y_exp integer value that represents the lowest exponent of the polynomial in the 2nd dimension
/// @param x_base double value that represents the base value for a centred fit in the 1st dimension
/// @param y_base double value that represents the base value for a centred fit in the 2nd dimension
double solve_guess(const Eigen::MatrixXd &coefficients, const double &in, const double &z_in, const double &guess, const int &axis, const int &x_exp, const int &y_exp, const double &x_base=0.0, const double &y_base=0.0);
/// Uses the Brent solver to find the roots of Int(p(x_in,y_in))-z_in
/// @param coefficients vector containing the ordered coefficients
/// @param in double value that represents the current input in x (1st dimension) or y (2nd dimension)
/// @param z_in double value that represents the current output in the 3rd dimension
/// @param min double value that represents the minimum value
/// @param max double value that represents the maximum value
/// @param axis unsigned integer value that represents the axis to solve for (0=x, 1=y)
/// @param x_exp integer value that represents the lowest exponent of the polynomial in the 1st dimension
/// @param y_exp integer value that represents the lowest exponent of the polynomial in the 2nd dimension
/// @param x_base double value that represents the base value for a centred fit in the 1st dimension
/// @param y_base double value that represents the base value for a centred fit in the 2nd dimension
/// @param int_axis axis for the integration (0=x, 1=y)
double solve_limitsInt(const Eigen::MatrixXd &coefficients, const double &in, const double &z_in, const double &min, const double &max, const int &axis, 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);
/// Uses the Newton solver to find the roots of Int(p(x_in,y_in))-z_in
/// @param coefficients vector containing the ordered coefficients
/// @param in double value that represents the current input in x (1st dimension) or y (2nd dimension)
/// @param z_in double value that represents the current output in the 3rd dimension
/// @param guess double value that represents the start value
/// @param axis unsigned integer value that represents the axis to solve for (0=x, 1=y)
/// @param x_exp integer value that represents the lowest exponent of the polynomial in the 1st dimension
/// @param y_exp integer value that represents the lowest exponent of the polynomial in the 2nd dimension
/// @param x_base double value that represents the base value for a centred fit in the 1st dimension
/// @param y_base double value that represents the base value for a centred fit in the 2nd dimension
/// @param int_axis axis for the integration (0=x, 1=y)
double solve_guessInt(const Eigen::MatrixXd &coefficients, const double &in, const double &z_in, const double &guess, const int &axis, 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);
protected:
/// @param nValue integer value that represents the order of the factorial
double factorial(const int &nValue);
/// @param nValue integer value that represents the upper part of the factorial
/// @param nValue2 integer value that represents the lower part of the factorial
double binom(const int &nValue, const int &nValue2);
///Helper function to calculate the D vector:
/// @param m integer value that represents order
/// @param x_in double value that represents the current input
/// @param x_base double value that represents the basis for the fit
Eigen::MatrixXd fracIntCentralDvector(const int &m, const double &x_in, const double &x_base);
///Indefinite integral of a centred polynomial divided by its independent variable
/// @param coefficients vector containing the ordered coefficients
/// @param x_in double value that represents the current input
/// @param x_base double value that represents the basis for the fit
double fracIntCentral(const Eigen::MatrixXd &coefficients, const double &x_in, const double &x_base);
};
class Poly2DFracResidual : public Poly2DResidual {
protected:
int x_exp, y_exp;
double x_base, y_base;
/// Object that evaluates the equation
Polynomial2DFrac poly;
protected:
Poly2DFracResidual();
public:
/// Residual of a polynomial divided by the independent variable
/// @param poly polynomial object used to evaluate the calls
/// @param coefficients
/// @param in double value that represents the current input in x (1st dimension) or y (2nd dimension)
/// @param z_in double value that represents the current output in the 3rd dimension
/// @param axis unsigned integer value that represents the axis to solve for (0=x, 1=y)
/// @param x_exp first exponent in x-direction
/// @param y_exp first exponent in y-direction
/// @param x_base base value for x (x = x_in - x_base)
/// @param y_base base value for y (y = y_in - y_base)
Poly2DFracResidual(Polynomial2DFrac &poly, const Eigen::MatrixXd &coefficients,
const double &in, const double &z_in, const int &axis,
const int &x_exp, const int &y_exp, const double &x_base, const double &y_base);
virtual ~Poly2DFracResidual(){};
double call(double target);
double deriv(double target);
};
class Poly2DFracIntResidual : public Poly2DFracResidual {
protected:
int int_axis;
Poly2DFracIntResidual();
public:
/// Residual of an integrated polynomial divided by the independent variable
/// @param poly polynomial object used to evaluate the calls
/// @param coefficients vector of coefficients
/// @param in double value that represents the current input in x (1st dimension) or y (2nd dimension)
/// @param z_in double value that represents the current output in the 3rd dimension
/// @param axis unsigned integer value that represents the axis to solve for (0=x, 1=y)
/// @param x_exp first exponent in x-direction
/// @param y_exp first exponent in y-direction
/// @param x_base base value for x (x = x_in - x_base)
/// @param y_base base value for y (y = y_in - y_base)
/// @param int_axis axis for the integration (0=x, 1=y)
Poly2DFracIntResidual(Polynomial2DFrac &poly, const Eigen::MatrixXd &coefficients,
const double &in, const double &z_in, const int &axis,
const int &x_exp, const int &y_exp, const double &x_base, const double &y_base,
const int &int_axis);
virtual ~Poly2DFracIntResidual(){};
double call(double target);
double deriv(double target);
};
//
//
//
//
//
//
//
//
//
///// The base class for Polynomials
//class BasePolynomial{
//
//public:
// // Constructor
// BasePolynomial();
// // Destructor. No implementation
// virtual ~BasePolynomial(){};
//
//public:
// /// Basic checks for coefficient vectors.
// /** Starts with only the first coefficient dimension
// * and checks the vector length against parameter n. */
// bool checkCoefficients(const Eigen::VectorXd &coefficients, const unsigned int n);
// bool checkCoefficients(const Eigen::MatrixXd &coefficients, const unsigned int rows, const unsigned int columns);
// bool checkCoefficients(const std::vector<double> &coefficients, const unsigned int n);
// bool checkCoefficients(const std::vector< std::vector<double> > &coefficients, const unsigned int rows, const unsigned int columns);
//
// /** Integrating coefficients for polynomials is done by dividing the
// * original coefficients by (i+1) and elevating the order by 1
// * through adding a zero as first coefficient.
// * Some reslicing needs to be applied to integrate along the x-axis.
// * In the brine/solution equations, reordering of the parameters
// * avoids this expensive operation. However, it is included for the
// * sake of completeness.
// */
// std::vector<double> integrateCoeffs(const std::vector<double> &coefficients);
// std::vector< std::vector<double> > integrateCoeffs(const std::vector< std::vector<double> > &coefficients, bool axis);
//
// /** Deriving coefficients for polynomials is done by multiplying the
// * original coefficients with i and lowering the order by 1.
// *
// * It is not really deprecated, but untested and therefore a warning
// * is issued. Please check this method before you use it.
// */
// std::vector<double> deriveCoeffs(const std::vector<double> &coefficients);
// std::vector< std::vector<double> > deriveCoeffs(const std::vector< std::vector<double> > &coefficients, unsigned int axis);
//
//private:
// /** The core of the polynomial wrappers are the different
// * implementations that follow below. In case there are
// * new calculation schemes available, please do not delete
// * the implementations, but mark them as deprecated.
// * The old functions are good for debugging since the
// * structure is easier to read than the backward Horner-scheme
// * or the recursive Horner-scheme.
// */
//
// /// Simple polynomial function generator. <- Deprecated due to poor performance, use Horner-scheme instead
// /** Base function to produce n-th order polynomials
// * based on the length of the coefficient vector.
// * Starts with only the first coefficient at x^0. */
// DEPRECATED(double simplePolynomial(const std::vector<double> &coefficients, double x));
// DEPRECATED(double simplePolynomial(const std::vector<std::vector<double> > &coefficients, double x, double y));
//
// /// Simple integrated polynomial function generator.
// /** Base function to produce integrals of n-th order polynomials based on
// * the length of the coefficient vector.
// * Starts with only the first coefficient at x^0 */
// ///Indefinite integral in x-direction
// double simplePolynomialInt(const std::vector<double> &coefficients, double x);
// ///Indefinite integral in y-direction only
// double simplePolynomialInt(const std::vector<std::vector<double> > &coefficients, double x, double y);
//
// /// Simple integrated polynomial function generator divided by independent variable.
// /** Base function to produce integrals of n-th order
// * polynomials based on the length of the coefficient
// * vector. Starts with only the first coefficient at x^0 */
// ///Indefinite integral of a polynomial divided by its independent variable
// double simpleFracInt(const std::vector<double> &coefficients, double x);
// ///Indefinite integral of a polynomial divided by its 2nd independent variable
// double simpleFracInt(const std::vector<std::vector<double> > &coefficients, double x, double y);
//
// /** Simple integrated centred(!) polynomial function generator divided by independent variable.
// * We need to rewrite some of the functions in order to
// * use central fit. Having a central temperature xbase
// * allows for a better fit, but requires a different
// * formulation of the fracInt function group. Other
// * functions are not affected.
// * Starts with only the first coefficient at x^0 */
// ///Helper function to calculate the D vector:
// double factorial(double nValue);
// double binom(double nValue, double nValue2);
// std::vector<double> fracIntCentralDvector(int m, double x, double xbase);
// ///Indefinite integral of a centred polynomial divided by its independent variable
// double fracIntCentral(const std::vector<double> &coefficients, double x, double xbase);
//
// /// Horner function generator implementations
// /** Represent polynomials according to Horner's scheme.
// * This avoids unnecessary multiplication and thus
// * speeds up calculation.
// */
// double baseHorner(const std::vector<double> &coefficients, double x);
// double baseHorner(const std::vector< std::vector<double> > &coefficients, double x, double y);
// ///Indefinite integral in x-direction
// double baseHornerInt(const std::vector<double> &coefficients, double x);
// ///Indefinite integral in y-direction only
// double baseHornerInt(const std::vector<std::vector<double> > &coefficients, double x, double y);
// ///Indefinite integral of a polynomial divided by its independent variable
// double baseHornerFracInt(const std::vector<double> &coefficients, double x);
// ///Indefinite integral of a polynomial divided by its 2nd independent variable
// double baseHornerFracInt(const std::vector<std::vector<double> > &coefficients, double x, double y);
//
// /** Alternatives
// * Simple functions that heavily rely on other parts of this file.
// * We still need to check which combinations yield the best
// * performance.
// */
// ///Derivative in x-direction
// double deriveIn2Steps(const std::vector<double> &coefficients, double x); // TODO: Check results!
// ///Derivative in terms of x(axis=true) or y(axis=false).
// double deriveIn2Steps(const std::vector< std::vector<double> > &coefficients, double x, double y, bool axis); // TODO: Check results!
// ///Indefinite integral in x-direction
// double integrateIn2Steps(const std::vector<double> &coefficients, double x);
// ///Indefinite integral in terms of x(axis=true) or y(axis=false).
// double integrateIn2Steps(const std::vector< std::vector<double> > &coefficients, double x, double y, bool axis);
// ///Indefinite integral in x-direction of a polynomial divided by its independent variable
// double fracIntIn2Steps(const std::vector<double> &coefficients, double x);
// ///Indefinite integral in y-direction of a polynomial divided by its 2nd independent variable
// double fracIntIn2Steps(const std::vector<std::vector<double> > &coefficients, double x, double y);
// ///Indefinite integral of a centred polynomial divided by its 2nd independent variable
// double fracIntCentral2Steps(const std::vector<std::vector<double> > &coefficients, double x, double y, double ybase);
//
//public:
// /** Here we define the functions that should be used by the
// * respective implementations. Please do no use any other
// * method since this would break the purpose of this interface.
// * Note that the functions below are supposed to be aliases
// * to implementations declared elsewhere in this file.
// */
//
// /** Everything related to the normal polynomials goes in this
// * section, holds all the functions for evaluating polynomials.
// */
// /// Evaluates a one-dimensional polynomial for the given coefficients
// /// @param coefficients vector containing the ordered coefficients
// /// @param x double value that represents the current input
// virtual inline double polyval(const std::vector<double> &coefficients, double x){
// return baseHorner(coefficients,x);
// }
//
// /// Evaluates a two-dimensional polynomial for the given coefficients
// /// @param coefficients vector containing the ordered coefficients
// /// @param x double value that represents the current input in the 1st dimension
// /// @param y double value that represents the current input in the 2nd dimension
// virtual inline double polyval(const std::vector< std::vector<double> > &coefficients, double x, double y){
// return baseHorner(coefficients,x,y);
// }
//
//
// /** Everything related to the integrated polynomials goes in this
// * section, holds all the functions for evaluating polynomials.
// */
// /// Evaluates the indefinite integral of a one-dimensional polynomial
// /// @param coefficients vector containing the ordered coefficients
// /// @param x double value that represents the current input
// virtual inline double polyint(const std::vector<double> &coefficients, double x){
// return baseHornerInt(coefficients,x);
// }
//
// /// Evaluates the indefinite integral of a two-dimensional polynomial along the 2nd axis (y)
// /// @param coefficients vector containing the ordered coefficients
// /// @param x double value that represents the current input in the 1st dimension
// /// @param y double value that represents the current input in the 2nd dimension
// virtual inline double polyint(const std::vector< std::vector<double> > &coefficients, double x, double y){
// return baseHornerInt(coefficients,x,y);
// }
//
//
// /** Everything related to the derived polynomials goes in this
// * section, holds all the functions for evaluating polynomials.
// */
// /// Evaluates the derivative of a one-dimensional polynomial
// /// @param coefficients vector containing the ordered coefficients
// /// @param x double value that represents the current input
// virtual inline double polyder(const std::vector<double> &coefficients, double x){
// return deriveIn2Steps(coefficients,x);
// }
//
// /// Evaluates the derivative of a two-dimensional polynomial along the 2nd axis (y)
// /// @param coefficients vector containing the ordered coefficients
// /// @param x double value that represents the current input in the 1st dimension
// /// @param y double value that represents the current input in the 2nd dimension
// virtual inline double polyder(const std::vector< std::vector<double> > &coefficients, double x, double y){
// return deriveIn2Steps(coefficients,x,y,false);
// }
//
//
// /** Everything related to the polynomials divided by one variable goes in this
// * section, holds all the functions for evaluating polynomials.
// */
// /// Evaluates the indefinite integral of a one-dimensional polynomial divided by its independent variable
// /// @param coefficients vector containing the ordered coefficients
// /// @param x double value that represents the current position
// virtual inline double polyfracval(const std::vector<double> &coefficients, double x){
// return baseHorner(coefficients,x)/x;
// }
//
// /// Evaluates the indefinite integral of a two-dimensional polynomial divided by its 2nd independent variable
// /// @param coefficients vector containing the ordered coefficients
// /// @param x double value that represents the current input in the 1st dimension
// /// @param y double value that represents the current input in the 2nd dimension
// virtual inline double polyfracval(const std::vector< std::vector<double> > &coefficients, double x, double y){
// return baseHorner(coefficients,x,y)/y;
// }
//
//
// /** Everything related to the integrated polynomials divided by one variable goes in this
// * section, holds all the functions for solving polynomials.
// */
// /// Evaluates the indefinite integral of a one-dimensional polynomial divided by its independent variable
// /// @param coefficients vector containing the ordered coefficients
// /// @param x double value that represents the current position
// virtual inline double polyfracint(const std::vector<double> &coefficients, double x){
// return baseHornerFracInt(coefficients,x);
// }
//
// /// Evaluates the indefinite integral of a two-dimensional polynomial divided by its 2nd independent variable
// /// @param coefficients vector containing the ordered coefficients
// /// @param x double value that represents the current input in the 1st dimension
// /// @param y double value that represents the current input in the 2nd dimension
// virtual inline double polyfracint(const std::vector< std::vector<double> > &coefficients, double x, double y){
// return baseHornerFracInt(coefficients,x,y);
// }
//
// /// Evaluates the indefinite integral of a centred one-dimensional polynomial divided by its independent variable
// /// @param coefficients vector containing the ordered coefficients
// /// @param x double value that represents the current position
// /// @param xbase central temperature for fitted function
// virtual inline double polyfracintcentral(const std::vector<double> &coefficients, double x, double xbase){
// return fracIntCentral(coefficients,x,xbase);
// }
//
// /// Evaluates the indefinite integral of a centred two-dimensional polynomial divided by its 2nd independent variable
// /// @param coefficients vector containing the ordered coefficients
// /// @param x double value that represents the current input in the 1st dimension
// /// @param y double value that represents the current input in the 2nd dimension
// /// @param ybase central temperature for fitted function
// virtual inline double polyfracintcentral(const std::vector< std::vector<double> > &coefficients, double x, double y, double ybase){
// return fracIntCentral2Steps(coefficients,x,y,ybase);
// }
//
//
// /** Everything related to the derived polynomials divided by one variable goes in this
// * section, holds all the functions for solving polynomials.
// */
// /// Evaluates the derivative of a one-dimensional polynomial divided by its independent variable
// /// @param coefficients vector containing the ordered coefficients
// /// @param x double value that represents the current position
// virtual inline double polyfracder(const std::vector<double> &coefficients, double x){
// throw CoolProp::NotImplementedError("Derivatives of polynomials divided by their independent variable have not been implemented."); // TODO: Implement polyfracder1D
// }
//
// /// Evaluates the derivative of a two-dimensional polynomial divided by its 2nd independent variable
// /// @param coefficients vector containing the ordered coefficients
// /// @param x double value that represents the current input in the 1st dimension
// /// @param y double value that represents the current input in the 2nd dimension
// virtual inline double polyfracder(const std::vector< std::vector<double> > &coefficients, double x, double y){
// throw CoolProp::NotImplementedError("Derivatives of polynomials divided by their independent variable have not been implemented."); // TODO: Implement polyfracder2D
// }
//
// /// Evaluates the derivative of a centred one-dimensional polynomial divided by its independent variable
// /// @param coefficients vector containing the ordered coefficients
// /// @param x double value that represents the current position
// /// @param xbase central temperature for fitted function
// virtual inline double polyfracdercentral(const std::vector<double> &coefficients, double x, double xbase){
// throw CoolProp::NotImplementedError("Derivatives of polynomials divided by their independent variable have not been implemented."); // TODO: Implement polyfracdercentral1D
// }
//
// /// Evaluates the derivative of a centred two-dimensional polynomial divided by its 2nd independent variable
// /// @param coefficients vector containing the ordered coefficients
// /// @param x double value that represents the current input in the 1st dimension
// /// @param y double value that represents the current input in the 2nd dimension
// /// @param ybase central temperature for fitted function
// virtual inline double polyfracdercentral(const std::vector< std::vector<double> > &coefficients, double x, double y, double ybase){
// throw CoolProp::NotImplementedError("Derivatives of polynomials divided by their independent variable have not been implemented."); // TODO: Implement polyfracdercentral2D
// }
//};
//
//
//
//
///** Implements the function wrapper interface and can be
// * used by the solvers.
// * TODO: Make multidimensional
// */
//class PolyResidual : public FuncWrapper1D {
//protected:
// enum dims {i1D, i2D};
// /// Object that evaluates the equation
// BasePolynomial poly;
// /// Current output value
// double output, firstDim;
// int dim;
// std::vector< std::vector<double> > coefficients;
//private:
// PolyResidual();
//public:
// PolyResidual(const std::vector<double> &coefficients, double y);
// PolyResidual(const std::vector< std::vector<double> > &coefficients, double x, double z);
// virtual ~PolyResidual(){};
// bool is2D(){return (this->dim==i2D);};
// virtual double call(double x);
// virtual double deriv(double x);
//};
//class PolyIntResidual : public PolyResidual {
//public:
// PolyIntResidual(const std::vector<double> &coefficients, double y):PolyResidual(coefficients, y){};
// PolyIntResidual(const std::vector< std::vector<double> > &coefficients, double x, double z):PolyResidual(coefficients, x, z){};
// virtual double call(double x);
// virtual double deriv(double x);
//};
//class PolyFracIntResidual : public PolyResidual {
//public:
// PolyFracIntResidual(const std::vector<double> &coefficients, double y):PolyResidual(coefficients, y){};
// PolyFracIntResidual(const std::vector< std::vector<double> > &coefficients, double x, double z):PolyResidual(coefficients, x, z){};
// virtual double call(double x);
// virtual double deriv(double x);
//};
//class PolyFracIntCentralResidual : public PolyResidual {
//protected:
// double baseVal;
//public:
// PolyFracIntCentralResidual(const std::vector<double> &coefficients, double y, double xBase):PolyResidual(coefficients, y){this->baseVal = xBase;};
// PolyFracIntCentralResidual(const std::vector< std::vector<double> > &coefficients, double x, double z, double yBase): PolyResidual(coefficients, x, z){this->baseVal = yBase;};
// virtual double call(double x);
// virtual double deriv(double x);
//};
//class PolyDerResidual : public PolyResidual {
//public:
// PolyDerResidual(const std::vector<double> &coefficients, double y):PolyResidual(coefficients, y){};
// PolyDerResidual(const std::vector< std::vector<double> > &coefficients, double x, double z):PolyResidual(coefficients, x, z){};
// virtual double call(double x);
// virtual double deriv(double x);
//};
//
//
//
//
///** Implements the same public functions as the
// * but solves the polynomial for the given value
// * instead of evaluating it.
// * TODO: This class does not check for bijective
// * polynomials and is therefore a little
// * fragile.
// */
//class PolynomialSolver : public BasePolynomial{
//private:
// enum solvers {iNewton, iBrent};
// int uses;
// double guess, min, max;
// double macheps, tol;
// int maxiter;
//
//public:
// // Constructor
// PolynomialSolver();
// // Destructor. No implementation
// virtual ~PolynomialSolver(){};
//
//public:
// /** Here we redefine the functions that solve the polynomials.
// * These implementations all use the base class to evaluate
// * the polynomial during the solution process.
// */
//
// /** Everything related to the normal polynomials goes in this
// * section, holds all the functions for solving polynomials.
// */
// /// Solves a one-dimensional polynomial for the given coefficients
// /// @param coefficients vector containing the ordered coefficients
// /// @param y double value that represents the current input
// virtual double polyval(const std::vector<double> &coefficients, double y);
//
// /// Solves a two-dimensional polynomial for the given coefficients
// /// @param coefficients vector containing the ordered coefficients
// /// @param x double value that represents the current input in the 1st dimension
// /// @param z double value that represents the current output
// virtual double polyval(const std::vector< std::vector<double> > &coefficients, double x, double z);
//
//
// /** Everything related to the integrated polynomials goes in this
// * section, holds all the functions for solving polynomials.
// */
// /// Solves the indefinite integral of a one-dimensional polynomial
// /// @param coefficients vector containing the ordered coefficients
// /// @param y double value that represents the current output
// virtual double polyint(const std::vector<double> &coefficients, double y);
//
// /// Solves the indefinite integral of a two-dimensional polynomial along the 2nd axis (y)
// /// @param coefficients vector containing the ordered coefficients
// /// @param x double value that represents the current input in the 1st dimension
// /// @param z double value that represents the current output
// virtual double polyint(const std::vector< std::vector<double> > &coefficients, double x, double z);
//
//
// /** Everything related to the derived polynomials goes in this
// * section, holds all the functions for solving polynomials.
// */
// /// Solves the derivative of a one-dimensional polynomial
// /// @param coefficients vector containing the ordered coefficients
// /// @param y double value that represents the current output
// virtual double polyder(const std::vector<double> &coefficients, double y);
//
// /// Solves the derivative of a two-dimensional polynomial along the 2nd axis (y)
// /// @param coefficients vector containing the ordered coefficients
// /// @param x double value that represents the current input in the 1st dimension
// /// @param z double value that represents the current output
// virtual double polyder(const std::vector< std::vector<double> > &coefficients, double x, double z);
//
//
// /** Everything related to the polynomials divided by one variable goes in this
// * section, holds all the functions for solving polynomials.
// */
// /// Solves the indefinite integral of a one-dimensional polynomial divided by its independent variable
// /// @param coefficients vector containing the ordered coefficients
// /// @param y double value that represents the current output
// virtual double polyfracval(const std::vector<double> &coefficients, double y);
//
// /// Solves the indefinite integral of a two-dimensional polynomial divided by its 2nd independent variable
// /// @param coefficients vector containing the ordered coefficients
// /// @param x double value that represents the current input in the 1st dimension
// /// @param z double value that represents the current output
// virtual double polyfracval(const std::vector< std::vector<double> > &coefficients, double x, double z);
//
//
// /** Everything related to the integrated polynomials divided by one variable goes in this
// * section, holds all the functions for solving polynomials.
// */
// /// Solves the indefinite integral of a one-dimensional polynomial divided by its independent variable
// /// @param coefficients vector containing the ordered coefficients
// /// @param y double value that represents the current output
// virtual double polyfracint(const std::vector<double> &coefficients, double y);
//
// /// Solves the indefinite integral of a two-dimensional polynomial divided by its 2nd independent variable
// /// @param coefficients vector containing the ordered coefficients
// /// @param x double value that represents the current input in the 1st dimension
// /// @param z double value that represents the current output
// virtual double polyfracint(const std::vector< std::vector<double> > &coefficients, double x, double z);
//
// /// Solves the indefinite integral of a centred one-dimensional polynomial divided by its independent variable
// /// @param coefficients vector containing the ordered coefficients
// /// @param y double value that represents the current output
// /// @param xbase central x-value for fitted function
// virtual double polyfracintcentral(const std::vector<double> &coefficients, double y, double xbase);
//
// /// Solves the indefinite integral of a centred two-dimensional polynomial divided by its 2nd independent variable
// /// @param coefficients vector containing the ordered coefficients
// /// @param x double value that represents the current input in the 1st dimension
// /// @param z double value that represents the current output
// /// @param ybase central y-value for fitted function
// virtual double polyfracintcentral(const std::vector< std::vector<double> > &coefficients, double x, double z, double ybase);
//
//
// /** Everything related to the derived polynomials divided by one variable goes in this
// * section, holds all the functions for solving polynomials.
// */
// /// Solves the derivative of a one-dimensional polynomial divided by its independent variable
// /// @param coefficients vector containing the ordered coefficients
// /// @param y double value that represents the current output
// virtual double polyfracder(const std::vector<double> &coefficients, double y);
//
// /// Solves the derivative of a two-dimensional polynomial divided by its 2nd independent variable
// /// @param coefficients vector containing the ordered coefficients
// /// @param x double value that represents the current input in the 1st dimension
// /// @param z double value that represents the current output
// virtual double polyfracder(const std::vector< std::vector<double> > &coefficients, double x, double z);
//
// /// Solves the derivative of a centred one-dimensional polynomial divided by its independent variable
// /// @param coefficients vector containing the ordered coefficients
// /// @param y double value that represents the current output
// /// @param xbase central x-value for fitted function
// virtual double polyfracdercentral(const std::vector<double> &coefficients, double y, double xbase);
//
// /// Solves the derivative of a centred two-dimensional polynomial divided by its 2nd independent variable
// /// @param coefficients vector containing the ordered coefficients
// /// @param x double value that represents the current input in the 1st dimension
// /// @param z double value that represents the current output
// /// @param ybase central y-value for fitted function
// virtual double polyfracdercentral(const std::vector< std::vector<double> > &coefficients, double x, double z, double ybase);
//
//
// /** Set the solvers and updates either the guess values or the
// * boundaries for the variable to solve for.
// */
// /// Sets the guess value for the Newton solver and enables it.
// /// @param guess double value that represents the guess value
// virtual void setGuess(double guess);
// /// Sets the limits for the Brent solver and enables it.
// /// @param min double value that represents the lower boundary
// /// @param max double value that represents the upper boundary
// virtual void setLimits(double min, double max);
// /// Solves the equations based on previously defined parameters.
// /// @param min double value that represents the lower boundary
// /// @param max double value that represents the upper boundary
// virtual double solve(PolyResidual &res);
//};
//
//
///// The base class for exponential functions
//class BaseExponential{
//
//protected:
// BasePolynomial poly;
// bool POLYMATH_DEBUG;
//
//public:
// BaseExponential();
// virtual ~BaseExponential(){};
//
//public:
// /// Evaluates an exponential function for the given coefficients
// /// @param coefficients vector containing the ordered coefficients
// /// @param x double value that represents the current input
// /// @param n int value that determines the kind of exponential function
// double expval(const std::vector<double> &coefficients, double x, int n);
//
// /// Evaluates an exponential function for the given coefficients
// /// @param coefficients vector containing the ordered coefficients
// /// @param x double value that represents the current input in the 1st dimension
// /// @param y double value that represents the current input in the 2nd dimension
// /// @param n int value that determines the kind of exponential function
// double expval(const std::vector< std::vector<double> > &coefficients, double x, double y, int n);
//};
}; /* namespace CoolProp */
#endif