
Boost : 
From: Paul Giaccone (paulg_at_[hidden])
Date: 20060712 09:30:23
Sebastian Redl wrote:
> Paul Giaccone wrote:
>
>
>> There is a very good reason why the "rule" (actually a
>> relation) is absent in mathematics: namely that it cannot be defined in
>> a meaningful, useful way, as others have already demonstrated. If it
>> can't be done meaningfully in mathematics, it can't be done meaningfully
>> in computer science either.
>>
>>
>>
> That's not true. An ordering cannot be defined for the mathematical
> construct "complex number" that is meaningful and useful to
> mathematicians. That doesn't mean that the same applies to computer
> scientists  it is very well possible to define an operator < for
> std::complex that is useful (allows using the class itself, as well as
> tuples containing it, to be easily used in sorted containers) and
> meaningful (it's lexicographical  it certainly has meaning, even if
> that meaning doesn't make sense to mathematicians).
>
I don't deny that it certainly is possible to define a _useful_
operator, but not one that is meaningful _in the context of what the
class is for_. The "complex" class is for storing and working with
complex numbers. A user wanting to sort 2uples should really be using
"pair" instead.
However, if you want to put complex numbers in a container that requires
its contents to be in some order, then by all means provide a
lexicographical ordering for the sake of necessity. The sorting is then
a computerscientific issue rather than a mathematical one, and there is
then no problem _provided_ the user is made well aware that processing
the contents in the order used by the container does not somehow mean
that the complex numbers themselves have been sorted into that order;
that is, that the ordering is necessary for computing purposes only but
cannot be said to apply to the complex numbers themselves.
In other words, there is a distinction to be made here between the
properties of what is being contained (the complex numbers, which have
no ordering relation) and the container (which requires its elements to
be sortable in some way or other). Once the distinction is made between
the two, there is no longer any contradiction between the way
mathematics and computer science treat complex numbers.
Paul
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk