SCM

SCM Repository

[matrix] Diff of /pkg/R/ngTMatrix.R
ViewVC logotype

Diff of /pkg/R/ngTMatrix.R

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2004, Tue Jul 17 22:12:30 2007 UTC revision 2005, Wed Jul 18 14:46:20 2007 UTC
# Line 17  Line 17 
17            stopifnot(is.logical(from))            stopifnot(is.logical(from))
18            if(any(is.na(from)))            if(any(is.na(from)))
19                warning("'NA's coerced to 'FALSE' in coercion to logical sparse")                warning("'NA's coerced to 'FALSE' in coercion to logical sparse")
20              dn <- dimnames(from)
21              if(is.null(dn))
22                  dn <- list(NULL,NULL)
23              else dimnames(from) <- NULL # such that which(.) does not see any:
24            ij <- which(from, arr.ind = TRUE) - 1L            ij <- which(from, arr.ind = TRUE) - 1L
25            if(length(ij) == 0) ij <- matrix(ij, 0, 2)            if(length(ij) == 0) ij <- matrix(ij, 0, 2)
26            new("ngTMatrix",            new("ngTMatrix",
27                i = ij[,1],                i = ij[,1],
28                j = ij[,2],                j = ij[,2],
29                Dim = as.integer(dim(from)),                Dim = as.integer(dim(from)),
30                Dimnames = .M.DN(from))                Dimnames = dn)
31            })            })
32    
33    setAs("matrix", "nMatrix", function(from) as(from, "ngTMatrix"))
34    
35    
36  setAs("ngTMatrix", "dgTMatrix",  setAs("ngTMatrix", "dgTMatrix",
37        function(from)        function(from)
38        ## more efficient than        ## more efficient than

Legend:
Removed from v.2004  
changed lines
  Added in v.2005

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