# SCM Repository

[matrix] Diff of /pkg/R/Matrix.R
 [matrix] / pkg / R / Matrix.R

# Diff of /pkg/R/Matrix.R

revision 1388, Thu Aug 17 22:37:19 2006 UTC revision 1389, Fri Aug 18 13:53:33 2006 UTC
# Line 19  Line 19
19  setMethod("as.array",  signature(x = "Matrix"), function(x) as(x, "matrix"))  setMethod("as.array",  signature(x = "Matrix"), function(x) as(x, "matrix"))
20
21  ## head and tail apply to all Matrix objects for which subscripting is allowed:  ## head and tail apply to all Matrix objects for which subscripting is allowed:
22    if(paste(R.version\$major, R.version\$minor, sep=".") < "2.4") {
24  setMethod("tail", signature(x = "Matrix"), utils:::tail.matrix)  setMethod("tail", signature(x = "Matrix"), utils:::tail.matrix)
25    } else { # R 2.4.0 and newer
27        setMethod("tail", signature(x = "Matrix"), utils::tail.matrix)
28    }
29  ## slow "fall back" method {subclasses should have faster ones}:  ## slow "fall back" method {subclasses should have faster ones}:
30  setMethod("as.vector", signature(x = "Matrix", mode = "missing"),  setMethod("as.vector", signature(x = "Matrix", mode = "missing"),
31            function(x) as.vector(as(x, "matrix")))            function(x) as.vector(as(x, "matrix")))
32
33    ## mainly need these for "dMatrix" or "lMatrix" respectively, but why not general:
34    setMethod("as.numeric", signature(x = "Matrix"),
35              function(x, ...) as.numeric(as.vector(x)))
36    setMethod("as.logical", signature(x = "Matrix"),
37              function(x, ...) as.logical(as.vector(x)))
38
39
40  ## Note that isSymmetric is *not* exported  ## Note that isSymmetric is *not* exported
41  ## but that "base" has an isSymmetric() S3-generic since R 2.3.0  ## but that "base" has an isSymmetric() S3-generic since R 2.3.0

Legend:
 Removed from v.1388 changed lines Added in v.1389