You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sage: V = (QQ^3).span_of_basis([[1,1,0],[1,0,2]]); V
Vector space of degree 3 and dimension 2 over Rational Field
User basis matrix:
[1 1 0]
[1 0 2]
sage: V.hom([V.0, V.1])
Traceback (most recent call last):
...
TypeError: entries has the wrong length
The hom command above should create the identity morphism, since according to the docs hom takes as input a list of the images of the generators. Instead, what is happening is that the list is being turned into a matrix directly. Conclusion, the above just goes boom, since the matrix would have to be 2x2, as V has rank 2. E.g., this works:
sage: V.hom([[1,2],[3,4]], V)
Free module morphism defined by the matrix
[1 2]
[3 4]
Domain: Vector space of degree 3 and dimension 2 over Rational Field
User ...
Codomain: Vector space of degree 3 and dimension 2 over Rational Field
User ...
The really scary thing is that this broken code will accidentally and silently give totally wrong answers in some cases, e.g.,
sage: V = (QQ^2).span_of_basis([[1,2],[3,4]])
sage: I = V.hom([V.0,V.1]); I
Free module morphism defined by the matrix
[1 2]
[3 4]
Domain: Vector space of degree 2 and dimension 2 over Rational Field
User ...
Codomain: Vector space of degree 2 and dimension 2 over Rational Field
User ...
sage: I(V.0)
(7, 10)
sage: V.0
(1, 2)
Notice above that I should be the identity map, but it's most certainly not -- it's the map defined by the matrix [[1,2],[3,4]].
It looks good. I'm having trouble running any doctests (applied to a pre-3.4.1 branch after upgrading) but the examples I tried manually work.
robertwb
changed the title
Bug in free module homomorphism creation
[positive review pending no doctest breakage] Bug in free module homomorphism creation
Apr 24, 2009
Seriously, I did apply this patch to a clean 3.4.1 build on sage.math, run --long doctests, and got no failures.
williamstein
changed the title
[positive review pending no doctest breakage] Bug in free module homomorphism creation
Bug in free module homomorphism creation
Apr 24, 2009
Consider the following
The hom command above should create the identity morphism, since according to the docs hom takes as input a list of the images of the generators. Instead, what is happening is that the list is being turned into a matrix directly. Conclusion, the above just goes boom, since the matrix would have to be 2x2, as V has rank 2. E.g., this works:
The really scary thing is that this broken code will accidentally and silently give totally wrong answers in some cases, e.g.,
Notice above that I should be the identity map, but it's most certainly not -- it's the map defined by the matrix [[1,2],[3,4]].
Component: linear algebra
Issue created by migration from https://trac.sagemath.org/ticket/5886
The text was updated successfully, but these errors were encountered: