Changes between Initial Version and Version 1 of Ticket #10793

Feb 17, 2011, 3:43:08 PM (12 years ago)
Andrey Novoseltsev

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 #10793

    • Property Component changed from algebraic geometry to linear algebra
    • Property Summary changed from FanMorphism defined by matrices are dangerous to Matrices can be "constructed" from matrices of wrong dimensions
    • Property Priority changed from major to critical
    • Property Owner changed from Alex Ghitza to jason, was
    • Property Type changed from PLEASE CHANGE to defect
  • Ticket #10793 – Description

    initial v1  
    1 Here I use a projection matrix to map a 3d cone to a 2d cone:
     1Let's make a matrix and use it to define a morphism:
    33sage: projection = matrix(ZZ,[[1,0,0],[0,1,0]])
    55[1 0 0]
    66[0 1 0]
    7 sage: cone3d = Cone([(1,0,0),(0,1,0)])
    8 sage: cone2d = Cone([ projection*r for r in cone3d.rays() ])
    9 sage: cone2d.rays()
    10 (N(0, 1), N(1, 0))
    11 }}}
    12 If you use the same matrix in `FanMorphism`, you get an unexpected result:
    13 {{{
    14 sage: FanMorphism( projection, Fan([cone3d]), Fan([cone2d]) )
    15 Fan morphism defined by the matrix
     7sage: H = Hom(ZZ^3, ZZ^2)
     8sage: H(projection)
     9Free module morphism defined by the matrix
    1610[1 0]
    1711[0 0]
    1812[1 0]
    19 Domain fan: Rational polyhedral fan in 3-d lattice N
    20 Codomain fan: Rational polyhedral fan in 2-d lattice N
     13Domain: Ambient free module of rank 3 over the principal ideal domain ...
     14Codomain: Ambient free module of rank 2 over the principal ideal domain ...
    22 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.
    24 For reference, the correct way to construct the morphism is with the transposed matrix.
     16As we see, the matrix of the morphism is very unlikely to be what it should be. Here is the source of the problem:
    26 sage: FanMorphism( projection.transpose(), Fan([cone3d]), Fan([cone2d]) )
    27 Fan morphism defined by the matrix
     18sage: projection.parent()
     19Full MatrixSpace of 2 by 3 dense matrices over Integer Ring
     20sage: M = MatrixSpace(ZZ, 3 , 2)
     21sage: M
     22Full MatrixSpace of 3 by 2 dense matrices over Integer Ring
     23sage: M(projection)
    2824[1 0]
    29 [0 1]
    3025[0 0]
    31 Domain fan: Rational polyhedral fan in 3-d lattice N
    32 Codomain fan: Rational polyhedral fan in 2-d lattice N
     26[1 0]
     28So 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.