Hi Saul,
On 2014-01-24, Saul Schleimer <[email protected]> wrote:
> Nice to hear from you. This discussion of morphisms is pretty
> convincing. I tried it out, but I think I am doing something wrong.
>
> ...
>
> sage: A = Mat.get_action(Mat, operator.inv); A
> sage: A.codomain()
> ---------------------------------------------------------------------------
> AttributeError Traceback (most recent call last)
><ipython-input-414-ef5880878bbf> in <module>()
> ----> 1 A.codomain()
>
> AttributeError: 'NoneType' object has no attribute 'codomain'
>
> What am I doing wrong?
Nothing. What I said was an attempt to explain why Sage generally uses a
"per parent" and not "per element" approach towards arithmetic/algebra:
It makes the coercion system nicer, and for consistency one might prefer
to have a "per parent" approach even when coercion is actually not
directly involved.
Here, we don't have an action (with two parents/two operands), since
operator.inv is a unary operator. Hence, A in your example is None, and
no coercion of the *matrices* is involved. However, in the underlying
inversion algorithm, I suppose one sometimes has to divide by the
*coefficients* of the matrix, and thus inversion of an integer matrix
naturally leads to a matrix whose coefficients live in the fraction
field of ZZ, even if in the end the coefficients have denominator one.
Inversion is implemented (as usual in Python) by the `__invert__`
method. In the case of matrices, one reads in the documentation:
"""
Return this inverse of this matrix, as a matrix over the fraction
field.
...
"""
In principle it would be legal to have something that is not a morphism
(hence, choose the result's parent based an a "per element" decision),
since it is not part of the coercion system.
I guess, after all it was a conscious design decision that may not be
*forced* by the coercion system, but certainly *suggested* by the coercion
system.
Best regards,
Simon
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/groups/opt_out.