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 2098, Sun Dec 9 00:35:14 2007 UTC revision 2110, Sat Jan 26 20:59:26 2008 UTC
# Line 428  Line 428 
428            .M.sub.i.logical)            .M.sub.i.logical)
429    
430    
431  ## A[ ij ]  where ij is (i,j) 2-column matrix :  ## A[ ij ]  where ij is (i,j) 2-column matrix -- but also when that is logical mat!
432  .M.sub.i.2col <- function (x, i, j, ..., drop)  .M.sub.i.2col <- function (x, i, j, ..., drop)
433  {  {
434      nA <- nargs()      nA <- nargs()
435      if(nA == 2) { ##  M [ cbind(ii,jj) ]      if(nA == 2) { ##  M [ cbind(ii,jj) ] or M [ <logical matrix> ]
436          if(!is.integer(nc <- ncol(i)))          if(!is.integer(nc <- ncol(i)))
437              stop("'i' has no integer column number",              stop(".M.sub.i.2col(): 'i' has no integer column number;\n",
438                   " should never happen; please report")                   " should never happen; please report")
439          if(is.logical(i))          if(is.logical(i))
440              return(.M.sub.i.logical(x,i,j,drop))              return(.M.sub.i.logical(x, i=i)) # call with 2 args!
441          else if(!is.numeric(i) || nc != 2)          else if(!is.numeric(i) || nc != 2)
442              stop("such indexing must be by logical or 2-column numeric matrix")              stop("such indexing must be by logical or 2-column numeric matrix")
443          m <- nrow(i)          m <- nrow(i)
# Line 475  Line 475 
475  .M.repl.i.2col <- function (x, i, j, ..., value)  .M.repl.i.2col <- function (x, i, j, ..., value)
476  {  {
477      nA <- nargs()      nA <- nargs()
478      if(nA == 3) { ##  M [ cbind(ii,jj) ] <- value      if(nA == 3) { ##  M [ cbind(ii,jj) ] <- value  or M [ Lmat ] <- value
479          if(!is.integer(nc <- ncol(i)))          if(!is.integer(nc <- ncol(i)))
480              stop("'i' has no integer column number",              stop(".M.repl.i.2col(): 'i' has no integer column number;\n",
481                   " should never happen; please report")                   " should never happen; please report")
482          else if(!is.numeric(i) || nc != 2)          else if(!is.numeric(i) || nc != 2)
483              stop("such indexing must be by logical or 2-column numeric matrix")              stop("such indexing must be by logical or 2-column numeric matrix")
484          if(is.logical(i)) {          if(is.logical(i)) {
485              message(".M.repl.i.2col(): drop 'matrix' case ...")              message(".M.repl.i.2col(): drop 'matrix' case ...")
486              i <- c(i) # drop "matrix"              ## c(i) : drop "matrix" to logical vector
487              return( callNextMethod() )              return( callGeneric(x, i=c(i), value=value) )
488          }          }
489          if(!is.integer(i)) storage.mode(i) <- "integer"          if(!is.integer(i)) storage.mode(i) <- "integer"
490          if(any(i < 0))          if(any(i < 0))

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

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