Hi,

I'm trying to construct a generic Interpolation class, where the
interpolation scheme is 'templated'. Doing this in C++ is trivial, but
I'm having problems porting my design to C#. Here's what I have so
far:

public class Interpolator<Method>
    where Method : IBasisFunction1D
{
    public double Interp(double x, IList<double> xPoints,
IList<double> yPoints)
    {
           return Method.Interpolate(x, xPoints, yPoints);
    }
}

interface IBasisFunction1D
{
     public double Interpolate(double x, IList<double> xPoints,
IList<double> yPoints);
}

public class Linear : IBasisFunction1D
{
     public double Interpolate(double x, IList<double> xPoints,
IList<double> yPoints)     { ..... }
}

public class Piecewise : IBasisFunction1D
{
     public double Interpolate(double x, IList<double> xPoints,
IList<double> yPoints)     { ..... }
}

... and so on .....

Why can't I call member functions of the template class? Do I need to
use a constraint?
Grateful for any suggestions.



Reply via email to