Boost logo

Boost :

From: Alberto Ganesh Barbati (abarbati_at_[hidden])
Date: 2006-04-23 20:41:46

Bronek Kozicki ha scritto:
> Alberto Ganesh Barbati wrote:
>> template <typename T>
>> struct compare_absolute_error : std::binary_function<T, T, bool>
>> bool operator()(T x, T y) const { return abs(x - y) < eps; }
>> 1) Is there interest for this?
> I'm not math expert, but I certainly agree that such utility would be useful.
> However, as some standard algorithms need equality comparison, while
> containers need less-than comparison, it would be nice to provide at least
> then both, and make names obvious enough.

I believe less-than comparison are not very useful, in fact. That's
because whatever fuzzy algorithm you use, the induced relation won't be
transitive, so it won't induce a strict-weak ordering. It's true that
also fuzzy equality does not induce an equivalence relation for the same
reason, yet the fuzzy equality is still useful even in absence of that

>> 2) What are the comparison algorithms to include?
> good question. But if comparision algorithm is a template parameter (policy
> class), we do not have to define them all in advance.

Well... if you already had the comparison algorithm to put in a template
parameter, then you won't need a... comparison algorithm! The point here
is exactly to provide a library of ready-made algorithms. Of course some
details might be fine-tunable via policy classes, as suggested by John
Maddock, but not the entire algorithm itself.


Boost list run by bdawes at, gregod at, cpdaniel at, john at