#20015: Sanitize matrix constructor
-------------------------------------+-------------------------------------
       Reporter:  jdemeyer           |        Owner:
           Type:  defect             |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-7.1
      Component:  linear algebra     |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Jeroen Demeyer     |    Reviewers:  Nils Bruin, Vincent
Report Upstream:  N/A                |  Delecroix
         Branch:                     |  Work issues:
  u/jdemeyer/ticket/20015            |       Commit:
   Dependencies:                     |  d9e215030b8c8ad6c2707e2f9f16f326362b7c3f
                                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by vdelecroix):

 The error message does not correspond to what is happening with other
 entries
 {{{
 sage: matrix(QQ,2,2,0)
 [0 0]
 [0 0]
 sage: matrix(QQ,2,2,0.0)
 [0 0]
 [0 0]
 sage: matrix(QQ,2,2,'0')
 [0 0]
 [0 0]
 sage: matrix(QQ,2,2,'0.0')
 ...
 TypeError: entries must be coercible to a list or integer
 }}}
 If the data must be coercible then the last 3 should fail. Though, if the
 ring is provided I would be less strict and also allow conversion (and
 make all the above work).

 The following should either work or not work for all rings
 {{{
 sage: matrix(QQ,2,2,'3')
 [3 0]
 [0 3]
 sage: matrix(RBF,2,2,'3')
 [3.000000000000000                 0]
 [                0 3.000000000000000]
 sage: matrix(ZZ,2,2,'3')
 ...
 TypeError: entries has the wrong length
 sage: matrix(QQbar,2,2,'3')
 ...
 TypeError: entries has the wrong length
 }}}
 (there is something weird above since `QQbar('3')` does not work but
 `ZZ('3')` does)

 Similarly, some rings are less strict about input conversion/coercion
 {{{
 sage: matrix(QQbar,2,2,3.0)
 ...
 TypeError: entries must be coercible to a list or the base ring
 sage: matrix(ZZ,2,2,3.0)
 [3 0]
 [0 3]
 }}}

--
Ticket URL: <http://trac.sagemath.org/ticket/20015#comment:25>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to