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 1189, Fri Jan 20 18:13:39 2006 UTC revision 1290, Thu Jun 8 09:30:21 2006 UTC
# Line 46  Line 46 
46    
47    
48  setMethod("isTriangular", signature(object = "triangularMatrix"),  setMethod("isTriangular", signature(object = "triangularMatrix"),
49            function(object,tol) TRUE)            function(object, ...) TRUE)
50  setMethod("isTriangular", signature(object = "matrix"),  
51            .is.triangular)  setMethod("isTriangular", signature(object = "matrix"), isTriMat)
52    
53  setMethod("isDiagonal", signature(object = "matrix"), .is.diagonal)  setMethod("isDiagonal", signature(object = "matrix"), .is.diagonal)
54    
# Line 229  Line 229 
229  setMethod("[", signature(x = "Matrix",  setMethod("[", signature(x = "Matrix",
230                           i = "missing", j = "missing", drop = "ANY"),                           i = "missing", j = "missing", drop = "ANY"),
231            function (x, i, j, drop) x)            function (x, i, j, drop) x)
232    
233  ## missing 'drop' --> 'drop = TRUE'  ## missing 'drop' --> 'drop = TRUE'
234  ##                     -----------  ##                     -----------
235  ## select rows  ## select rows
# Line 248  Line 249 
249            function(x,i,j, drop)            function(x,i,j, drop)
250            stop("invalid or not-yet-implemented 'Matrix' subsetting"))            stop("invalid or not-yet-implemented 'Matrix' subsetting"))
251    
252    ##  "logical *vector* indexing, such as  M [ M >= 10 ] :
253    setMethod("[", signature(x = "Matrix", i = "lMatrix", j = "missing",
254                             drop = "ANY"),
255              function (x, i, j, drop) {
256                  as(x, geClass(x))@x[as.vector(i)]
257                                            # -> error when lengths don't match
258              })
259    
260    setMethod("[", signature(x = "Matrix", i = "logical", j = "missing",
261                             drop = "ANY"),
262              function (x, i, j, drop) as(x, geClass(x))@x[i])
263    
264    
265  ## "FIXME:"  ## "FIXME:"
266  ## 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?
267  ##  and                A[ LL ]  where LL is a logical *vector*  ##  and                A[ LL ]  where LL is a logical *vector*
# Line 276  Line 290 
290            })            })
291    
292    
   
 ## NOTE: the following only works for R 2.2.x (and later) ---  
 ## ----  *and* 'Matrix' must have been *installed* by R >= 2.2.x  
   
 if(paste(R.version$major, R.version$minor, sep=".") >= "2.2") {  
   
293      ## The trivial methods :      ## The trivial methods :
294      setMethod("cbind2", signature(x = "Matrix", y = "NULL"),      setMethod("cbind2", signature(x = "Matrix", y = "NULL"),
295                function(x, y) x)                function(x, y) x)
# Line 312  Line 320 
320                    colCheck(x,y)                    colCheck(x,y)
321                    t(cbind2(t(x), t(y)))                    t(cbind2(t(x), t(y)))
322                })                })
   
 }## R-2.2.x and newer  

Legend:
Removed from v.1189  
changed lines
  Added in v.1290

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