On 06/07/16 16:03, mmarco wrote:
Non units are not interval in the same parent, but might be in a
bigger one (think of the fraction field of a ring). The question is
to have a method that tries to invert the object even if it has to go
to a bigger parent; and a different one that tries to find the
inverse in the same parent, and raises an exception if it doesn't
exist.
Indeed
{{{
sage: parent(~1) # parent changes
Rational Field
sage: parent(1.inverse_of_unit()) # same parent
Integer Ring
sage: 2.inverse_of_unit() # error
Traceback (most recent call last):
...
ZeroDivisionError: Inverse does not exist.
}}}
sided note: I would like the above to actually be an `ArithmeticError`
rather than a `ZeroDivisionError`.
For multiplicative groups, x.__invert__() is internal
(i.e. same parent) and .inverse() is also an alias. For example we have
{{{
sage: SL(2,ZZ).an_element().inverse().parent() is SL(2,ZZ)
True
}}}
And as mentioned by Kwankyu Lee we also have x.inverse() as an alias for
x.__invert__() for matrices. But here, this operation is external (i.e.
it the result has a different parent if the base ring is not a field).
For example
{{{
sage: Mat(ZZ,2).one().inverse().parent() is Mat(QQ,2)
True
}}}
Vincent
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.