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 607, Fri Mar 4 17:33:03 2005 UTC revision 618, Sat Mar 5 21:20:42 2005 UTC
# Line 1  Line 1 
1  #### Toplevel ``virtual'' class "Matrix"  #### Toplevel ``virtual'' class "Matrix"
2    
3  ## probably not needed eventually:  ## probably not needed eventually:
4  setAs(from = "Matrix", to = "matrix",  setAs(from = "ddenseMatrix", to = "matrix",
5        function(from) {        function(from) {
6            if(length(d <- dim(from)) != 2) stop("dim(.) has not length 2")            if(length(d <- dim(from)) != 2) stop("dim(.) has not length 2")
7            array(as.numeric(NA), dim = d, dimnames = dimnames(from))            array(from@x, dim = d, dimnames = dimnames(from))
8        })        })
9    
 prMatrix <-  
10      ## private function to be used as show() method possibly more than once      ## private function to be used as show() method possibly more than once
11      function(object) {  prMatrix <- function(object) {
12          d <- dim(object)          d <- dim(object)
13          cat(paste(d, collapse= " x "), " Matrix of class ",      cl <- class(object)
14              sQuote(class(object)),"\n", sep='')      cat(paste(d, collapse= " x "), " Matrix of class ", sQuote(cl),
15            "\n", sep='')
16        if(cl == "Matrix") { ## have no data slot
17            cat("Dim = ", d)
18            if(any(sapply(object@Dimnames,length) > 0)) {
19                cat("; Dimnames = ")
20                str(object@Dimnames)
21            }
22            cat("\n")
23        } else { # not "Matrix", hence have data 'x' slot
24          m <- as(object, "matrix")          m <- as(object, "matrix")
25          maxp <- getOption("max.print")          maxp <- getOption("max.print")
26          if(prod(d) <= maxp) print(m)          if(prod(d) <= maxp) print(m)
# Line 24  Line 32 
32              print(tail(m, max(1, nr - n2)))              print(tail(m, max(1, nr - n2)))
33          }          }
34          ## DEBUG: cat("str(.):\n") ; str(object)          ## DEBUG: cat("str(.):\n") ; str(object)
35        }
36          invisible()          invisible()
37      }      }
38    

Legend:
Removed from v.607  
changed lines
  Added in v.618

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