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 1290, Thu Jun 8 09:30:21 2006 UTC revision 1751, Tue Jan 30 17:41:02 2007 UTC
# Line 1  Line 1 
1  #### Toplevel ``virtual'' class "Matrix"  #### Toplevel ``virtual'' class "Matrix"
2    
3    
4    ### Virtual coercions -- via smart "helpers" (-> ./Auxiliaries.R)
5    
6    setAs("Matrix", "sparseMatrix", function(from) as_Csparse(from))
7    setAs("Matrix", "denseMatrix",  function(from) as_dense(from))
8    
9    ## Most of these work; this is a last resort:
10    setAs(from = "Matrix", to = "matrix", # do *not* call base::as.matrix() here:
11          function(from) .bail.out.2("coerce", class(from), class(to)))
12    setAs(from = "matrix", to = "Matrix", function(from) Matrix(from))
13    
14  ## ## probably not needed eventually:  ## ## probably not needed eventually:
15  ## setAs(from = "ddenseMatrix", to = "matrix",  ## setAs(from = "ddenseMatrix", to = "matrix",
16  ##       function(from) {  ##       function(from) {
# Line 12  Line 23 
23  ## for 'Matrix' objects, as.array() should be equivalent:  ## for 'Matrix' objects, as.array() should be equivalent:
24  setMethod("as.array",  signature(x = "Matrix"), function(x) as(x, "matrix"))  setMethod("as.array",  signature(x = "Matrix"), function(x) as(x, "matrix"))
25    
26    ## head and tail apply to all Matrix objects for which subscripting is allowed:
27    setMethod("head", signature(x = "Matrix"), utils::head.matrix)
28    setMethod("tail", signature(x = "Matrix"), utils::tail.matrix)
29    
30    setMethod("drop", signature(x = "Matrix"),
31              function(x) if(all(dim(x) != 1)) x else drop(as(x, "matrix")))
32    
33  ## slow "fall back" method {subclasses should have faster ones}:  ## slow "fall back" method {subclasses should have faster ones}:
34  setMethod("as.vector", signature(x = "Matrix", mode = "missing"),  setMethod("as.vector", signature(x = "Matrix", mode = "missing"),
35            function(x) as.vector(as(x, "matrix")))            function(x) as.vector(as(x, "matrix")))
36    
37    ## mainly need these for "dMatrix" or "lMatrix" respectively, but why not general:
38    setMethod("as.numeric", signature(x = "Matrix"),
39              function(x, ...) as.numeric(as.vector(x)))
40    setMethod("as.logical", signature(x = "Matrix"),
41              function(x, ...) as.logical(as.vector(x)))
42    
43    
44  ## Note that isSymmetric is *not* exported  ## "base" has an isSymmetric() S3-generic since R 2.3.0
 ## but that "base" has an isSymmetric() S3-generic since R 2.3.0  
45  setMethod("isSymmetric", signature(object = "symmetricMatrix"),  setMethod("isSymmetric", signature(object = "symmetricMatrix"),
46            function(object,tol) TRUE)            function(object,tol) TRUE)
47  setMethod("isSymmetric", signature(object = "triangularMatrix"),  setMethod("isSymmetric", signature(object = "triangularMatrix"),
48            ## TRUE iff diagonal:            ## TRUE iff diagonal:
49            function(object,tol) isDiagonal(object))            function(object,tol) isDiagonal(object))
50    
 if(paste(R.version$major, R.version$minor, sep=".") < "2.3")  
     ## need a "matrix" method as in R 2.3 and later  
     setMethod("isSymmetric", signature(object = "matrix"),  
               function(object, tol = 100*.Machine$double.eps, ...)  
           {  
               ## pretest: is it square?  
               d <- dim(object)  
               if(d[1] != d[2]) return(FALSE)  
               ## for `broken' all.equal in R <= 2.2.x:  
               dn <- dimnames(object)  
               if(!identical(dn[1], dn[2])) return(FALSE)  
               test <-  
                   if(is.complex(object))  
                       all.equal.numeric(object, Conj(t(object)), tol = tol, ...)  
                   else              # numeric, character, ..  
                       all.equal(object, t(object), tol = tol, ...)  
               isTRUE(test)  
           })  
   
   
51  setMethod("isTriangular", signature(object = "triangularMatrix"),  setMethod("isTriangular", signature(object = "triangularMatrix"),
52            function(object, ...) TRUE)            function(object, ...) TRUE)
53    
# Line 56  Line 59 
59    
60  setMethod("dim", signature(x = "Matrix"),  setMethod("dim", signature(x = "Matrix"),
61            function(x) x@Dim, valueClass = "integer")            function(x) x@Dim, valueClass = "integer")
62    
63    setMethod("length", "Matrix", function(x) prod(dim(x)))
64    
65  setMethod("dimnames", signature(x = "Matrix"), function(x) x@Dimnames)  setMethod("dimnames", signature(x = "Matrix"), function(x) x@Dimnames)
66    
67    
68  ## not exported but used more than once for "dimnames<-" method :  ## not exported but used more than once for "dimnames<-" method :
69  ## -- or do only once for all "Matrix" classes ??  ## -- or do only once for all "Matrix" classes ??
70  dimnamesGets <- function (x, value) {  dimnamesGets <- function (x, value) {
# Line 75  Line 83 
83  setMethod("unname", signature("Matrix", force="missing"),  setMethod("unname", signature("Matrix", force="missing"),
84            function(obj) { obj@Dimnames <- list(NULL,NULL); obj})            function(obj) { obj@Dimnames <- list(NULL,NULL); obj})
85    
86    setMethod("all", signature(x = "Matrix"),
87              function(x, ..., na.rm) { x <- as(x, "lMatrix"); callGeneric()})
88    setMethod("any", signature(x = "Matrix"),
89              function(x, ..., na.rm) { x <- as(x, "lMatrix"); callGeneric()})
90    
91    setMethod("!", "Matrix", function(e1) !as(e1, "lMatrix"))
92    
93    
94    
95  Matrix <-  Matrix <-
96      function (data = NA, nrow = 1, ncol = 1, byrow = FALSE, dimnames = NULL,      function (data = NA, nrow = 1, ncol = 1, byrow = FALSE, dimnames = NULL,
97                sparse = NULL)                sparse = NULL, forceCheck = FALSE)
98  {  {
99      sparseDefault <- function(m)      sparseDefault <- function(m) prod(dim(m)) > 2*sum(isN0(as(m, "matrix")))
         prod(dim(m)) > 2*sum(as(m, "matrix") != 0)  
100    
101      i.M <- is(data, "Matrix")      i.M <- is(data, "Matrix")
102      if(is.null(sparse) && (i.M || is(data, "matrix")))  
103        if(is.null(sparse1 <- sparse) && (i.M || is(data, "matrix")))
104          sparse <- sparseDefault(data)          sparse <- sparseDefault(data)
105    
106        doDN <- TRUE
107      if (i.M) {      if (i.M) {
108            if(!missing(nrow) || !missing(ncol)|| !missing(byrow))
109                warning("'nrow', 'ncol', etc, are disregarded when 'data' is \"Matrix\" already")
110          sM <- is(data,"sparseMatrix")          sM <- is(data,"sparseMatrix")
111          if((sparse && sM) || (!sparse && !sM))          if(!forceCheck && ((sparse && sM) || (!sparse && !sM)))
112              return(data)              return(data)
113          ## else : convert  dense <-> sparse -> at end          ## else : convert  dense <-> sparse -> at end
114      }      }
# Line 97  Line 117 
117              nrow <- ceiling(length(data)/ncol)              nrow <- ceiling(length(data)/ncol)
118          else if (missing(ncol))          else if (missing(ncol))
119              ncol <- ceiling(length(data)/nrow)              ncol <- ceiling(length(data)/nrow)
120            if(length(data) == 1 && is0(data) && !identical(sparse, FALSE)) {
121                ## Matrix(0, ...) : always sparse unless "sparse = FALSE":
122                if(is.null(sparse)) sparse1 <- sparse <- TRUE
123                ## will be sparse: do NOT construct full matrix!
124                data <- new(if(is.numeric(data)) "dgTMatrix" else
125                            if(is.logical(data)) "lgTMatrix" else
126                            stop("invalid 'data'"),
127                            Dim = as.integer(c(nrow,ncol)),
128                            Dimnames = if(is.null(dimnames)) list(NULL,NULL)
129                            else dimnames)
130            } else { ## normal case
131          data <- .Internal(matrix(data, nrow, ncol, byrow))          data <- .Internal(matrix(data, nrow, ncol, byrow))
132          if(is.null(sparse))          if(is.null(sparse))
133              sparse <- sparseDefault(data)              sparse <- sparseDefault(data)
134          dimnames(data) <- dimnames          dimnames(data) <- dimnames
135      } else if (!is.null(dimnames))          }
136          dimnames(data) <- dimnames          doDN <- FALSE
137        } else if(!missing(nrow) || !missing(ncol)|| !missing(byrow))
138            warning("'nrow', 'ncol', etc, are disregarded for matrix 'data'")
139    
140      ## 'data' is now a "matrix" or "Matrix"      ## 'data' is now a "matrix" or "Matrix"
141        if (doDN && !is.null(dimnames))
142            dimnames(data) <- dimnames
143    
144      ## check for symmetric / triangular / diagonal :      ## check for symmetric / triangular / diagonal :
145      isSym <- isSymmetric(data)      isSym <- isSymmetric(data)
# Line 114  Line 149 
149      if(isDiag)      if(isDiag)
150          isDiag <- isDiagonal(data)          isDiag <- isDiagonal(data)
151    
 ### TODO: Compare with as.Matrix() and its tests in ./dgeMatrix.R  
   
152      ## Find proper matrix class 'cl'      ## Find proper matrix class 'cl'
153      cl <-      cl <-
154          if(isDiag)          if(isDiag && !isTRUE(sparse1))
155              "diagonalMatrix" # -> will automatically check for type              "diagonalMatrix" # -> will automatically check for type
156          else {          else {
157              ## consider it's type              ## consider it's type
# Line 159  Line 192 
192            function(x, y) callGeneric(x, as.matrix(y)))            function(x, y) callGeneric(x, as.matrix(y)))
193    
194  setMethod("%*%", signature(x = "numeric", y = "Matrix"),  setMethod("%*%", signature(x = "numeric", y = "Matrix"),
195            function(x, y) callGeneric(rbind(x), y))            function(x, y) callGeneric(matrix(x, nrow = 1, byrow=TRUE), y))
196    
197  setMethod("crossprod", signature(x = "Matrix", y = "numeric"),  setMethod("crossprod", signature(x = "Matrix", y = "numeric"),
198            function(x, y = NULL) callGeneric(x, as.matrix(y)))            function(x, y = NULL) callGeneric(x, as.matrix(y)))
   
199  setMethod("crossprod", signature(x = "numeric", y = "Matrix"),  setMethod("crossprod", signature(x = "numeric", y = "Matrix"),
200            function(x, y = NULL)  callGeneric(rbind(x), y))            function(x, y = NULL)  callGeneric(as.matrix(x), y))
201    
202    ## The as.matrix() promotion seems illogical to MM,
203    ## but is according to help(tcrossprod, package = "base") :
204    setMethod("tcrossprod", signature(x = "Matrix", y = "numeric"),
205              function(x, y = NULL) callGeneric(x, as.matrix(y)))
206    setMethod("tcrossprod", signature(x = "numeric", y = "Matrix"),
207              function(x, y = NULL)  callGeneric(as.matrix(x), y))
208    
209    ## maybe not optimal
210    setMethod("solve", signature(a = "Matrix", b = "missing"),
211              function(a, b, ...) solve(a, Diagonal(nrow(a))))
212    
213  setMethod("solve", signature(a = "Matrix", b = "numeric"),  setMethod("solve", signature(a = "Matrix", b = "numeric"),
214            function(a, b, ...) callGeneric(a, as.matrix(b)))            function(a, b, ...) callGeneric(a, as.matrix(b)))
215    ## when no sub-class method is found, bail out
216    setMethod("solve", signature(a = "Matrix", b = "matrix"),
217              function(a, b, ...) .bail.out.2("solve", class(a), "matrix"))
218    setMethod("solve", signature(a = "Matrix", b = "Matrix"),
219              function(a, b, ...) .bail.out.2("solve", class(a), class(b)))
220    
221  ## bail-out methods in order to get better error messages  ## bail-out methods in order to get better error messages
222  setMethod("%*%", signature(x = "Matrix", y = "Matrix"),  setMethod("%*%", signature(x = "Matrix", y = "Matrix"),
# Line 180  Line 228 
228            function (x, y = NULL) .bail.out.2(.Generic, class(x), class(y)))            function (x, y = NULL) .bail.out.2(.Generic, class(x), class(y)))
229  setMethod("crossprod", signature(x = "ANY", y = "Matrix"),  setMethod("crossprod", signature(x = "ANY", y = "Matrix"),
230            function (x, y = NULL) .bail.out.2(.Generic, class(x), class(y)))            function (x, y = NULL) .bail.out.2(.Generic, class(x), class(y)))
231    setMethod("tcrossprod", signature(x = "Matrix", y = "ANY"),
232              function (x, y = NULL) .bail.out.2(.Generic, class(x), class(y)))
233    setMethod("tcrossprod", signature(x = "ANY", y = "Matrix"),
234              function (x, y = NULL) .bail.out.2(.Generic, class(x), class(y)))
235    
236    ## cheap fallbacks
237    setMethod("crossprod", signature(x = "Matrix", y = "Matrix"),
238              function(x, y = NULL) t(x) %*% y)
239    setMethod("tcrossprod", signature(x = "Matrix", y = "Matrix"),
240              function(x, y = NULL) x %*% t(y))
241    
242  ## There are special sparse methods; this is a "fall back":  ## There are special sparse methods; this is a "fall back":
243  setMethod("kronecker", signature(X = "Matrix", Y = "ANY",  setMethod("kronecker", signature(X = "Matrix", Y = "ANY",
# Line 192  Line 250 
250                Y <- as(Y, "matrix") ; Matrix(callGeneric()) })                Y <- as(Y, "matrix") ; Matrix(callGeneric()) })
251    
252    
253    ## FIXME: All of these should never be called
254    setMethod("chol", signature(x = "Matrix"),
255              function(x, pivot = FALSE) .bail.out.1(.Generic, class(x)))
256    setMethod("determinant", signature(x = "Matrix"),
257              function(x, logarithm = TRUE) .bail.out.1(.Generic, class(x)))
258    
259    setMethod("diag", signature(x = "Matrix"),
260              function(x, nrow, ncol) .bail.out.1(.Generic, class(x)))
261  setMethod("t", signature(x = "Matrix"),  setMethod("t", signature(x = "Matrix"),
262            function(x) .bail.out.1(.Generic, class(x)))            function(x) .bail.out.1(.Generic, class(x)))
263    
264  ## Group Methods  ## Group Methods
 setMethod("+", signature(e1 = "Matrix", e2 = "missing"), function(e1) e1)  
 ## "fallback":  
 setMethod("-", signature(e1 = "Matrix", e2 = "missing"),  
           function(e1) {  
               warning("inefficient method used for \"- e1\"")  
               0-e1  
           })  
   
 ## bail-outs:  
 setMethod("Compare", signature(e1 = "Matrix", e2 = "Matrix"),  
           function(e1, e2) {  
               d <- dimCheck(e1,e2)  
               .bail.out.2(.Generic, class(e1), class(e2))  
           })  
 setMethod("Compare", signature(e1 = "Matrix", e2 = "ANY"),  
           function(e1, e2) .bail.out.2(.Generic, class(e1), class(e2)))  
 setMethod("Compare", signature(e1 = "ANY", e2 = "Matrix"),  
           function(e1, e2) .bail.out.2(.Generic, class(e1), class(e2)))  
   
265    
266    ##-> see ./Ops.R
267    
268  ### --------------------------------------------------------------------------  ### --------------------------------------------------------------------------
269  ###  ###
# Line 249  Line 297 
297            function(x,i,j, drop)            function(x,i,j, drop)
298            stop("invalid or not-yet-implemented 'Matrix' subsetting"))            stop("invalid or not-yet-implemented 'Matrix' subsetting"))
299    
300  ##  "logical *vector* indexing, such as  M [ M >= 10 ] :  ## logical indexing, such as M[ M >= 7 ] *BUT* also M[ M[,1] >= 3,],
301  setMethod("[", signature(x = "Matrix", i = "lMatrix", j = "missing",  ## The following is *both* for    M [ <logical>   ]
302                           drop = "ANY"),  ##                 and also for   M [ <logical> , ]
303            function (x, i, j, drop) {  .M.sub.i.logical <- function (x, i, j, drop)
304    {
305        nA <- nargs()
306        if(nA == 2) { ##  M [ M >= 7 ]
307            ## FIXME: when both 'x' and 'i' are sparse, this can be very inefficient
308                as(x, geClass(x))@x[as.vector(i)]                as(x, geClass(x))@x[as.vector(i)]
309                                          # -> error when lengths don't match          ## -> error when lengths don't match
310            })      } else if(nA == 3) { ##  M [ M[,1, drop=FALSE] >= 7, ]
311            stop("not-yet-implemented 'Matrix' subsetting") ## FIXME
312    
313        } else stop("nargs() = ", nA,
314                    ".  Extraneous illegal arguments inside '[ .. ]' ?")
315    }
316    setMethod("[", signature(x = "Matrix", i = "lMatrix", j = "missing",
317                             drop = "ANY"),
318              .M.sub.i.logical)
319  setMethod("[", signature(x = "Matrix", i = "logical", j = "missing",  setMethod("[", signature(x = "Matrix", i = "logical", j = "missing",
320                           drop = "ANY"),                           drop = "ANY"),
321            function (x, i, j, drop) as(x, geClass(x))@x[i])            .M.sub.i.logical)
322    
323    
324    ## A[ ij ]  where ij is (i,j) 2-column matrix :
325    .M.sub.i.2col <- function (x, i, j, drop)
326    {
327        nA <- nargs()
328        if(nA == 2) { ##  M [ cbind(ii,jj) ]
329            if(!is.integer(nc <- ncol(i)))
330                stop("'i' has no integer column number",
331                     " should never happen; please report")
332            if(is.logical(i))
333                return(.M.sub.i.logical(x,i,j,drop))
334            else if(!is.numeric(i) || nc != 2)
335                stop("such indexing must be by logical or 2-column numeric matrix")
336            m <- nrow(i)
337            if(m == 0) return(vector(mode = .type.kind[.M.kind(x)]))
338            ## else
339            i1 <- i[,1]
340            i2 <- i[,2]
341            ## potentially inefficient -- FIXME --
342            unlist(lapply(seq_len(m), function(j) x[i1[j], i2[j]]))
343    
344  ## "FIXME:"      } else stop("nargs() = ", nA,
345  ## How can we get at   A[ ij ]  where ij is (i,j) 2-column matrix?                  ".  Extraneous illegal arguments inside '[ .. ]' ?")
346  ##  and                A[ LL ]  where LL is a logical *vector*  }
347  ## -> [.data.frame uses nargs() - can we do this in the *generic* ?  setMethod("[", signature(x = "Matrix", i = "matrix", j = "missing"),# drop="ANY"
348              .M.sub.i.2col)
349    
350    
351  ### "[<-" : -----------------  ### "[<-" : -----------------
# Line 274  Line 354 
354  setReplaceMethod("[", signature(x = "Matrix", i = "missing", j = "missing",  setReplaceMethod("[", signature(x = "Matrix", i = "missing", j = "missing",
355                                  value = "ANY"),## double/logical/...                                  value = "ANY"),## double/logical/...
356            function (x, value) {            function (x, value) {
357                x@x <- value                ## Fails for 'nMatrix' ... FIXME : make sure have method there
358                  x@x <- rep(value, length = length(x@x))
359                validObject(x)# check if type and lengths above match                validObject(x)# check if type and lengths above match
360                x                x
361            })            })
362    
363  ## Method for all 'Matrix' kinds (rather than incomprehensible error messages);  ## A[ ij ] <- value,  where ij is (i,j) 2-column matrix :
364    ## ----------------   The cheap general method --- FIXME: provide special ones
365    .M.repl.i.2col <- function (x, i, j, value)
366    {
367        nA <- nargs()
368        if(nA == 3) { ##  M [ cbind(ii,jj) ] <- value
369            if(!is.integer(nc <- ncol(i)))
370                stop("'i' has no integer column number",
371                     " should never happen; please report")
372            else if(!is.numeric(i) || nc != 2)
373                stop("such indexing must be by logical or 2-column numeric matrix")
374            if(is.logical(i)) {
375                message(".M.repl.i.2col(): drop 'matrix' case ...")
376                i <- c(i) # drop "matrix"
377                return( callNextMethod() )
378            }
379            if(!is.integer(i)) storage.mode(i) <- "integer"
380            if(any(i < 0))
381                stop("negative values are not allowed in a matrix subscript")
382            if(any(is.na(i)))
383                stop("NAs are not allowed in subscripted assignments")
384            if(any(i0 <- (i == 0))) # remove them
385                i <- i[ - which(i0, arr.ind = TRUE)[,"row"], ]
386            ## now have integer i >= 1
387            m <- nrow(i)
388            ## mod.x <- .type.kind[.M.kind(x)]
389            if(length(value) > 0 && m %% length(value) != 0)
390                warning("number of items to replace is not a multiple of replacement length")
391            ## recycle:
392            value <- rep(value, length = m)
393            i1 <- i[,1]
394            i2 <- i[,2]
395            ## inefficient -- FIXME -- (also loses "symmetry" unnecessarily)
396            for(k in seq_len(m))
397                x[i1[k], i2[k]] <- value[k]
398    
399            x
400        } else stop("nargs() = ", nA,
401                    ".  Extraneous illegal arguments inside '[ .. ]' ?")
402    }
403    
404    setReplaceMethod("[", signature(x = "Matrix", i = "matrix", j = "missing",
405                                    value = "replValue"),
406              .M.repl.i.2col)
407    
408    
409    setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY",
410                                    value = "Matrix"),
411                     function (x, i, j, value) {
412    ### *TEMPORARY* diagnostic output:
413    ##                  cat("<Matrix1>[i,j] <- <Matrix1>:\n<Matrix1> = x :")
414    ##                  str(x)
415    ##                  cat("<Matrix2> = value :")
416    ##                  str(value)
417    ##                  cat("i :"); if(!missing(i)) str(i) else cat("<missing>\n")
418    ##                  cat("j :"); if(!missing(j)) str(j) else cat("<missing>\n")
419    
420                         callGeneric(x=x, i=i, j=j, value = as.vector(value))
421                     })
422    setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY",
423                                    value = "Matrix"),
424                     function (x, i, j, value)
425                     callGeneric(x=x, i=i, j=j, value = as.vector(value)))
426    
427    setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY",
428                                    value = "matrix"),
429                     function (x, i, j, value)
430                     callGeneric(x=x, i=i, j=j, value = c(value)))
431    
432  ## (ANY,ANY,ANY) is used when no `real method' is implemented :  ## (ANY,ANY,ANY) is used when no `real method' is implemented :
433  setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY",  setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY",
434                                  value = "ANY"),                                  value = "ANY"),
435            function (x, i, j, value) {            function (x, i, j, value) {
436                if(!is.atomic(value))                if(!is.atomic(value))
437                    stop("RHS 'value' must match matrix class ", class(x))                    stop(sprintf("RHS 'value' (class %s) matches 'ANY', but must match matrix class %s",
438                                   class(value),class(x)))
439                else stop("not-yet-implemented 'Matrix[<-' method")                else stop("not-yet-implemented 'Matrix[<-' method")
440            })            })
   
   
 ## The trivial methods :  
 setMethod("cbind2", signature(x = "Matrix", y = "NULL"),  
           function(x, y) x)  
 setMethod("cbind2", signature(x = "Matrix", y = "missing"),  
           function(x, y) x)  
 setMethod("cbind2", signature(x = "NULL", y="Matrix"),  
           function(x, y) x)  
   
 setMethod("rbind2", signature(x = "Matrix", y = "NULL"),  
           function(x, y) x)  
 setMethod("rbind2", signature(x = "Matrix", y = "missing"),  
           function(x, y) x)  
 setMethod("rbind2", signature(x = "NULL", y="Matrix"),  
           function(x, y) x)  
   
 ## Makes sure one gets x decent error message for the unimplemented cases:  
 setMethod("cbind2", signature(x = "Matrix", y = "Matrix"),  
           function(x, y) {  
               rowCheck(x,y)  
               stop(gettextf("cbind2() method for (%s,%s) not-yet defined",  
                             class(x), class(y)))  
           })  
   
 ## Use a working fall back {particularly useful for sparse}:  
 ## FIXME: implement rbind2 via "cholmod" for C* and Tsparse ones  
 setMethod("rbind2", signature(x = "Matrix", y = "Matrix"),  
           function(x, y) {  
               colCheck(x,y)  
               t(cbind2(t(x), t(y)))  
           })  

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

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