[Rd] zero-extent matrices (PR#958)

Prof Brian D Ripley ripley@stats.ox.ac.uk
Thu, 31 May 2001 07:36:02 +0100 (BST)


On Wed, 30 May 2001, Thomas Lumley wrote:

> On 30 May 2001, Peter Dalgaard BSA wrote:
>
> > tlumley@u.washington.edu writes:
> >
> > > In 1.2.3
> > >   matrix(nrow=10,ncol=0)%*%numeric(0)
> > > returns a 10x1 matrix of 0s
> > >
> > > In todays 1.3 it returns a 10x1 matrix of miscellaneous junk.
> > >
> > > While both are probably wrong the latter is causing problems for survival.
> >
> > Acutally, I'd say that the 1.2.3 version is correct (sums over empty
> > sets being zero is a standard convention).
>
> I was thinking that a 10x0 matrix times a 0x0 matrix should be a 10x0
> matrix

It's a 10x0 matrix times a 0x1 matrix.  A length-n vector gets promoted to
a nx1 matrix, and that applies for n=0 too:

> dim(as.matrix(numeric(0)))
[1] 0 1


-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._