SCM

SCM Repository

[matrix] Diff of /pkg/R/AllClass.R
ViewVC logotype

Diff of /pkg/R/AllClass.R

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 952, Wed Sep 28 19:19:19 2005 UTC revision 953, Wed Sep 28 19:31:36 2005 UTC
# Line 6  Line 6 
6  ## ------------- Virtual Classes ----------------------------------------  ## ------------- Virtual Classes ----------------------------------------
7    
8  ## Mother class of all Matrix objects  ## Mother class of all Matrix objects
9  setClass("Matrix", representation(Dim = "integer", Dimnames = "list",  setClass("Matrix",
10             representation(Dim = "integer", Dimnames = "list", factors = "list",
11                                    "VIRTUAL"),                                    "VIRTUAL"),
12           prototype = prototype(Dim = integer(2), Dimnames = list(NULL,NULL)),           prototype = prototype(Dim = integer(2), Dimnames = list(NULL,NULL)),
13           validity = function(object) {           validity = function(object) {
# Line 48  Line 49 
49           representation(x = "complex", "VIRTUAL"), contains = "Matrix")           representation(x = "complex", "VIRTUAL"), contains = "Matrix")
50    
51  ## Virtual class of dense matrices  ## Virtual class of dense matrices
52  setClass("denseMatrix", representation("VIRTUAL"), contains = "Matrix")  setClass("denseMatrix", representation("VIRTUAL"),
53             contains = "Matrix")
54    
55  ## Virtual class of dense, numeric matrices  ## Virtual class of dense, numeric matrices
56  setClass("ddenseMatrix",  setClass("ddenseMatrix", representation(rcond = "numeric", "VIRTUAL"),
          representation(rcond = "numeric", factors = "list", "VIRTUAL"),  
57           contains = c("dMatrix", "denseMatrix"))           contains = c("dMatrix", "denseMatrix"))
58    
59  ## Virtual class of dense, logical matrices  ## Virtual class of dense, logical matrices
60  setClass("ldenseMatrix",  setClass("ldenseMatrix", representation(x = "logical", "VIRTUAL"),
          representation(x = "logical", factors = "list", "VIRTUAL"),  
61           contains = c("lMatrix", "denseMatrix"))           contains = c("lMatrix", "denseMatrix"))
62    
63  ## virtual SPARSE ------------  ## virtual SPARSE ------------
64    
65  setClass("sparseMatrix", representation(factors = "list", "VIRTUAL"), contains = "Matrix")  setClass("sparseMatrix", representation("VIRTUAL"), contains = "Matrix")
66    
67  ## sparse matrices in Triplet representation (dgT, lgT, ..):  ## sparse matrices in Triplet representation (dgT, lgT, ..):
68  setClass("TsparseMatrix", representation(i = "integer", j = "integer", "VIRTUAL"),  setClass("TsparseMatrix", representation(i = "integer", j = "integer", "VIRTUAL"),
# Line 93  Line 93 
93    
94  ## numeric, dense, non-packed, triangular matrices  ## numeric, dense, non-packed, triangular matrices
95  setClass("dtrMatrix",  setClass("dtrMatrix",
96           ## 'ddense*' before 'dge*' so it can use d* or ddense* methods           ## FIXME?
97           ## WITHOUT a coerce to dge* (losing triangularity)           ##> 'ddense*' before 'dge*' so it can use d* or ddense* methods
98           ##-- gives error from callNextMethod() in crossprod() dispatch {R bug ??}           ##> WITHOUT a coerce to dge* (losing triangularity)
99           ##-- contains = c("ddenseMatrix", "dgeMatrix", "triangularMatrix"),           ##> gives error from callNextMethod() in crossprod() dispatch {R bug?}
100             ##> contains = c("ddenseMatrix", "dgeMatrix", "triangularMatrix"),
101           contains = c("dgeMatrix", "triangularMatrix"),           contains = c("dgeMatrix", "triangularMatrix"),
102           prototype = prototype(uplo = "U", diag = "N"),           prototype = prototype(uplo = "U", diag = "N"),
103           validity = function(object) .Call("dtrMatrix_validate", object)           validity = function(object) .Call("dtrMatrix_validate", object)
# Line 111  Line 112 
112    
113  ## numeric, dense, non-packed symmetric matrices  ## numeric, dense, non-packed symmetric matrices
114  setClass("dsyMatrix",  setClass("dsyMatrix",
115           ## 'ddense*' before 'dge*' so it can use d* or ddense* methods           ## FIXME?
116           ## WITHOUT a coerce to dge* (losing triangularity)           ##> 'ddense*' before 'dge*' so it can use d* or ddense* methods
117           ##-- gives error in crossprod() dispatch           ##> WITHOUT a coerce to dge* (losing triangularity)
118           ##-- contains = c("ddenseMatrix", "dgeMatrix", "symmetricMatrix"),           ##> gives error in crossprod() dispatch
119             ##> contains = c("ddenseMatrix", "dgeMatrix", "symmetricMatrix"),
120           contains = c("dgeMatrix", "symmetricMatrix"),           contains = c("dgeMatrix", "symmetricMatrix"),
121           prototype = prototype(uplo = "U"),           prototype = prototype(uplo = "U"),
122           validity = function(object) .Call("dsyMatrix_validate", object)           validity = function(object) .Call("dsyMatrix_validate", object)
# Line 231  Line 233 
233    
234  ## numeric, sparse, sorted compressed sparse row-oriented general matrices  ## numeric, sparse, sorted compressed sparse row-oriented general matrices
235  setClass("dgRMatrix",  setClass("dgRMatrix",
236           representation(j = "integer", p = "integer", factors = "list"),           representation(j = "integer", p = "integer"),
237           contains = "dsparseMatrix",           contains = "dsparseMatrix",
238           ##TODO: validity = function(object) .Call("dgRMatrix_validate", object)           ##TODO: validity = function(object) .Call("dgRMatrix_validate", object)
239           )           )
# Line 340  Line 342 
342    
343  ##-------------------- permutation ----------------------------------------  ##-------------------- permutation ----------------------------------------
344    
345  setClass("pMatrix", representation(perm = "integer"), contains = "Matrix",  setClass("pMatrix", representation(perm = "integer"),
346             contains = "sparseMatrix",
347           validity = function(object) {           validity = function(object) {
348               dd <- object@Dim               d <- object@Dim
349               n <- dd[1]               if (d[2] != (n <- d[1])) return("pMatrix must be square")
350               perm <- object@perm               perm <- object@perm
              if (dd[2] != n) return("pMatrix must be symmetric")  
351               if (length(perm) != n)               if (length(perm) != n)
352                   return(paste("length of 'perm' slot must be", n))                   return(paste("length of 'perm' slot must be", n))
353               if(n > 0 &&               if(n > 0 &&
# Line 354  Line 356 
356               TRUE               TRUE
357           })           })
358    
359    ### Class Union :  no inheritance, but is(*, <class>) :
360    setClassUnion("packedMatrix",
361                  members = c("dspMatrix", "dppMatrix", "dtpMatrix",
362                   "lspMatrix", "ltpMatrix"))
363    
364    
365  ## --------------------- non-"Matrix" Classes --------------------------------  ## --------------------- non-"Matrix" Classes --------------------------------
366    
367  ## --- "General" (not Matrix at all) ----  ## --- "General" (not Matrix at all) ----

Legend:
Removed from v.952  
changed lines
  Added in v.953

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