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 1225, Mon Mar 13 14:06:17 2006 UTC revision 1315, Mon Jul 10 16:08:05 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 97  Line 97 
97              nrow <- ceiling(length(data)/ncol)              nrow <- ceiling(length(data)/ncol)
98          else if (missing(ncol))          else if (missing(ncol))
99              ncol <- ceiling(length(data)/nrow)              ncol <- ceiling(length(data)/nrow)
100            if(length(data) == 1 && data == 0 && !identical(sparse,FALSE)) {
101                if(is.null(sparse)) sparse <- TRUE
102                ## will be sparse: do NOT construct full matrix!
103                data <- new(if(is.numeric(data)) "dgTMatrix" else
104                            if(is.logical(data)) "lgTMatrix" else
105                            stop("invalid 'data'"),
106                            Dim = as.integer(c(nrow,ncol)),
107                            Dimnames = if(is.null(dimnames))
108                            list(NULL,NULL) else dimnames)
109            } else { ## normal case
110          data <- .Internal(matrix(data, nrow, ncol, byrow))          data <- .Internal(matrix(data, nrow, ncol, byrow))
111          if(is.null(sparse))          if(is.null(sparse))
112              sparse <- sparseDefault(data)              sparse <- sparseDefault(data)
113          dimnames(data) <- dimnames          dimnames(data) <- dimnames
114            }
115      } else if (!is.null(dimnames))      } else if (!is.null(dimnames))
116          dimnames(data) <- dimnames          dimnames(data) <- dimnames
117    
# Line 192  Line 203 
203                Y <- as(Y, "matrix") ; Matrix(callGeneric()) })                Y <- as(Y, "matrix") ; Matrix(callGeneric()) })
204    
205    
206    setMethod("diag", signature(x = "Matrix"),
207              function(x, nrow, ncol) .bail.out.1(.Generic, class(x)))
208  setMethod("t", signature(x = "Matrix"),  setMethod("t", signature(x = "Matrix"),
209            function(x) .bail.out.1(.Generic, class(x)))            function(x) .bail.out.1(.Generic, class(x)))
210    
# Line 290  Line 303 
303            })            })
304    
305    
   
 ## 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") {  
   
306      ## The trivial methods :      ## The trivial methods :
307      setMethod("cbind2", signature(x = "Matrix", y = "NULL"),      setMethod("cbind2", signature(x = "Matrix", y = "NULL"),
308                function(x, y) x)                function(x, y) x)
# Line 326  Line 333 
333                    colCheck(x,y)                    colCheck(x,y)
334                    t(cbind2(t(x), t(y)))                    t(cbind2(t(x), t(y)))
335                })                })
   
 }## R-2.2.x and newer  

Legend:
Removed from v.1225  
changed lines
  Added in v.1315

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