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 2096, Fri Dec 7 17:44:44 2007 UTC revision 2098, Sun Dec 9 00:35:14 2007 UTC
# Line 380  Line 380 
380  setMethod("[", signature(x = "Matrix", i = "index", j = "missing",  setMethod("[", signature(x = "Matrix", i = "index", j = "missing",
381                           drop = "missing"),                           drop = "missing"),
382            function(x,i,j, ..., drop) {            function(x,i,j, ..., drop) {
383                if(nargs() == 1) { ## e.g. M[0] , M[TRUE],  M[1:2]                if(nargs() == 2) { ## e.g. M[0] , M[TRUE],  M[1:2]
384                    if(any(i)) as.vector(x)[i] else as.vector(x[1,1])[FALSE]                    if(any(i) || prod(dim(x)) == 0)
385                } else callGeneric(x, i=i, drop= TRUE)})                        as.vector(x)[i]
386                      else ## save memory
387                          as.vector(x[1,1])[FALSE]
388                  } else {
389                      callGeneric(x, i=i, , drop=TRUE)
390                      ##                  ^^
391                  }
392              })
393    
394  ## select columns  ## select columns
395  setMethod("[", signature(x = "Matrix", i = "missing", j = "index",  setMethod("[", signature(x = "Matrix", i = "missing", j = "index",
# Line 512  Line 519 
519  setReplaceMethod("[", signature(x = "Matrix", i = "missing", j = "ANY",  setReplaceMethod("[", signature(x = "Matrix", i = "missing", j = "ANY",
520                                  value = "Matrix"),                                  value = "Matrix"),
521                   function (x, i, j, ..., value)                   function (x, i, j, ..., value)
522                   callGeneric(x=x, j=j, value = as.vector(value)))                   callGeneric(x=x, , j=j, value = as.vector(value)))
523    
524  setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "missing",  setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "missing",
525                                  value = "Matrix"),                                  value = "Matrix"),
526                   function (x, i, j, ..., value)                   function (x, i, j, ..., value)
527                   callGeneric(x=x, i=i, value = as.vector(value)))                   callGeneric(x=x, i=i, , value = as.vector(value)))
528    
529  setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY",  setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY",
530                                  value = "Matrix"),                                  value = "Matrix"),
# Line 527  Line 534 
534  setReplaceMethod("[", signature(x = "Matrix", i = "missing", j = "ANY",  setReplaceMethod("[", signature(x = "Matrix", i = "missing", j = "ANY",
535                                  value = "matrix"),                                  value = "matrix"),
536                   function (x, i, j, ..., value)                   function (x, i, j, ..., value)
537                   callGeneric(x=x, j=j, value = c(value)))                   callGeneric(x=x, , j=j, value = c(value)))
538    
539  setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "missing",  setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "missing",
540                                  value = "matrix"),                                  value = "matrix"),
541                   function (x, i, j, ..., value)                   function (x, i, j, ..., value)
542                   callGeneric(x=x, i=i, value = c(value)))                   callGeneric(x=x, i=i, , value = c(value)))
543    
544  setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY",  setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY",
545                                  value = "matrix"),                                  value = "matrix"),

Legend:
Removed from v.2096  
changed lines
  Added in v.2098

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