"Stuart Golodetz" <sg*******@NdOiSaPlA.pMiPpLeExA.ScEomwrote in message
news:SK******************************@pipex.net...
As far as the first question goes (and just off the top of my head), youthis works well, thank you.
may be able to avoid partially specializing Curve if you define a
templated DataContainer type and partially specialize that instead. In
other words, something like:
template <typename Interpolatorstruct DataContainer;
template <struct DataContainer<Constant>
{
typedef std::map<double,doubletype;
};
etc.
template <typename Interpolator, typename Extrapolator, typename
Integrator>
class Curve
{
// can use (typename) DataContainer<Interpolator>::type here
};
Just a thought anyway...
Note that this provides one possible solution to your problem with the
function signatures: for example, Constant::interpolate now takes a
DataContainer<Constant>& as its first argument, etc.
i have 1 more question:
I would do this:
template <struct DataContainer<Constant>
{
typedef std::map<double,doubletype;
};
and
template <struct DataContainer<Ploynomial>
{
typedef struct {
double* data[2];
size_t size;
} type;
};
However, in Curve<Polynomial>, i have
double& operator(double x); // to insert a new x in the tabulated data
for Constant with map, this is trivial {
return map[x];
}
for Polynomial, with double*[2]
i have to manage it myself, the sorting/inserting into the array,
it seems like redundant work thatt can be done better by stdlib c++
is there a way to get double*[2] frm map<double, double(i cuold write it)
should i keep both map<double, doubleand the double*[2] for the case of
Poynomial,
using the map for inserting, and then using the double*[2] to do the
interpolation
(because it requires random access iterators)
rds,