#10793: Matrices can be "constructed" from matrices of wrong dimensions
------------------------------+---------------------------------------------
   Reporter:  vbraun          |          Owner:  jason, was        
       Type:  defect          |         Status:  positive_review   
   Priority:  critical        |      Milestone:  sage-4.7.2        
  Component:  linear algebra  |       Keywords:  sd31              
Work_issues:                  |       Upstream:  N/A               
   Reviewer:  Volker Braun    |         Author:  Andrey Novoseltsev
     Merged:                  |   Dependencies:  #11200            
------------------------------+---------------------------------------------
Changes (by vbraun):

  * status:  needs_review => positive_review
  * reviewer:  => Volker Braun
  * milestone:  sage-4.7.1 => sage-4.7.2


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

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.


 Apply trac_10793_bug_in_matrix_construction.patch,
 trac_10793_fixing_existing_bugs.patch

--

Comment:

 I totally forgot that we haven't merged this ticket yet. Applies fine on
 Sage-4.7.1.rc2. Positive review.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10793#comment:13>
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.

Reply via email to