ProSHADE: ProSHADE_internal_maths::BicubicInterpolator Class Reference

| ProSHADE 0.7.5.1 (JAN 2021) Protein Shape Detection

Public Member Functions | List of all members
ProSHADE_internal_maths::BicubicInterpolator Class Reference

## Public Member Functions
| BicubicInterpolator (proshade_double **areaToInterpolate, proshade_double xStart, proshade_double yStart)
| This is the constructor for the BicubicInterpolator class. More...
| ~BicubicInterpolator (void)
| This is the destructor for the BicubicInterpolator class. More...
proshade_double | getValue (proshade_double x, proshade_double y)
| This function allows accessing the interpolated value for a given position x and y. More...

## Detailed Description

Definition at line 101 of file ProSHADE_maths.hpp.

## Constructor & Destructor Documentation

## ◆ BicubicInterpolator()

ProSHADE_internal_maths::BicubicInterpolator::BicubicInterpolator | ( | proshade_double ** | areaToInterpolate,
|  | proshade_double | xStart,
|  | proshade_double | yStart
| ) |  |
| inline

This is the constructor for the BicubicInterpolator class.

This constructor takes the 4 by 4 array of values and pre-computes all the interpolators required for fast computation of any positions value.

Parameters

  [in] | areaToInterpolate | Pointer to pointer of 4 by 4 equidistantly spaced grid of values.

Definition at line 115 of file ProSHADE_maths.hpp.

116 {
117 //======================================== Save the original non-unit square positions
118 this->xStartIndex = xStart;
119 this->yStartIndex = yStart;
120
121 //======================================== Prepare variables for converting from original indices to unit square
122 this->xRange = 1.0;
123 this->yRange = 1.0;
124
125 //======================================== Precompute interpolators
126 this->a00 = areaToInterpolate[1][1];
127 this->a01 = - ( 0.5 * areaToInterpolate[1][0] ) +
128 ( 0.5 * areaToInterpolate[1][2] );
129 this->a02 = areaToInterpolate[1][0] -
130 ( 2.5 * areaToInterpolate[1][1] ) +
131 ( 2.0 * areaToInterpolate[1][2] ) -
132 ( 0.5 * areaToInterpolate[1][3] );
133 this->a03 = - ( 0.5 * areaToInterpolate[1][0] ) +
134 ( 1.5 * areaToInterpolate[1][1] ) -
135 ( 1.5 * areaToInterpolate[1][2] ) +
136 ( 0.5 * areaToInterpolate[1][3] );
137 this->a10 = - ( 0.5 * areaToInterpolate[0][1] ) +
138 ( 0.5 * areaToInterpolate[2][1] );
139 this->a11 = ( 0.25 * areaToInterpolate[0][0] ) -
140 ( 0.25 * areaToInterpolate[0][2] ) -
141 ( 0.25 * areaToInterpolate[2][0] ) +
142 ( 0.25 * areaToInterpolate[2][2] );
143 this->a12 = - ( 0.5 * areaToInterpolate[0][0] ) +
144 ( 1.25 * areaToInterpolate[0][1] ) -
145 areaToInterpolate[0][2] +
146 ( 0.25 * areaToInterpolate[0][3] ) +
147 ( 0.5 * areaToInterpolate[2][0] ) -
148 ( 1.25 * areaToInterpolate[2][1] ) +
149 areaToInterpolate[2][2] -
150 ( 0.25 * areaToInterpolate[2][3] );
151 this->a13 = ( 0.25 * areaToInterpolate[0][0] ) -
152 ( 0.75 * areaToInterpolate[0][1] ) +
153 ( 0.75 * areaToInterpolate[0][2] ) -
154 ( 0.25 * areaToInterpolate[0][3] ) -
155 ( 0.25 * areaToInterpolate[2][0] ) +
156 ( 0.75 * areaToInterpolate[2][1] ) -
157 ( 0.75 * areaToInterpolate[2][2] ) +
158 ( 0.25 * areaToInterpolate[2][3] );
159 this->a20 = areaToInterpolate[0][1] -
160 ( 2.5 * areaToInterpolate[1][1] ) +
161 ( 2.0 * areaToInterpolate[2][1] ) -
162 ( 0.5 * areaToInterpolate[3][1] );
163 this->a21 = - ( 0.5 * areaToInterpolate[0][0] ) +
164 ( 0.5 * areaToInterpolate[0][2] ) +
165 ( 1.25 * areaToInterpolate[1][0] ) -
166 ( 1.25 * areaToInterpolate[1][2] ) -
167 areaToInterpolate[2][0] + areaToInterpolate[2][2] +
168 ( 0.25 * areaToInterpolate[3][0] ) -
169 ( 0.25 * areaToInterpolate[3][2] );
170 this->a22 = areaToInterpolate[0][0] -
171 ( 2.5 * areaToInterpolate[0][1] ) +
172 ( 2.0 * areaToInterpolate[0][2] ) -
173 ( 0.5 * areaToInterpolate[0][3] ) -
174 ( 2.5 * areaToInterpolate[1][0] ) +
175 ( 6.25 * areaToInterpolate[1][1] ) -
176 ( 5.0 * areaToInterpolate[1][2] ) +
177 ( 1.25 * areaToInterpolate[1][3] ) +
178 ( 2.0 * areaToInterpolate[2][0] ) -
179 ( 5.0 * areaToInterpolate[2][1] ) +
180 ( 4.0 * areaToInterpolate[2][2] ) -
181 areaToInterpolate[2][3] -
182 ( 0.5 * areaToInterpolate[3][0] ) +
183 ( 1.25 * areaToInterpolate[3][1] ) -
184 areaToInterpolate[3][2] +
185 ( 0.25 * areaToInterpolate[3][3] );
186 this->a23 = - ( 0.5 * areaToInterpolate[0][0] ) +
187 ( 1.5 * areaToInterpolate[0][1] ) -
188 ( 1.5 * areaToInterpolate[0][2] ) +
189 ( 0.5 * areaToInterpolate[0][3] ) +
190 ( 1.25 * areaToInterpolate[1][0] ) -
191 ( 3.75 * areaToInterpolate[1][1] ) +
192 ( 3.75 * areaToInterpolate[1][2] ) -
193 ( 1.25 * areaToInterpolate[1][3] ) -
194 areaToInterpolate[2][0] +
195 ( 3.0 * areaToInterpolate[2][1] ) -
196 ( 3.0 * areaToInterpolate[2][2] ) +
197 areaToInterpolate[2][3] +
198 ( 0.25 * areaToInterpolate[3][0] ) -
199 ( 0.75 * areaToInterpolate[3][1] ) +
200 ( 0.75 * areaToInterpolate[3][2] ) -
201 ( 0.25 * areaToInterpolate[3][3] );
202 this->a30 = - ( 0.5 * areaToInterpolate[0][1] ) +
203 ( 1.5 * areaToInterpolate[1][1] ) -
204 ( 1.5 * areaToInterpolate[2][1] ) +
205 ( 0.5*areaToInterpolate[3][1] );
206 this->a31 = ( 0.25 * areaToInterpolate[0][0] ) -
207 ( 0.25 * areaToInterpolate[0][2] ) -
208 ( 0.75 * areaToInterpolate[1][0] ) +
209 ( 0.75 * areaToInterpolate[1][2] ) +
210 ( 0.75 * areaToInterpolate[2][0] ) -
211 ( 0.75 * areaToInterpolate[2][2] ) -
212 ( 0.25 * areaToInterpolate[3][0] ) +
213 ( 0.25 * areaToInterpolate[3][2] );
214 this->a32 = - ( 0.5 * areaToInterpolate[0][0] ) +
215 ( 1.25 * areaToInterpolate[0][1] ) -
216 areaToInterpolate[0][2] +
217 ( 0.25 * areaToInterpolate[0][3] ) +
218 ( 1.5 * areaToInterpolate[1][0] ) -
219 ( 3.75 * areaToInterpolate[1][1] ) +
220 ( 3.0 * areaToInterpolate[1][2] ) -
221 ( 0.75 * areaToInterpolate[1][3] ) -
222 ( 1.5 * areaToInterpolate[2][0] ) +
223 ( 3.75 * areaToInterpolate[2][1] ) -
224 ( 3.0 * areaToInterpolate[2][2] ) +
225 ( 0.75 * areaToInterpolate[2][3] ) +
226 ( 0.5 * areaToInterpolate[3][0] ) -
227 ( 1.25 * areaToInterpolate[3][1] ) +
228 areaToInterpolate[3][2] -
229 ( 0.25 * areaToInterpolate[3][3] );
230 this->a33 = ( 0.25 * areaToInterpolate[0][0] ) -
231 ( 0.75 * areaToInterpolate[0][1] ) +
232 ( 0.75 * areaToInterpolate[0][2] ) -
233 ( 0.25 * areaToInterpolate[0][3] ) -
234 ( 0.75 * areaToInterpolate[1][0] ) +
235 ( 2.25 * areaToInterpolate[1][1] ) -
236 ( 2.25 * areaToInterpolate[1][2] ) +
237 ( 0.75 * areaToInterpolate[1][3] ) +
238 ( 0.75 * areaToInterpolate[2][0] ) -
239 ( 2.25 * areaToInterpolate[2][1] ) +
240 ( 2.25 * areaToInterpolate[2][2] ) -
241 ( 0.75 * areaToInterpolate[2][3] ) -
242 ( 0.25 * areaToInterpolate[3][0] ) +
243 ( 0.75 * areaToInterpolate[3][1] ) -
244 ( 0.75 * areaToInterpolate[3][2] ) +
245 ( 0.25 * areaToInterpolate[3][3] );
246 }

## ◆ ~BicubicInterpolator()

ProSHADE_internal_maths::BicubicInterpolator::~BicubicInterpolator | ( | void |  | ) |
| inline

This is the destructor for the BicubicInterpolator class.

This destructor does nothing.

Definition at line 252 of file ProSHADE_maths.hpp.

252 { ; }

## Member Function Documentation

## ◆ getValue()

proshade_double ProSHADE_internal_maths::BicubicInterpolator::getValue | ( | proshade_double | x,
|  | proshade_double | y
| ) |  |
| inline

This function allows accessing the interpolated value for a given position x and y.

This constructor takes the 4 by 4 array of values and pre-computes all the interpolators required for fast computation of any positions value.

Parameters

  [in] | x | The x-axis position on the unit square for which the interpolated value should be computed.
  [in] | y | The y-axis position on the unit square for which the interpolated value should be computed.
  [out] | res | The interpolated value for the position x and y.

Definition at line 263 of file ProSHADE_maths.hpp.

264 {
265 //======================================== Sanity check
266 if ( ( ( x < this->xStartIndex ) || ( x > ( this->xStartIndex + this->xRange ) ) ) ||
267 ( ( y < this->yStartIndex ) || ( y > ( this->yStartIndex + this->yRange ) ) ) )
268 {
269 if ( ( x < this->xStartIndex ) || ( x > ( this->xStartIndex + this->xRange ) ) ) { std::cout << "PROBLEM WITH LAT" << std::endl; }
270 if ( ( y < this->yStartIndex ) || ( y > ( this->yStartIndex + this->yRange ) ) ) { std::cout << "PROBLEM WITH LON" << std::endl; }
271
272 throw ProSHADE_exception ( "Requested bicubic interpolation outside of pre-computed\n : square.", "ES00064", __FILE__, __LINE__, __func__, "The supplied x or y value(s) is outside of the range of\n : the bi-cubic interpolator's pre-computed square. Please\n : make sure the start values were correctly supplied when\n : the constructor was called or create a new interpolator\n : for these values." );
273 }
274
275 //======================================== Convert x and y to unit square
276 proshade_double unitSquareX = ( x - this->xStartIndex ) / this->xRange;
277 proshade_double unitSquareY = ( y - this->yStartIndex ) / this->yRange;
278
279 //======================================== Precompute powers
280 proshade_double x2 = std::pow ( unitSquareX, 2.0 );
281 proshade_double x3 = std::pow ( unitSquareX, 3.0 );
282 proshade_double y2 = std::pow ( unitSquareY, 2.0 );
283 proshade_double y3 = std::pow ( unitSquareY, 3.0 );
284
285 //======================================== Done
286 return ( ( this->a00 + this->a01 * unitSquareY + this->a02 * y2 + this->a03 * y3 ) +
287 ( this->a10 + this->a11 * unitSquareY + this->a12 * y2 + this->a13 * y3 ) * unitSquareX +
288 ( this->a20 + this->a21 * unitSquareY + this->a22 * y2 + this->a23 * y3 ) * x2 +
289 ( this->a30 + this->a31 * unitSquareY + this->a32 * y2 + this->a33 * y3 ) * x3 );
290 }

The documentation for this class was generated from the following file:

- src/proshade/ProSHADE_maths.hpp

ProSHADE_exception
This class is the representation of ProSHADE exception.
Definition: ProSHADE_exceptions.hpp:37