@@ -50,9 +50,6 @@ class PolyInterpolator {
50
50
*/
51
51
double ypxmin;
52
52
53
- Eigen::VectorXd x_in_poly = Eigen::VectorXd(5 );
54
- Eigen::VectorXd y_in_poly = Eigen::VectorXd(5 );
55
-
56
53
public:
57
54
/* *
58
55
* @brief Constructor
@@ -65,6 +62,7 @@ class PolyInterpolator {
65
62
n = x_in.size ();
66
63
xmin = x_in (0 );
67
64
xmax = x_in (x_in.size () - 1 );
65
+ Eigen::VectorXd x_in_poly (5 ), y_in_poly (5 );
68
66
69
67
int j = 0 ;
70
68
for (int i = n - 5 ; i < n; i++) {
@@ -86,13 +84,14 @@ class PolyInterpolator {
86
84
* Useful when the logarithm of the density is interpolated.
87
85
* @param x x value at which to evaluate the function
88
86
*/
89
- double evalfLeftNoRightLinear (const double &xval) {
87
+ double evalfLeftNoRightLinear (const double &xval) const {
90
88
double y;
91
89
if (xval > xmax) { // linear extrapolation
92
90
y = this ->y (n - 1 ) + ypxmax*(xval - xmax);
93
91
return y;
94
92
}
95
93
94
+ Eigen::VectorXd x_in_poly (5 ), y_in_poly (5 );
96
95
int i = adjustIndexToBoundaries (binarySearch (this ->x , xval));
97
96
for (int k = 0 ; k < 5 ; k++) {
98
97
x_in_poly (k) = this ->x (i - 2 + k);
@@ -108,13 +107,15 @@ class PolyInterpolator {
108
107
* Useful when the density is interpolated.
109
108
* @param x x value at which to evaluate the function
110
109
*/
111
- double evalfLeftNoRightZero (const double &xval) {
110
+ double evalfLeftNoRightZero (const double &xval) const {
112
111
double y;
113
- if (xval > xmax) { // linear extrapolation
112
+ if (xval > xmax) { // constant
114
113
y = 0.0 ;
115
114
return y;
116
115
}
117
116
117
+ Eigen::VectorXd x_in_poly (5 ), y_in_poly (5 );
118
+ int j = adjustIndexToBoundaries (binarySearch (this ->x , xval));
118
119
int i = adjustIndexToBoundaries (binarySearch (this ->x , xval));
119
120
for (int k = 0 ; k < 5 ; k++) {
120
121
x_in_poly (k) = this ->x (i - 2 + k);
@@ -127,7 +128,7 @@ class PolyInterpolator {
127
128
int adjustIndexToBoundaries (int i) const {
128
129
int j = i;
129
130
if (i == 0 ) j = 2 ;
130
- if (i == 1 ) i = 2 ;
131
+ if (i == 1 ) j = 2 ;
131
132
if (i == n - 1 ) j = n - 3 ;
132
133
if (i == n - 2 ) j = n - 3 ;
133
134
return j;
0 commit comments