Boost logo

Boost :

From: Jason House (jhouse_at_[hidden])
Date: 2003-04-24 09:56:30


Well, take erf using a single parameter for precision

template <precision = 0.00001>
double erf{};

Then in usage somewhere...

{
  double x2 = erf<0.01>(0);
  double x5 = erf(0);
  cout << round(x2*100)/100.0 << round(x2*1E5)*1E-5 << endl;
  cout << round(x5*100)/100.0 << round(x5*1E5)*1E-5 << endl;
}

Possible output:
1.00 0.99583
1.00 1.00000

The idea is that erf<0.01> only gives a result accurate to 2 decimal
places, while erf or erf<0.00001> gives a result accurate to 5 decimal
places.

That's the basic idea I tried to convey.

Getting multiple performance parameters in would be tougher... and I'm
unsure as to which would be most useful to people... I could imagine
something like trying to specify a time bound and a minimum precision...
possibly causing a compile-time error if there is no available
implementation that can achieve it. Of course, the defining of a time
bound is tricky... As far as precision, an integer number of decimal
places would probably be easier from the implementation standpoint.

Gabriel Dos Reis wrote:
>
> Jason House <jhouse_at_[hidden]> writes:
>
> [...]
>
> | Well, *practical* can mean a number of things to different people.
> | Maybe performance constraints should be template parameters with default
> | values?
>
> Once, you have defined meaning for "perfomance" and workable proposal
> I'd be glad to consider it.
>
> | One possibility being precision?
>
> Could you elaborate on this please?
>
> -- Gaby
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk