Opened 11 years ago

# Matrices can be "constructed" from matrices of wrong dimensions — at Version 1

Reported by: Owned by: vbraun jason, was critical sage-4.7.2 linear algebra sd31 rbeezer, kcrisman N/A

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:1 Changed 11 years ago by novoselt

• Component changed from algebraic geometry to linear algebra
• Description modified (diff)
• Owner changed from AlexGhitza to jason, was
• Priority changed from major to critical
• Summary changed from FanMorphism defined by matrices are dangerous to Matrices can be "constructed" from matrices of wrong dimensions
• Type changed from PLEASE CHANGE to defect

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...

Note: See TracTickets for help on using tickets.