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 1673, Mon Nov 6 20:54:26 2006 UTC revision 1707, Thu Dec 21 08:03:05 2006 UTC
# Line 56  Line 56 
56    
57  setMethod("dim", signature(x = "Matrix"),  setMethod("dim", signature(x = "Matrix"),
58            function(x) x@Dim, valueClass = "integer")            function(x) x@Dim, valueClass = "integer")
59    
60  setMethod("dimnames", signature(x = "Matrix"), function(x) x@Dimnames)  setMethod("dimnames", signature(x = "Matrix"), function(x) x@Dimnames)
61    
62    
63  ## not exported but used more than once for "dimnames<-" method :  ## not exported but used more than once for "dimnames<-" method :
64  ## -- or do only once for all "Matrix" classes ??  ## -- or do only once for all "Matrix" classes ??
65  dimnamesGets <- function (x, value) {  dimnamesGets <- function (x, value) {
# Line 75  Line 78 
78  setMethod("unname", signature("Matrix", force="missing"),  setMethod("unname", signature("Matrix", force="missing"),
79            function(obj) { obj@Dimnames <- list(NULL,NULL); obj})            function(obj) { obj@Dimnames <- list(NULL,NULL); obj})
80    
81    setMethod("all", signature(x = "Matrix"),
82              function(x, ..., na.rm) { x <- as(x, "lMatrix"); callNextMethod()})
83    setMethod("any", signature(x = "Matrix"),
84              function(x, ..., na.rm) { x <- as(x, "lMatrix"); callNextMethod()})
85    
86    
87    
88  Matrix <-  Matrix <-
89      function (data = NA, nrow = 1, ncol = 1, byrow = FALSE, dimnames = NULL,      function (data = NA, nrow = 1, ncol = 1, byrow = FALSE, dimnames = NULL,
90                sparse = NULL, forceCheck = FALSE)                sparse = NULL, forceCheck = FALSE)
# Line 396  Line 406 
406    
407  setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY",  setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY",
408                                  value = "Matrix"),                                  value = "Matrix"),
409                     function (x, i, j, value) {
410    ### FIXME: *TEMPORARY* diagnostic output:
411                         cat("<Matrix1>[i,j] <- <Matrix1>:\n<Matrix1> = x :")
412                         str(x)
413                         cat("<Matrix2> = value :")
414                         str(value)
415                         cat("i :"); if(!missing(i)) str(i) else cat("<missing>\n")
416                         cat("j :"); if(!missing(j)) str(j) else cat("<missing>\n")
417    
418                         callGeneric(x=x, i=i, j=j, value = as.vector(value))
419                     })
420    setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY",
421                                    value = "Matrix"),
422                   function (x, i, j, value)                   function (x, i, j, value)
423                   callGeneric(x=x, i=i, j=j, value = as.vector(value)))                   callGeneric(x=x, i=i, j=j, value = as.vector(value)))
424    
425  setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY",  setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY",
426                                  value = "matrix"),                                  value = "matrix"),
427                   function (x, i, j, value)                   function (x, i, j, value)
# Line 421  Line 445 
445            function(x, y) x)            function(x, y) x)
446  setMethod("cbind2", signature(x = "NULL", y="Matrix"),  setMethod("cbind2", signature(x = "NULL", y="Matrix"),
447            function(x, y) x)            function(x, y) x)
448    setMethod("cbind2", signature(x = "Matrix", y = "numeric"),
449              function(x, y) callGeneric(x, as.matrix(y)))
450    setMethod("cbind2", signature(x = "numeric", y = "Matrix"),
451              function(x, y) callGeneric(as.matrix(x), y))
452    setMethod("cbind2", signature(x = "ANY", y = "Matrix"),
453              function(x, y) .bail.out.2(.Generic, class(x), class(y)))
454    setMethod("cbind2", signature(x = "Matrix", y = "ANY"),
455              function(x, y) .bail.out.2(.Generic, class(x), class(y)))
456    
457    
458    
459  setMethod("rbind2", signature(x = "Matrix", y = "NULL"),  setMethod("rbind2", signature(x = "Matrix", y = "NULL"),
460            function(x, y) x)            function(x, y) x)
# Line 428  Line 462 
462            function(x, y) x)            function(x, y) x)
463  setMethod("rbind2", signature(x = "NULL", y="Matrix"),  setMethod("rbind2", signature(x = "NULL", y="Matrix"),
464            function(x, y) x)            function(x, y) x)
465    setMethod("rbind2", signature(x = "Matrix", y = "numeric"),
466              function(x, y) callGeneric(x, matrix(y, nrow = 1)))
467    setMethod("rbind2", signature(x = "numeric", y = "Matrix"),
468              function(x, y) callGeneric(matrix(x, nrow = 1), y))
469    setMethod("rbind2", signature(x = "ANY", y = "Matrix"),
470              function(x, y) .bail.out.2(.Generic, class(x), class(y)))
471    setMethod("rbind2", signature(x = "Matrix", y = "ANY"),
472              function(x, y) .bail.out.2(.Generic, class(x), class(y)))
473    
474  ## Makes sure one gets x decent error message for the unimplemented cases:  ## Makes sure one gets x decent error message for the unimplemented cases:
475  setMethod("cbind2", signature(x = "Matrix", y = "Matrix"),  setMethod("cbind2", signature(x = "Matrix", y = "Matrix"),

Legend:
Removed from v.1673  
changed lines
  Added in v.1707

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