block sums

17 views
Skip to first unread message

Robert Miller

unread,
Apr 13, 2007, 2:08:36 PM4/13/07
to sage-devel
sage: A = Matrix( GF(2), [[]] )
sage: B = Matrix( GF(2), [[0]] )
sage: A
[]
sage: B
[0]
sage: A.block_sum(B)

[0]
[0]
sage: A = Matrix( GF(2), [] )
sage: A
[]
sage: A.block_sum(B)
[0]

David Harvey

unread,
Apr 13, 2007, 2:18:22 PM4/13/07
to sage-...@googlegroups.com

I don't understand the problem. In all cases, the number of rows of A
plus the number of rows of B equals the number of rows of
A.block_sum(B), and similarly for columns. What am I missing?

david

Robert Miller

unread,
Apr 15, 2007, 3:22:51 PM4/15/07
to sage-devel
There should be no difference between the matrices [[]] and [],
especially if they're printing as the same matrix. There is no
mathematical reason for having a matrix consisting of one row and zero
columns. Even if there were, there doesn't seem to be a way to create
a matrix with zero rows and one column. I'm of the opinion that [[]]
should be treated as having zero rows *and* zero columns.

William Stein

unread,
Apr 16, 2007, 11:54:02 AM4/16/07
to sage-...@googlegroups.com
On 4/15/07, Robert Miller <rlmil...@gmail.com> wrote:
> There should be no difference between the matrices [[]] and [],
> especially if they're printing as the same matrix. There is no
> mathematical reason for having a matrix consisting of one row and zero
> columns.

Yes there is. Most matrix algorithms have as corner cases either
the number of rows or number of columns equal to 0. Two years
ago John Cremona advocated strongly that I allow both cases, so
SAGE would be much more pleasant to use than, say, LiDIA. I've done
so, even though in many cases it was a surprising amount of extra work.
For the record, MAGMA takes the same approach:

sage: magma.RMatrixSpace(RationalField(),0,1)
Full KMatrixSpace of 0 by 1 matrices over Rational Field

> Even if there were, there doesn't seem to be a way to create
> a matrix with zero rows and one column.

Yes there is.

sage: a = matrix(QQ,0,1,[]);
sage: a.nrows(), a.ncols()
(0, 1)


> I'm of the opinion that [[]]
> should be treated as having zero rows *and* zero columns.

No. It has one row [], which has 0 columns.

Printing doesn't determine objects in SAGE, so that a 0,1 and a 0,0 matrix
print the same way isn't convincing.

-- William

> On Apr 13, 11:18 am, David Harvey <dmhar...@math.harvard.edu> wrote:
> > On Apr 13, 2007, at 2:08 PM, Robert Miller wrote:
> >
> > > sage: A = Matrix( GF(2), [[]] )
> > > sage: B = Matrix( GF(2), [[0]] )
> > > sage: A
> > > []
> > > sage: B
> > > [0]
> > > sage: A.block_sum(B)
> >
> > > [0]
> > > [0]
> > > sage: A = Matrix( GF(2), [] )
> > > sage: A
> > > []
> > > sage: A.block_sum(B)
> > > [0]
> >
> > I don't understand the problem. In all cases, the number of rows of A
> > plus the number of rows of B equals the number of rows of
> > A.block_sum(B), and similarly for columns. What am I missing?
> >
> > david
>
>
> >
>


--
William Stein
Associate Professor of Mathematics
University of Washington
http://www.williamstein.org

Reply all
Reply to author
Forward
0 new messages