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 698, Mon Apr 18 20:20:04 2005 UTC revision 871, Fri Aug 26 17:26:49 2005 UTC
# Line 96  Line 96 
96    
97  setMethod("solve", signature(a = "Matrix", b = "numeric"),  setMethod("solve", signature(a = "Matrix", b = "numeric"),
98            function(a, b, ...) callGeneric(a, as.matrix(b)))            function(a, b, ...) callGeneric(a, as.matrix(b)))
99    
100    ### --------------------------------------------------------------------------
101    ###
102    ### Subsetting "["  and
103    ### SubAssign  "[<-" : The "missing" cases can be dealt with here, "at the top":
104    
105    ## "x[]":
106    setMethod("[", signature(x = "Matrix",
107                             i = "missing", j = "missing", drop = "ANY"),
108              function (x, i, j, drop) x)
109    ## missing 'drop' --> 'drop = TRUE'
110    ##                     -----------
111    ## select rows
112    setMethod("[", signature(x = "Matrix", i = "numeric", j = "missing",
113                             drop = "missing"),
114              function(x,i,j, drop) callGeneric(x, i=i, drop= TRUE))
115    ## select columns
116    setMethod("[", signature(x = "Matrix", i = "missing", j = "numeric",
117                             drop = "missing"),
118              function(x,i,j, drop) callGeneric(x, j=j, drop= TRUE))
119    setMethod("[", signature(x = "Matrix", i = "numeric", j = "numeric",
120                             drop = "missing"),
121              function(x,i,j, drop) callGeneric(x, i=i, j=j, drop= TRUE))
122    
123    ## "FIXME:"
124    ## How can we get at   A[ ij ]  where ij is (i,j) 2-column matrix?
125    ##  and                A[ LL ]  where LL is a logical *vector*
126    
127    
128    
129    ### "[<-" : -----------------
130    
131    ## x[] <- value :
132    setReplaceMethod("[", signature(x = "Matrix", i = "missing", j = "missing",
133                                    value = "vector"),##  double/logical/...
134              function (x, value) { x@x <- value ; validObject(x); x })
135    
136    ## Otherwise (value is not "vector"): bail out
137    setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY",
138                                    value = "ANY"),
139              function (x, i, j, value) stop("RHS 'value' must be of class \"vector\""))
140    
141    
142    
143    if(FALSE) ## The following can't work as long as cbind is function(..., *)
144    setMethod("cbind", signature(a = "Matrix", b = "Matrix"),
145              function(a, b, ...) {
146                  da <- Dim(a)
147                  db <- Dim(b)
148                  if(da[1] != db[1])
149                      stop("Matrices must have same number of rows for cbind()ing")
150              })

Legend:
Removed from v.698  
changed lines
  Added in v.871

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