On Sat, Mar 31, 2012 at 5:50 PM, Tom Bachmann <[email protected]> wrote:
>
> [Sorry to make this become the sort of "tiring discussion" I was warning
> of...]

No problem :-)

> I agree that, mathematically, the operations should be part of the ring
> structure, and not of the elements. But in practice, that is not terribly
> useful. What is easier to read / better OOP practice: ring.multiply(poly1,
> poly2) or poly1*poly2?
>
> In particular it is easy to create ligthweight wrapper classes around
> existing classes if you ever wish to perform other operations than the usual
> ones (see for example class ModularInteger).
>
> I should say that I find designing this kind of stuff highly confusing.
> Since all the "real stuff" is in the elements, why bother with a ring class
> at all? It turns out (every time I try to think about it) that its most
> important role is *conversion*: e.g. creating the correct representation of
> "1".

This is the pragmatic approach to the situation, and I believe that
Ring was implemented with this in mind.  However, I think that if we
do want to implement algebraic structures, we have to have slightly
different thing in focus.

I haven't been following the threads on group theory closely lately,
but I believe everyone agreed to have the group operation tied with
the Group class instead of having it stuffed into the elements.
(Correct me, please, if I am wrong).

While the which one is clearer R.multiply(a, b) or a * b is debatable,
I'd like to stress the fact that, when working with rings (at least
that's what my experience tells me), knowing the information about the
operation is equally important with (or maybe even more important
than) knowing the result of applying the operation to two elements.
For example, the property of a ring having the unit element 1 is
actually a property of the ring multiplication, not of any element of
the underlying set.

Summarising: when you work in concrete rings (integers, reals, etc.)
and focus on elements thereof, the "real" stuff is indeed in elements.
However, if the focus is on the rings themselves, the situation is
utterly different.  Consider, for example, a quite real task of
deciding whether a ring with a given set of generators is commutative
or not.  The focus is on rings.

Obviously, both approaches discussed here are approaches which *work*.
However, we should also choose the approach which is correct and
corresponds to the entities in the situation we want to model.

I don't want to sound obstinate, really :-) It's just that I have yet
to see a solid argument which would prove my position wrong or
inefficient.

Sergiu

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to