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 511, Fri Feb 4 23:44:00 2005 UTC revision 512, Fri Feb 4 23:45:12 2005 UTC
# Line 1  Line 1 
1  setMethod("show", signature(object = "Matrix"),  prMatrix <-
2            function(object) print(as(object, "matrix")))      ## private function to be used as show() method possibly more than once
3        function(object) {
4            d <- dim(object)
5            cat(paste(d, collapse= " x "), " Matrix of class ",
6                sQuote(class(object)),"\n", sep='')
7            m <- as(object, "matrix")
8            maxp <- getOption("max.print")
9            if(prod(d) <= maxp) print(m)
10            else { ## d[1] > maxp / d[2] >= nr :
11                nr <- maxp %/% d[2]
12                n2 <- ceiling(nr / 2)
13                print(head(m, max(1, n2)))
14                cat("\n ..........\n\n")
15                print(tail(m, max(1, nr - n2)))
16            }
17            ## DEBUG: cat("str(.):\n") ; str(object)
18            invisible()
19        }
20    
21    setMethod("show", signature(object = "Matrix"), prMatrix)
22    
23  Matrix <-  Matrix <-
24      function (data = NA, nrow = 1, ncol = 1, byrow = FALSE, dimnames = NULL)      function (data = NA, nrow = 1, ncol = 1, byrow = FALSE, dimnames = NULL)
# Line 17  Line 36 
36      as(val, "dgeMatrix")      as(val, "dgeMatrix")
37  }  }
38    
39    
40    if(FALSE) { ##--- never used --
41    
42    ## utility for as.Matrix() :
43  Matrix.class <- function(x, tol = 0, symmetry = TRUE, unit.diagonal = TRUE,  Matrix.class <- function(x, tol = 0, symmetry = TRUE, unit.diagonal = TRUE,
44                           triangularity = c(TRUE, TRUE),                           triangularity = c(TRUE, TRUE),
45                           orthogonality = c(TRUE, TRUE),                           orthogonality = c(TRUE, TRUE),
# Line 67  Line 90 
90      asObject(if (inherits(x, "Matrix")) x else as.matrix(x),      asObject(if (inherits(x, "Matrix")) x else as.matrix(x),
91               Matrix.class(x, tol = tol))               Matrix.class(x, tol = tol))
92  }  }
93    
94    }## never used

Legend:
Removed from v.511  
changed lines
  Added in v.512

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