# SCM Repository

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

# Diff of /pkg/R/Matrix.R

revision 848, Thu Aug 11 07:41:59 2005 UTC revision 871, Fri Aug 26 17:26:49 2005 UTC
# Line 97  Line 97
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(..., *)  if(FALSE) ## The following can't work as long as cbind is function(..., *)
144  setMethod("cbind", signature(a = "Matrix", b = "Matrix"),  setMethod("cbind", signature(a = "Matrix", b = "Matrix"),
145            function(a, b, ...) {            function(a, b, ...) {

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