SCM

SCM Repository

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

Diff of /pkg/R/Matrix.R

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

revision 875, Sat Aug 27 21:29:21 2005 UTC revision 886, Wed Aug 31 17:49:47 2005 UTC
# Line 40  Line 40 
40  ## should propagate to all subclasses:  ## should propagate to all subclasses:
41  setMethod("as.matrix", signature(x = "Matrix"), function(x) as(x, "matrix"))  setMethod("as.matrix", signature(x = "Matrix"), function(x) as(x, "matrix"))
42    
43    ## Note that isSymmetric is *not* exported
44    setMethod("isSymmetric", signature(object = "symmetricMatrix"),
45              function(object) TRUE)
46    setMethod("isSymmetric", signature(object = "triangularMatrix"),
47              ## FIXME: 'TRUE' if *diagonal*, i.e. return(isDiagonal(object))
48              function(object) FALSE)
49    
50  setMethod("dim", signature(x = "Matrix"),  setMethod("dim", signature(x = "Matrix"),
51            function(x) x@Dim, valueClass = "integer")            function(x) x@Dim, valueClass = "integer")
52  setMethod("dimnames", signature(x = "Matrix"), function(x) x@Dimnames)  setMethod("dimnames", signature(x = "Matrix"), function(x) x@Dimnames)
# Line 102  Line 109 
109  ### Subsetting "["  and  ### Subsetting "["  and
110  ### SubAssign  "[<-" : The "missing" cases can be dealt with here, "at the top":  ### SubAssign  "[<-" : The "missing" cases can be dealt with here, "at the top":
111    
112  ## Using "vector" for indices should allow  ## Using "index" for indices should allow
113  ## integer (numeric), logical, or character (names!) indices :  ## integer (numeric), logical, or character (names!) indices :
114    
115  ## "x[]":  ## "x[]":
# Line 112  Line 119 
119  ## missing 'drop' --> 'drop = TRUE'  ## missing 'drop' --> 'drop = TRUE'
120  ##                     -----------  ##                     -----------
121  ## select rows  ## select rows
122  setMethod("[", signature(x = "Matrix", i = "vector", j = "missing",  setMethod("[", signature(x = "Matrix", i = "index", j = "missing",
123                           drop = "missing"),                           drop = "missing"),
124            function(x,i,j, drop) callGeneric(x, i=i, drop= TRUE))            function(x,i,j, drop) callGeneric(x, i=i, drop= TRUE))
125  ## select columns  ## select columns
126  setMethod("[", signature(x = "Matrix", i = "missing", j = "vector",  setMethod("[", signature(x = "Matrix", i = "missing", j = "index",
127                           drop = "missing"),                           drop = "missing"),
128            function(x,i,j, drop) callGeneric(x, j=j, drop= TRUE))            function(x,i,j, drop) callGeneric(x, j=j, drop= TRUE))
129  setMethod("[", signature(x = "Matrix", i = "vector", j = "vector",  setMethod("[", signature(x = "Matrix", i = "index", j = "index",
130                           drop = "missing"),                           drop = "missing"),
131            function(x,i,j, drop) callGeneric(x, i=i, j=j, drop= TRUE))            function(x,i,j, drop) callGeneric(x, i=i, j=j, drop= TRUE))
132    
# Line 131  Line 138 
138  ## "FIXME:"  ## "FIXME:"
139  ## How can we get at   A[ ij ]  where ij is (i,j) 2-column matrix?  ## How can we get at   A[ ij ]  where ij is (i,j) 2-column matrix?
140  ##  and                A[ LL ]  where LL is a logical *vector*  ##  and                A[ LL ]  where LL is a logical *vector*
141    ## -> [.data.frame uses nargs() - can we do this in the *generic* ?
142    
143    
144  ### "[<-" : -----------------  ### "[<-" : -----------------
145    
146  ## x[] <- value :  ## x[] <- value :
147  setReplaceMethod("[", signature(x = "Matrix", i = "missing", j = "missing",  setReplaceMethod("[", signature(x = "Matrix", i = "missing", j = "missing",
148                                  value = "vector"),##  double/logical/...                                  value = "index"),##  double/logical/...
149            function (x, value) { x@x <- value ; validObject(x); x })            function (x, value) { x@x <- value ; validObject(x); x })
150    
151  ## Otherwise (value is not "vector"): bail out  ## Otherwise (value is not "index"): bail out
152  setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY",  setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY",
153                                  value = "ANY"),                                  value = "ANY"),
154            function (x, i, j, value)            function (x, i, j, value)
155                   if(!is(value,"vector"))                   if(!is(value,"index"))
156                   stop("RHS 'value' must be of class \"vector\"")                   stop("RHS 'value' must be of class \"index\"")
157                   else stop("unimplemented 'Matrix[<-' method"))                   else stop("unimplemented 'Matrix[<-' method"))
158    
159    

Legend:
Removed from v.875  
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