Changes between Initial Version and Version 1 of Ticket #10793
 Timestamp:
 Feb 17, 2011, 3:43:08 PM (12 years ago)
Legend:
 Unmodified
 Added
 Removed
 Modified

Ticket #10793

Property
Component
changed from
algebraic geometry
tolinear algebra

Property
Summary
changed from
FanMorphism defined by matrices are dangerous
toMatrices can be "constructed" from matrices of wrong dimensions

Property
Priority
changed from
major
tocritical
 Property Owner changed from Alex Ghitza to jason, was

Property
Type
changed from
PLEASE CHANGE
todefect

Property
Component
changed from

Ticket #10793 – Description
initial v1 1 Here I use a projection matrix to map a 3d cone to a 2d cone:1 Let's make a matrix and use it to define a morphism: 2 2 {{{ 3 3 sage: projection = matrix(ZZ,[[1,0,0],[0,1,0]]) … … 5 5 [1 0 0] 6 6 [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 7 sage: H = Hom(ZZ^3, ZZ^2) 8 sage: H(projection) 9 Free module morphism defined by the matrix 16 10 [1 0] 17 11 [0 0] 18 12 [1 0] 19 Domain fan: Rational polyhedral fan in 3d lattice N20 Codomain fan: Rational polyhedral fan in 2d lattice N13 Domain: Ambient free module of rank 3 over the principal ideal domain ... 14 Codomain: Ambient free module of rank 2 over the principal ideal domain ... 21 15 }}} 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. 23 24 For reference, the correct way to construct the morphism is with the transposed matrix. 16 As we see, the matrix of the morphism is very unlikely to be what it should be. Here is the source of the problem: 25 17 {{{ 26 sage: FanMorphism( projection.transpose(), Fan([cone3d]), Fan([cone2d]) ) 27 Fan morphism defined by the matrix 18 sage: projection.parent() 19 Full MatrixSpace of 2 by 3 dense matrices over Integer Ring 20 sage: M = MatrixSpace(ZZ, 3 , 2) 21 sage: M 22 Full MatrixSpace of 3 by 2 dense matrices over Integer Ring 23 sage: M(projection) 28 24 [1 0] 29 [0 1]30 25 [0 0] 31 Domain fan: Rational polyhedral fan in 3d lattice N 32 Codomain fan: Rational polyhedral fan in 2d lattice N 26 [1 0] 33 27 }}} 28 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.