0-extent matrices?

Thomas Lumley thomas@biostat.washington.edu
Mon, 13 Apr 1998 18:04:40 -0700 (PDT)


On Sun, 12 Apr 1998, Kurt Hornik wrote:
> 
> Sounds very much like going the Octave/MATLAB way.  I thought we'd
> eventually have a `Matrix' class for such things?

Not really -- this applies to arrays as well and is basically a
programming issue similar to using drop=F when subscripting.  If you
subscript an array and it turns out that the result is empty you still
want as much as possible of the same code to work.  The most important
things are cbind, rbind and t, but it is useful that %*%, chol, solve, and
qr all give sensible results with empty matrices.  I went with m+2 giving
NA, for consistency with real(0)+2, so you do have to explicitly do
m+array(2,dim=dim(m)) or some such if you want elementwise arithmetic
operations on a possibly empty array.  This means very little special case
work is need to handle possibly empty arrays


Thomas Lumley
------------------------
Biostatistics		
Uni of Washington	
Box 357232		
Seattle WA 98195-7232	
------------------------

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