memfun template

H

Hicham Mouline

Hello,



We have an object which exposes this public interface:



template<typename CurveTraits>

class Curve1D

{

public:

typedef typename CurveTraits::xType xType;

typedef typename CurveTraits::fType fType;



template<typename Interp, typename Extrap>

fType Get(xType abscissa) const;

};





The Get function returns the ordinate (f(x) value corresponding to x :
abscissa) with the help of a Interp(olator) type. If x happens to be outside
the range of points that the object contains, the Extrap(olator) is then
used.



I am now trying to add 2 things:

1. a Get version that takes many x's and returns as many f(x)'s. By
default, it would just iterate over the Get function that takes 1 abscissa.

2. The Get function calls generic functions from the interpolator type. For
some interpolators it is possible to optimize the Get function.



I'm thinking



template<typename CurveTraits> // user supplied

class Curve1D

{

....

template<typename Interp, typename Extrap, // user supplied

typename xIter, typename fIter> // only xIter can be deduced
from the arguments

... Get(xIter xbegin, xIter xend) const;

};

and the question1 is what should the return type. Clearly, whatever choice
will force the caller to respect some rules in terms of mem allocation



Or

template<typename CurveTraits>

class Curve1D

{

....

template<typename Interp, typename Extrap, // user supplied

typename xIter, typename fIter> // xIter and fIter can be
deduced from the arguments

void Get(xIter xbegin, xIter xend, fIter fbegin) const;

};



Question 2 is: how to write the explicit specialization for Interp1 and
Interp2 that takes advantage of the optimized functions available in Interp1
and 2 but not in the other interpolators.



regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,792
Messages
2,569,639
Members
45,353
Latest member
RogerDoger

Latest Threads

Top