Evaluation eval(const Evaluation& x, const Evaluation& y) const
    {
        typedef MathToolbox<Evaluation> Toolbox;

#ifndef NDEBUG
        if (!applies(x,y))
        {
            OPM_THROW(NumericalProblem,
                       "Attempt to get tabulated value for ("
                       << x << ", " << y
                       << ") on a table of extend "
                       << xMin() << " to " << xMax() << " times "
                       << yMin() << " to " << yMax());
        };
#endif

        Evaluation alpha = xToI(x);
        Evaluation beta = yToJ(y);

        unsigned i = std::max(0U, std::min(static_cast<unsigned>(numX()) - 2,
                                           static_cast<unsigned>(Toolbox::value(alpha))));
        unsigned j = std::max(0U, std::min(static_cast<unsigned>(numY()) - 2,
                                           static_cast<unsigned>(Toolbox::value(beta))));

        alpha -= i;
        beta -= j;

        // bi-linear interpolation
        const Evaluation& s1 = getSamplePoint(i, j)*(1.0 - alpha) + getSamplePoint(i + 1, j)*alpha;
        const Evaluation& s2 = getSamplePoint(i, j + 1)*(1.0 - alpha) + getSamplePoint(i + 1, j + 1)*alpha;
        return s1*(1.0 - beta) + s2*beta;
    }
Esempio n. 2
0
void main ( void )
{
   printf ( "the answer is %d\n", xToI () );
}