# SCM Repository

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

revision 870, Fri Aug 26 17:25:03 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  ## Subsetting : The "missing" cases can be dealt with here, "at the top":  ### --------------------------------------------------------------------------
101    ###
102    ### Subsetting "["  and
103    ### SubAssign  "[<-" : The "missing" cases can be dealt with here, "at the top":
104
105  ## "x[]":  ## "x[]":
106  setMethod("[", signature(x = "Matrix",  setMethod("[", signature(x = "Matrix",
107                           i = "missing", j = "missing", drop = "ANY"),                           i = "missing", j = "missing", drop = "ANY"),
108            function (x, i, j, drop) x)            function (x, i, j, drop) x)

109  ## missing 'drop' --> 'drop = TRUE'  ## missing 'drop' --> 'drop = TRUE'
110  ##                     -----------  ##                     -----------
111  ## select rows  ## select rows
# Line 118  Line 120
120                           drop = "missing"),                           drop = "missing"),
121            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))
122

123  ## "FIXME:"  ## "FIXME:"
124  ## 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?
125  ##  and                A[ LL ]  where LL is a logical *vector*  ##  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"),
# Line 134  Line 148
148                if(da != db)                if(da != db)
149                    stop("Matrices must have same number of rows for cbind()ing")                    stop("Matrices must have same number of rows for cbind()ing")
150            })            })

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