SCM

SCM Repository

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

Diff of /pkg/R/sparseMatrix.R

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

revision 885, Tue Aug 30 20:54:55 2005 UTC revision 886, Wed Aug 31 17:49:47 2005 UTC
# Line 64  Line 64 
64  ### Subsetting -- basic things (drop = "missing") are done in ./Matrix.R  ### Subsetting -- basic things (drop = "missing") are done in ./Matrix.R
65    
66  ## 1)  dsparse -> dgT  ## 1)  dsparse -> dgT
67  setMethod("[", signature(x = "dsparseMatrix", i = "numeric", j = "missing",  setMethod("[", signature(x = "dsparseMatrix", i = "index", j = "missing",
68                           drop = "logical"),                           drop = "logical"),
69            function (x, i, j, drop)            function (x, i, j, drop)
70            callGeneric(x = as(x, "dgTMatrix"), i=i, drop=drop))            callGeneric(x = as(x, "dgTMatrix"), i=i, drop=drop))
71    
72  setMethod("[", signature(x = "dsparseMatrix", i = "missing", j = "numeric",  setMethod("[", signature(x = "dsparseMatrix", i = "missing", j = "index",
73                           drop = "logical"),                           drop = "logical"),
74            function (x, i, j, drop)            function (x, i, j, drop)
75            callGeneric(x = as(x, "dgTMatrix"), j=j, drop=drop))            callGeneric(x = as(x, "dgTMatrix"), j=j, drop=drop))
76    
77  setMethod("[", signature(x = "dsparseMatrix",  setMethod("[", signature(x = "dsparseMatrix",
78                           i = "numeric", j = "numeric", drop = "logical"),                           i = "index", j = "index", drop = "logical"),
79            function (x, i, j, drop)            function (x, i, j, drop)
80            callGeneric(x = as(x, "dgTMatrix"), i=i, j=j, drop=drop))            callGeneric(x = as(x, "dgTMatrix"), i=i, j=j, drop=drop))
81    
82  ## 2)  lsparse -> lgT  ## 2)  lsparse -> lgT
83  setMethod("[", signature(x = "lsparseMatrix", i = "numeric", j = "missing",  setMethod("[", signature(x = "lsparseMatrix", i = "index", j = "missing",
84                           drop = "logical"),                           drop = "logical"),
85            function (x, i, j, drop)            function (x, i, j, drop)
86            callGeneric(x = as(x, "lgTMatrix"), i=i, drop=drop))            callGeneric(x = as(x, "lgTMatrix"), i=i, drop=drop))
87    
88  setMethod("[", signature(x = "lsparseMatrix", i = "missing", j = "numeric",  setMethod("[", signature(x = "lsparseMatrix", i = "missing", j = "index",
89                           drop = "logical"),                           drop = "logical"),
90            function (x, i, j, drop)            function (x, i, j, drop)
91            callGeneric(x = as(x, "lgTMatrix"), j=j, drop=drop))            callGeneric(x = as(x, "lgTMatrix"), j=j, drop=drop))
92    
93  setMethod("[", signature(x = "lsparseMatrix",  setMethod("[", signature(x = "lsparseMatrix",
94                           i = "numeric", j = "numeric", drop = "logical"),                           i = "index", j = "index", drop = "logical"),
95            function (x, i, j, drop)            function (x, i, j, drop)
96            callGeneric(x = as(x, "lgTMatrix"), i=i, j=j, drop=drop))            callGeneric(x = as(x, "lgTMatrix"), i=i, j=j, drop=drop))
97    
# Line 148  Line 148 
148             invisible(object)             invisible(object)
149         }         }
150     })     })
151    
152    
153    ## not exported:
154    setMethod("isSymmetric", signature(object = "sparseMatrix"),
155              function(object, ...) {
156                  ## pretest: is it square?
157                  d <- dim(object)
158                  if(d[1] != d[2]) return(FALSE)
159                  ## else slower test
160                  if (is(object("dMatrix")))
161                      ## use gC; "T" (triplet) is *not* unique!
162                      isTRUE(all.equal(as(object, "dgCMatrix"),
163                                       as(t(object), "dgCMatrix"), ...))
164                  else if (is(object("lMatrix")))
165                      ## test for exact equality; FIXME(?): identical() too strict?
166                      identical(as(object, "lgCMatrix"),
167                                as(t(object), "lgCMatrix"))
168                  else stop("not yet implemented")
169              })

Legend:
Removed from v.885  
changed lines
  Added in v.886

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