On Fri, 3 Nov 2006, William Stein wrote:

>
> On Fri, 03 Nov 2006 09:54:14 -0800, Robert Bradshaw
> <[EMAIL PROTECTED]> wrote:
>> I think the problem here is that it _assumes_ that x and y commute,
>> which is not the only option.
>>
>> I am still looking for a convincing reason that
>>
>>      sage: (1/2) * Matrix(ZZ, 2, 2, [1,2,3,4])
>>
>> should not give
>>
>>      [1/2   1]
>>      [3/2   2]
>>
>> in MatrixSpace(QQ, 2, 2). Maybe it's just the cleanliness/
>> implementation of the coercion rules.
>
> In this case there could be a clean coercion rule.  E.g.,
>
> Try standard rules.  If they fail, then:
>
> (1) Check if the base ring of the parent of the left hand
>     side coerces to the parent of the right hand side.
>
> (2) Check if the base ring of the right hand side coerces
>     to the parent of the left hand side.
>
> If exactly one of (1) and (2) succeeds, say (2), then:
>
>     (a) Compute the base extension of the right hand side
>         to the parent of the parent of the left hand side.
>     (b) Do the algebra multiply.
>
> If both succeed, it's ambiguous -- throw an error.
>
> With your
>
>    (1/2) * Matrix(ZZ, 2, 2, [1,2,3,4])
>
> example this gives what you want.
>
> With your
>
>     (1/2) * (x^2 + 1)
>
> with x in ZZ['x'] this also gives what you want.
>
> With
>
>     x * y
>
> with x in ZZ['x'] and y in ZZ['y'] this gives *ambiguous*
> and throws an error.
>
> What do you think?
>
>  -- William
>

This is exactly what I was thinking of before I started about generalizing 
to other rings.

I think this could be rephrased recursively to handle cases like 1/2 * 
ZZ[x][y].

Robert

> >

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to