[R] < 0 x 0 matrix >

(Ted Harding) Ted.Harding at manchester.ac.uk
Fri Sep 4 15:51:56 CEST 2009


On 04-Sep-09 10:45:27, Markku Karhunen wrote:
> True. Should have read ?diag.
> 
> However, this provokes a more general question: Is there some way I  
> can declare some scalar and _all its functions_ as matrices?
> 
> For instance, I would like to
> 
> A = as.matrix(0.98)
> B = function(A)
> C = diag(sqrt(B))
> 
> so that all scalars are explicitly [1,1] matrices.
> BR, Markku

Hmmm, it might be a good idea to explain why you want to do this.
For instance:

  M <- matrix(c(1,2,3,4),nrow=2)
  c <- matrix(2,nrow=1)
  c%*%M
  # Error in c %*% M : non-conformable arguments
  c*M
  # Error in c * M : non-conformable arrays
  c+M
  # Error in c + M : non-conformable arrays

So what would you want to use the [1,1]-matrix scalars for, that
cannot be done just using them as numbers?

Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 04-Sep-09                                       Time: 14:51:52
------------------------------ XFMail ------------------------------




More information about the R-help mailing list