24 template <
typename Real>
31 Real yMin, Real ySpacing, Real
const* F);
37 inline Real
const*
GetF()
const;
52 Real
operator()(
int xOrder,
int yOrder, Real x, Real y)
const;
62 Real&
A(
int ix,
int iy);
64 Real
operator()(
int xOrder,
int yOrder, Real x, Real y)
const;
78 Real
const FY[2][2], Real
const FXY[2][2]);
81 void XLookup(Real x,
int& xIndex, Real& dx)
const;
82 void YLookup(Real y,
int& yIndex, Real& dy)
const;
92 template <
typename Real>
97 template <
typename Real>
99 Real xSpacing, Real yMin, Real ySpacing, Real
const* F)
135 template <
typename Real>
inline 141 template <
typename Real>
inline 147 template <
typename Real>
inline 153 template <
typename Real>
inline 159 template <
typename Real>
inline 165 template <
typename Real>
inline 171 template <
typename Real>
inline 177 template <
typename Real>
inline 183 template <
typename Real>
inline 189 template <
typename Real>
inline 195 template <
typename Real>
204 return mPoly[iy][ix](dx, dy);
207 template <
typename Real>
217 return mPoly[iy][ix](xOrder, yOrder, dx, dy);
220 template <
typename Real>
226 for (iy = 0; iy <
mYBound; ++iy)
228 for (ix = 0; ix <
mXBound - 1; ++ix)
230 slope[iy][ix + 2] = (F[iy][ix + 1] - F[iy][ix]) * invDX;
233 slope[iy][1] = ((Real)2) * slope[iy][2] - slope[iy][3];
234 slope[iy][0] = ((Real)2) * slope[iy][1] - slope[iy][2];
235 slope[iy][mXBound + 1] = ((Real)2) * slope[iy][
mXBound] - slope[iy][mXBound - 1];
236 slope[iy][mXBound + 2] = ((Real)2) * slope[iy][mXBound + 1] - slope[iy][
mXBound];
239 for (iy = 0; iy <
mYBound; ++iy)
241 for (ix = 0; ix <
mXBound; ++ix)
248 template <
typename Real>
254 for (ix = 0; ix <
mXBound; ++ix)
256 for (iy = 0; iy <
mYBound - 1; ++iy)
258 slope[ix][iy + 2] = (F[iy + 1][ix] - F[iy][ix]) * invDY;
261 slope[ix][1] = ((Real)2) * slope[ix][2] - slope[ix][3];
262 slope[ix][0] = ((Real)2) * slope[ix][1] - slope[ix][2];
263 slope[ix][mYBound + 1] = ((Real)2) * slope[ix][
mYBound] - slope[ix][mYBound - 1];
264 slope[ix][mYBound + 2] = ((Real)2) * slope[ix][mYBound + 1] - slope[ix][
mYBound];
267 for (ix = 0; ix <
mXBound; ++ix)
269 for (iy = 0; iy <
mYBound; ++iy)
276 template <
typename Real>
281 int ix0 = xBoundM1, ix1 = ix0 - 1, ix2 = ix1 - 1;
282 int iy0 = yBoundM1, iy1 = iy0 - 1, iy2 = iy1 - 1;
288 FXY[0][0] = ((Real)0.25)*invDXDY*(
299 FXY[0][xBoundM1] = ((Real)0.25)*invDXDY*(
301 - ((Real)12)*F[0][ix1]
302 + ((Real)3)*F[0][ix2]
303 - ((Real)12)*F[1][ix0]
304 + ((Real)16)*F[1][ix1]
305 - ((Real)4)*F[1][ix2]
306 + ((Real)3)*F[2][ix0]
307 - ((Real)4)*F[2][ix1]
310 FXY[yBoundM1][0] = ((Real)0.25)*invDXDY*(
312 - ((Real)12)*F[iy0][1]
313 + ((Real)3)*F[iy0][2]
314 - ((Real)12)*F[iy1][0]
315 + ((Real)16)*F[iy1][1]
316 - ((Real)4)*F[iy1][2]
317 + ((Real)3)*F[iy2][0]
318 - ((Real)4)*F[iy2][1]
321 FXY[yBoundM1][xBoundM1] = ((Real)0.25)*invDXDY*(
322 ((Real)9)*F[iy0][ix0]
323 - ((Real)12)*F[iy0][ix1]
324 + ((Real)3)*F[iy0][ix2]
325 - ((Real)12)*F[iy1][ix0]
326 + ((Real)16)*F[iy1][ix1]
327 - ((Real)4)*F[iy1][ix2]
328 + ((Real)3)*F[iy2][ix0]
329 - ((Real)4)*F[iy2][ix1]
333 for (ix = 1; ix < xBoundM1; ++ix)
335 FXY[0][ix] = ((Real)0.25)*invDXDY*(
336 ((Real)3)*(F[0][ix - 1] - F[0][ix + 1])
337 - ((Real)4)*(F[1][ix - 1] - F[1][ix + 1])
338 + (F[2][ix - 1] - F[2][ix + 1]));
340 FXY[yBoundM1][ix] = ((Real)0.25)*invDXDY*(
341 ((Real)3)*(F[iy0][ix - 1] - F[iy0][ix + 1])
342 - ((Real)4)*(F[iy1][ix - 1] - F[iy1][ix + 1])
343 + (F[iy2][ix - 1] - F[iy2][ix + 1]));
347 for (iy = 1; iy < yBoundM1; ++iy)
349 FXY[iy][0] = ((Real)0.25)*invDXDY*(
350 ((Real)3)*(F[iy - 1][0] - F[iy + 1][0])
351 - ((Real)4)*(F[iy - 1][1] - F[iy + 1][1])
352 + (F[iy - 1][2] - F[iy + 1][2]));
354 FXY[iy][xBoundM1] = ((Real)0.25)*invDXDY*(
355 ((Real)3)*(F[iy - 1][ix0] - F[iy + 1][ix0])
356 - ((Real)4)*(F[iy - 1][ix1] - F[iy + 1][ix1])
357 + (F[iy - 1][ix2] - F[iy + 1][ix2]));
361 for (iy = 1; iy < yBoundM1; ++iy)
363 for (ix = 1; ix < xBoundM1; ++ix)
365 FXY[iy][ix] = ((Real)0.25)*invDXDY*(F[iy - 1][ix - 1] -
366 F[iy - 1][ix + 1] - F[iy + 1][ix - 1] + F[iy + 1][ix + 1]);
371 template <
typename Real>
377 for (
int iy = 0; iy < yBoundM1; ++iy)
379 for (
int ix = 0; ix < xBoundM1; ++ix)
385 { F[iy][ix], F[iy + 1][ix] },
386 { F[iy][ix + 1], F[iy + 1][ix + 1] }
391 { FX[iy][ix], FX[iy + 1][ix] },
392 { FX[iy][ix + 1], FX[iy + 1][ix + 1] }
397 { FY[iy][ix], FY[iy + 1][ix] },
398 { FY[iy][ix + 1], FY[iy + 1][ix + 1] }
403 { FXY[iy][ix], FXY[iy + 1][ix] },
404 { FXY[iy][ix + 1], FXY[iy + 1][ix + 1] }
412 template <
typename Real>
415 if (slope[1] != slope[2])
417 if (slope[0] != slope[1])
419 if (slope[2] != slope[3])
421 Real ad0 = fabs(slope[3] - slope[2]);
422 Real ad1 = fabs(slope[0] - slope[1]);
423 return (ad0 * slope[1] + ad1 * slope[2]) / (ad0 + ad1);
432 if (slope[2] != slope[3])
438 return ((Real)0.5) * (slope[1] + slope[2]);
448 template <
typename Real>
450 Real
const FX[2][2], Real
const FY[2][2], Real
const FXY[2][2])
454 Real invDX = ((Real)1) / dx, invDX2 = invDX*invDX;
455 Real invDY = ((Real)1) / dy, invDY2 = invDY*invDY;
458 poly.
A(0, 0) = F[0][0];
459 poly.
A(1, 0) = FX[0][0];
460 poly.
A(0, 1) = FY[0][0];
461 poly.
A(1, 1) = FXY[0][0];
463 b0 = (F[1][0] - poly(0, 0, dx, (Real)0))*invDX2;
464 b1 = (FX[1][0] - poly(1, 0, dx, (Real)0))*invDX;
465 poly.
A(2, 0) = ((Real)3)*b0 - b1;
466 poly.
A(3, 0) = (-((Real)2)*b0 + b1)*invDX;
468 b0 = (F[0][1] - poly(0, 0, (Real)0, dy))*invDY2;
469 b1 = (FY[0][1] - poly(0, 1, (Real)0, dy))*invDY;
470 poly.
A(0, 2) = ((Real)3)*b0 - b1;
471 poly.
A(0, 3) = (-((Real)2)*b0 + b1)*invDY;
473 b0 = (FY[1][0] - poly(0, 1, dx, (Real)0))*invDX2;
474 b1 = (FXY[1][0] - poly(1, 1, dx, (Real)0))*invDX;
475 poly.
A(2, 1) = ((Real)3)*b0 - b1;
476 poly.
A(3, 1) = (-((Real)2)*b0 + b1)*invDX;
478 b0 = (FX[0][1] - poly(1, 0, (Real)0, dy))*invDY2;
479 b1 = (FXY[0][1] - poly(1, 1, (Real)0, dy))*invDY;
480 poly.
A(1, 2) = ((Real)3)*b0 - b1;
481 poly.
A(1, 3) = (-((Real)2)*b0 + b1)*invDY;
483 b0 = (F[1][1] - poly(0, 0, dx, dy))*invDX2*invDY2;
484 b1 = (FX[1][1] - poly(1, 0, dx, dy))*invDX*invDY2;
485 b2 = (FY[1][1] - poly(0, 1, dx, dy))*invDX2*invDY;
486 b3 = (FXY[1][1] - poly(1, 1, dx, dy))*invDX*invDY;
487 poly.
A(2, 2) = ((Real)9)*b0 - ((Real)3)*b1 - ((Real)3)*b2 + b3;
488 poly.
A(3, 2) = (-((Real)6)*b0 + ((Real)3)*b1 + ((Real)2)*b2 - b3)*invDX;
489 poly.
A(2, 3) = (-((Real)6)*b0 + ((Real)2)*b1 + ((Real)3)*b2 - b3)*invDY;
490 poly.
A(3, 3) = (((Real)4)*b0 - ((Real)2)*b1 - ((Real)2)*b2 + b3)*invDX*invDY;
493 template <
typename Real>
496 for (xIndex = 0; xIndex + 1 <
mXBound; ++xIndex)
509 template <
typename Real>
512 for (yIndex = 0; yIndex + 1 <
mYBound; ++yIndex)
525 template <
typename Real>
528 memset(&mCoeff[0][0], 0, 16 *
sizeof(Real));
531 template <
typename Real>
534 return mCoeff[ix][iy];
537 template <
typename Real>
541 for (
int i = 0; i <= 3; ++i)
543 B[i] = mCoeff[i][0] + y*(mCoeff[i][1] + y*(mCoeff[i][2] + y*mCoeff[i][3]));
546 return B[0] + x*(B[1] + x*(B[2] + x*B[3]));
549 template <
typename Real>
551 Real
x, Real
y)
const 565 xPow[2] = ((Real)2) *
x;
566 xPow[3] = ((Real)3) * x *
x;
572 xPow[3] = ((Real)6) *
x;
596 yPow[2] = ((Real)2) *
y;
597 yPow[3] = ((Real)3) * y *
y;
603 yPow[3] = ((Real)6) *
y;
616 for (
int iy = 0; iy <= 3; ++iy)
618 for (
int ix = 0; ix <= 3; ++ix)
620 p += mCoeff[ix][iy] * xPow[ix] * yPow[iy];
#define LogAssert(condition, message)