On Jan 18, 2008, at 11:32 AM, William Stein wrote:
>> Let A be a matrix not over ZZ or QQ:
>>
>>   A.adjoint()
>>   A.inverse()
>>
>> are not implemented.
>
> I don't think they should be.   There are already (at least) 3 ways  
> to do this:

Wait a sec.... I agree with David K on the adjoint issue. The adjoint  
doesn't require the fraction field to even be constructed, and it  
makes perfect sense over non-domains.

> sage: A = random_matrix(ZZ,2)
> sage: ~A
>
> [ 1/34  1/17]
> [-6/17  5/17]
> sage: A.__invert__()
>
> [ 1/34  1/17]
> [-6/17  5/17]
> sage: A^(-1)
>
> [ 1/34  1/17]
> [-6/17  5/17]

I vaguely recall being stung several times by the lack of an inverse 
() method. For someone who doesn't know python that well, neither ~  
nor __invert__ are obvious alternatives. I don't think it would hurt  
at all to have an inverse() method.

>>  For x a commutative ring element:
>>
>>   x.inverse()
>>
>> is not implemented even if x^-1 exists.
>
> Same remark as above.
>
>> sage: x = 7
>> sage: type(x)
>> <type 'sage.rings.integer.Integer'>
>> sage: x^-1
>> 1/7
>> sage: type(x^-1)
>> <type 'sage.rings.rational.Rational'>
>> sage: x = -1
>> sage: type(x^-1)
>>
>> Should the field of fractions be created?

Oooh these are hard. We still haven't settled on consistent semantics  
for the power operator. Given the types of A and B, I'm never sure  
what to expect the type of A^B to be. For example:

sage: type(Integer(2)^Rational(2))
<type 'sage.rings.integer.Integer'>

sage: type(Integer(2)^Rational(1/2))
<class 'sage.calculus.calculus.SymbolicArithmetic'>

That really bothers me.

>> Certaily x.inverse() should return an error for non-units.
>
> No it shouldn't.  It should compute the inverse as an element of a  
> natural
> larger structure.

Huh? How do you do this? What's the inverse of 2 mod 6? What is the  
larger structure? If anything it's the localisation, but that's not  
"larger".

david


--~--~---------~--~----~------------~-------~--~----~
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://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to