SCM

SCM Repository

[matrix] View of /pkg/R/lgeMatrix.R
ViewVC logotype

View of /pkg/R/lgeMatrix.R

Parent Directory Parent Directory | Revision Log Revision Log


Revision 956 - (download) (annotate)
Fri Sep 30 17:28:00 2005 UTC (14 years ago) by maechler
File size: 799 byte(s)
more coercions; particularly "d" <-> "l"; more tests (and more FIXMEs!); fixing two "index-0 bugs"; ...
setAs("matrix", "lgeMatrix",
      function(from) {
	  new("lgeMatrix",
	      x = as.logical(from),
	      Dim = as.integer(dim(from)),
	      Dimnames =
	      if(!is.null(dn <- dimnames(from))) dn else list(NULL,NULL)
	      )
      })

setAs("lgeMatrix", "matrix",
      function(from) {
	  array(from@x, dim = from@Dim, dimnames = from@Dimnames)
      })


## dense |-> compressed :
setAs("lgeMatrix", "lgTMatrix",
      function(from) {
          ##  cheap but not so efficient:
          ij <- which(as(from,"matrix"), arr.ind = TRUE) - 1:1
          new("lgTMatrix", i = ij[,1], j = ij[,2],
              Dim = from@Dim, Dimnames = from@Dimnames,
              factors = from@factors)
      })

setMethod("as.vector", signature(x = "lgeMatrix", mode = "missing"),
          function(x) x@x)

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge