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.hard...@manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 04-Sep-09 Time: 14:51:52 ------------------------------ XFMail ------------------------------ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.