Dear All,
Today I ran into some strange things concerning homomorphisms between free modules over different rings (QQ vs ZZ).
Please geuss which two of the following commands execute without error (using sage 5.0):
(ZZ^2).hom([[2,3],[3,6]],QQ^2)
(QQ^2).hom([[1/3,1/4],[1/3,1/6]],ZZ^2)
(ZZ^2).hom([[1/3,1/4],[1/3,1/6]],QQ^2)
Here are the answers:
sage: (ZZ^2).hom([[2,3],[3,6]],QQ^2) #ok
Free module morphism defined by the matrix
[2 3]
[3 6]
Domain: Ambient free module of rank 2 over the principal ideal domain Integer Ring
Codomain: Vector space of dimension 2 over Rational Field
sage: (QQ^2).hom([[1/3,1/4],[1/3,1/6]],ZZ^2) #should not be possible
Free module morphism defined by the matrix
[1/3 1/4]
[1/3 1/6]
Domain: Vector space of dimension 2 over Rational Field
Codomain: Ambient free module of rank 2 over the principal ideal domain Integer Ring
sage: (ZZ^2).hom([[1/3,1/4],[1/3,1/6]],QQ^2) #goes boom with an error you might have excpected in the previous example
Traceback (most recent call last):
...
TypeError: no conversion of this rational to integer
I wonder if anybody ran into similar things. And whether people are working on this. I tried to search trac but the most related ticket I could find is
http://trac.sagemath.org/sage_trac/ticket/1947 which it about morphisms between vectorspaces over different fields.