[sage-devel] Re: another matrix() corner case for sparse matrices

2008-03-26 Thread William Stein

On Wed, Mar 26, 2008 at 11:01 AM, Jason Grout
[EMAIL PROTECTED] wrote:

  Ryan Hinton brought up a good point at #2651:

  Currently, matrix(3,{(1,1): 2}) gives the 3x2 sparse matrix

  [0 0]
  [0 2]
  [0 0]


  However, for other cases, if we specify just the number of rows, the
  returned matrix is square (except when we are giving all the entries of
  the matrix and there aren't enough entries).  So:

  Should the above command return the following instead?

  [0 0 0]
  [0 2 0]
  [0 0 0]

  Sorry for bringing up the nitpicky corner cases, but since matrix() is
  used in a huge number of things, we don't want to mess something up when
  we replace the constructor.

I very strongly agree that the output of matrix(3,{(1,1): 2})  should be the
sparse matrix:
 [0 0 0]
 [0 2 0]
 [0 0 0]

BTW, there should be an example in the docstring for matrix that illustrates
how to make a dense matrix given a dictionary as input.  E.g.,

sage: matrix(2,{(1,1):5},sparse=False).parent()
Full MatrixSpace of 2 by 2 dense matrices over Integer Ring

 -- William

--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: another matrix() corner case for sparse matrices

2008-03-26 Thread didier deshommes

On Wed, Mar 26, 2008 at 2:01 PM, Jason Grout
[EMAIL PROTECTED] wrote:

  Ryan Hinton brought up a good point at #2651:

  Currently, matrix(3,{(1,1): 2}) gives the 3x2 sparse matrix

  [0 0]
  [0 2]
  [0 0]


  However, for other cases, if we specify just the number of rows, the
  returned matrix is square (except when we are giving all the entries of
  the matrix and there aren't enough entries).  So:

  Should the above command return the following instead?

  [0 0 0]
  [0 2 0]
  [0 0 0]

Yes, I think the matrix should be square way since that is the
behavior for dense matrices.

didier

--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---