Bi linear interpolation using Maps in C++

Hello,
I am trying to bi-interpolate a 10x10 elements using maps definition, i need to compute the interpolation reslts very very fast.
using the map i can only do a linear interpolation, but the problem is that i have to interpolate on the whole area
my interpolation function is :
std::pair<double, double> interpolate(const std::map<double,double> &data,
double x, double y)
{
typedef std::map< double, double>::const_iterator i_t, i_t2;

i_t i=data.upper_bound(x);
i_t c=data.upper_bound(y);
if(i==data.end())
{
if(c==data.end())
return std::make_pair ((--i)->second ,(--c)->second) ;
else if (c==data.begin())
return std::make_pair((--i)->second , c->second );
else
{i_t lc=c; --lc;

const double deltac=(y- lc->first)/(c->first - lc->first);
return std::make_pair((--i)->second , deltac*c->second +(1-deltac)*lc->second);}

}
if (i==data.begin())
{ if(c==data.end())
{
return std::make_pair((--c)->second, i->second);
}
else if (c==data.begin())
{
return std::make_pair(c->second, i->second);
}
else
{i_t lc=c; --lc;

const double deltac=(y- lc->first)/(c->first - lc->first);
return std::make_pair( deltac*c->second +(1-deltac)*lc->second, i->second);
}


}
i_t l=i; --l;
i_t lc=c; --lc;
const double deltai=(x- l->first)/(i->first - l->first);
const double deltac=(y- lc->first)/(c->first - lc->first);
return std::make_pair(deltai*i->second +(1-deltai)*l->second , deltac*c->second +(1-deltac)*lc->second);
}
it works exactly as it is linear interpolation and i dont know how to solve it, i really need an urgent help, please!
Topic archived. No new replies allowed.