#10793: Matrices can be "constructed" from matrices of wrong dimensions
------------------------------+---------------------------------------------
Reporter: vbraun | Owner: jason, was
Type: defect | Status: new
Priority: critical | Milestone: sage-4.6.2
Component: linear algebra | Keywords:
Author: | Upstream: N/A
Reviewer: | Merged:
Work_issues: |
------------------------------+---------------------------------------------
Changes (by novoselt):
* component: algebraic geometry => linear algebra
* priority: major => critical
* owner: AlexGhitza => jason, was
* type: PLEASE CHANGE => defect
Old description:
> Here I use a projection matrix to map a 3d cone to a 2d cone:
> {{{
> sage: projection = matrix(ZZ,[[1,0,0],[0,1,0]])
> sage: projection
> [1 0 0]
> [0 1 0]
> sage: cone3d = Cone([(1,0,0),(0,1,0)])
> sage: cone2d = Cone([ projection*r for r in cone3d.rays() ])
> sage: cone2d.rays()
> (N(0, 1), N(1, 0))
> }}}
> If you use the same matrix in `FanMorphism`, you get an unexpected
> result:
> {{{
> sage: FanMorphism( projection, Fan([cone3d]), Fan([cone2d]) )
> Fan morphism defined by the matrix
> [1 0]
> [0 0]
> [1 0]
> Domain fan: Rational polyhedral fan in 3-d lattice N
> Codomain fan: Rational polyhedral fan in 2-d lattice N
> }}}
> Sharp eyes reveal that the matrix is not the one I wanted; I understand
> that Sage expects a left matrix action. But having gotten a matrix of
> the wrong shape, no error is produced. Only a nonsensical output?
> Expected behavior would be an error, stating that the matrix dimensions
> do not match.
>
> For reference, the correct way to construct the morphism is with the
> transposed matrix.
> {{{
> sage: FanMorphism( projection.transpose(), Fan([cone3d]), Fan([cone2d]) )
> Fan morphism defined by the matrix
> [1 0]
> [0 1]
> [0 0]
> Domain fan: Rational polyhedral fan in 3-d lattice N
> Codomain fan: Rational polyhedral fan in 2-d lattice N
> }}}
New description:
Let's make a matrix and use it to define a morphism:
{{{
sage: projection = matrix(ZZ,[[1,0,0],[0,1,0]])
sage: projection
[1 0 0]
[0 1 0]
sage: H = Hom(ZZ^3, ZZ^2)
sage: H(projection)
Free module morphism defined by the matrix
[1 0]
[0 0]
[1 0]
Domain: Ambient free module of rank 3 over the principal ideal domain ...
Codomain: Ambient free module of rank 2 over the principal ideal domain
...
}}}
As we see, the matrix of the morphism is very unlikely to be what it
should be. Here is the source of the problem:
{{{
sage: projection.parent()
Full MatrixSpace of 2 by 3 dense matrices over Integer Ring
sage: M = MatrixSpace(ZZ, 3 , 2)
sage: M
Full MatrixSpace of 3 by 2 dense matrices over Integer Ring
sage: M(projection)
[1 0]
[0 0]
[1 0]
}}}
So the matrix space converts the input to the matrix no matter what (same
with `matrix` command, but inside morphisms matrix spaces are used). I
suppose this will work any time the number of entries in the original and
in the destination is matching. I think that if one really wants to do it,
then this one is very welcome to insert an explicit conversion of a matrix
to a list and then back to a matrix, but the above should raise
exceptions.
--
Comment:
I have completely replaced the original Volker's description since the
problem is unrelated to fan morphisms themselves.
Also I think that this is an extremely dangerous bug and will take the
liberty to elevate its priority...
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10793#comment:1>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.