On Tue, 18 Oct 2005, Peter Vanbroekhoven wrote:

> Seems that Integer#** tries to compare its argument to zero before
> coercing. Problem is that I don't want this SomeNumberLikeThing to be
> comparable. This is not something very exotic, as not all "number-like"
> things are (totally) ordered, e.g., polynomials, matrices and complex
> numbers. So IMO Integer#** should coerce before doing anything else with
> its argument.

What should happen after coercion? if i do 2**aMatrix, is it required that
the left side gets promoted to a matrix (that is, the same type as the
right-handed argument) ? Then is there any definition of matrix**matrix ?
(i haven't ever used one). It would have to extend the semantics of
scalar**matrix. Maybe I'm just lost too...

But then, x**y = exp(log(x)*y), and since both exp and log are defined on 
matrices (through use of singular value decomposition), this gives us a 
natural definition for aMatrix**anotherMatrix.

> As a side note, Complex#<=> is defined, but it violates the definition
> of an order: Complex(1, 1) >= Complex(1, -1) and Complex(1, 1) <=
> Complex(1, -1) but not Complex(1, 1) == Complex(1, -1), which is a
> violation of the antisymmetry law.

The complex fields (like Q(sqrt(-1)) and C) are not in any way totally
orderable. If you quotient the field in some way then you may obtain
something totally orderable or not, but the best you can get with an
ordinary complex field is a partial order. However Ruby doesn't have a
Semicomparable interface (the name i wanted to give to partial ordering in
Ruby), despite the Module class already supporting most of it in an 
implicit way: think about the meaning of "A<B" as "A is subclass of B" aka 
"A objects are a subset of B objects".

What do you think of this?

____________________________________________________________________
Mathieu Bouchard - t?l:+1.514.383.3801 - http://artengine.ca/matju
Freelance Digital Arts Engineer, Montr?al QC Canada