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 945, Wed Sep 28 08:54:28 2005 UTC revision 946, Wed Sep 28 08:56:42 2005 UTC
# Line 5  Line 5 
5    
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", representation(Dim = "integer", Dimnames = "list",
10                                    "VIRTUAL"),                                    "VIRTUAL"),
11           prototype = prototype(Dim = integer(2), Dimnames = list(NULL,NULL)),           prototype = prototype(Dim = integer(2), Dimnames = list(NULL,NULL)),
# Line 30  Line 30 
30           representation(uplo = "character", diag = "character",           representation(uplo = "character", diag = "character",
31                          "VIRTUAL"), contains = "Matrix")                          "VIRTUAL"), contains = "Matrix")
32    
33  # Virtual class of numeric matrices  ## Virtual class of numeric matrices
34  setClass("dMatrix",  setClass("dMatrix",
35           representation(x = "numeric", "VIRTUAL"), contains = "Matrix")           representation(x = "numeric", "VIRTUAL"), contains = "Matrix")
36    
37  # Virtual class of integer matrices  ## Virtual class of integer matrices
38  setClass("iMatrix",  setClass("iMatrix",
39           representation(x = "integer", "VIRTUAL"), contains = "Matrix")           representation(x = "integer", "VIRTUAL"), contains = "Matrix")
40    
41  # Virtual class of logical matrices  ## Virtual class of logical matrices
42  setClass("lMatrix", representation("VIRTUAL"), contains = "Matrix")  setClass("lMatrix", representation("VIRTUAL"), contains = "Matrix")
43  ## Note that logical sparse matrices do not need an x slot so the x  ## Note that logical sparse matrices do not need an x slot so the x
44  ## slot is part of the ldenseMatrix class  ## slot is part of the ldenseMatrix class
45    
46  # Virtual class of complex matrices  ## Virtual class of complex matrices
47  setClass("zMatrix", # letter 'z' is as in the names of Lapack subroutines  setClass("zMatrix", # letter 'z' is as in the names of Lapack subroutines
48           representation(x = "complex", "VIRTUAL"), contains = "Matrix")           representation(x = "complex", "VIRTUAL"), contains = "Matrix")
49    
50  # Virtual class of dense matrices  ## Virtual class of dense matrices
51  setClass("denseMatrix", representation("VIRTUAL"), contains = "Matrix")  setClass("denseMatrix", representation("VIRTUAL"), contains = "Matrix")
52    
53  # Virtual class of dense, numeric matrices  ## Virtual class of dense, numeric matrices
54  setClass("ddenseMatrix",  setClass("ddenseMatrix",
55           representation(rcond = "numeric", factors = "list", "VIRTUAL"),           representation(rcond = "numeric", factors = "list", "VIRTUAL"),
56           contains = c("dMatrix", "denseMatrix"))           contains = c("dMatrix", "denseMatrix"))
57    
58  # Virtual class of dense, logical matrices  ## Virtual class of dense, logical matrices
59  setClass("ldenseMatrix",  setClass("ldenseMatrix",
60           representation(x = "logical", factors = "list", "VIRTUAL"),           representation(x = "logical", factors = "list", "VIRTUAL"),
61           contains = c("lMatrix", "denseMatrix"))           contains = c("lMatrix", "denseMatrix"))
# Line 84  Line 84 
84    
85  ##----------------------  DENSE  -----------------------------------------  ##----------------------  DENSE  -----------------------------------------
86    
87  # numeric, dense, general matrices  ## numeric, dense, general matrices
88  setClass("dgeMatrix", contains = "ddenseMatrix",  setClass("dgeMatrix", contains = "ddenseMatrix",
89           ## checks that length( @ x) == prod( @ Dim):           ## checks that length( @ x) == prod( @ Dim):
90           validity = function(object) .Call("dgeMatrix_validate", object)           validity = function(object) .Call("dgeMatrix_validate", object)
91           )           )
92  ## i.e. "dgeMatrix" cannot be packed, but "ddenseMatrix" can ..  ## i.e. "dgeMatrix" cannot be packed, but "ddenseMatrix" can ..
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
97             ## WITHOUT a coerce to dge* (losing triangularity)
98             ##-- gives error from callNextMethod() in crossprod() dispatch {R bug ??}
99             ##-- contains = c("ddenseMatrix", "dgeMatrix", "triangularMatrix"),
100           contains = c("dgeMatrix", "triangularMatrix"),           contains = c("dgeMatrix", "triangularMatrix"),
101           prototype = prototype(uplo = "U", diag = "N"),           prototype = prototype(uplo = "U", diag = "N"),
102           validity = function(object) .Call("dtrMatrix_validate", object)           validity = function(object) .Call("dtrMatrix_validate", object)
103           )           )
104    
105  # numeric, dense, packed, triangular matrices  ## numeric, dense, packed, triangular matrices
106  setClass("dtpMatrix",  setClass("dtpMatrix",
107           contains = c("ddenseMatrix", "triangularMatrix"),           contains = c("ddenseMatrix", "triangularMatrix"),
108           prototype = prototype(uplo = "U", diag = "N"),           prototype = prototype(uplo = "U", diag = "N"),
109           validity = function(object) .Call("dtpMatrix_validate", object)           validity = function(object) .Call("dtpMatrix_validate", object)
110           )           )
111    
112  # numeric, dense, non-packed symmetric matrices  ## numeric, dense, non-packed symmetric matrices
113  setClass("dsyMatrix",  setClass("dsyMatrix",
114             ## 'ddense*' before 'dge*' so it can use d* or ddense* methods
115             ## WITHOUT a coerce to dge* (losing triangularity)
116             ##-- gives error in crossprod() dispatch
117             ##-- contains = c("ddenseMatrix", "dgeMatrix", "symmetricMatrix"),
118           contains = c("dgeMatrix", "symmetricMatrix"),           contains = c("dgeMatrix", "symmetricMatrix"),
119           prototype = prototype(uplo = "U"),           prototype = prototype(uplo = "U"),
120           validity = function(object) .Call("dsyMatrix_validate", object)           validity = function(object) .Call("dsyMatrix_validate", object)
121           )           )
122    
123  # numeric, dense, packed symmetric matrices  ## numeric, dense, packed symmetric matrices
124  setClass("dspMatrix",  setClass("dspMatrix",
125           prototype = prototype(uplo = "U"),           prototype = prototype(uplo = "U"),
126           contains = c("ddenseMatrix", "symmetricMatrix"),           contains = c("ddenseMatrix", "symmetricMatrix"),
127           validity = function(object) .Call("dspMatrix_validate", object)           validity = function(object) .Call("dspMatrix_validate", object)
128           )           )
129    
130  # numeric, dense, non-packed, positive-definite, symmetric matrices  ## numeric, dense, non-packed, positive-definite, symmetric matrices
131  setClass("dpoMatrix", contains = "dsyMatrix",  setClass("dpoMatrix", contains = "dsyMatrix",
132           validity = function(object) .Call("dpoMatrix_validate", object)           validity = function(object) .Call("dpoMatrix_validate", object)
133           )           )
134    
135  # numeric, dense, packed, positive-definite, symmetric matrices  ## numeric, dense, packed, positive-definite, symmetric matrices
136  setClass("dppMatrix", contains = "dspMatrix",  setClass("dppMatrix", contains = "dspMatrix",
137           validity = function(object) .Call("dppMatrix_validate", object)           validity = function(object) .Call("dppMatrix_validate", object)
138           )           )
139    
140  ##----- logical dense Matrices -- e.g. as result of <ddenseMatrix>  COMPARISON  ##----- logical dense Matrices -- e.g. as result of <ddenseMatrix>  COMPARISON
141    
142  # numeric, dense, general matrices  ## numeric, dense, general matrices
143  setClass("lgeMatrix", contains = "ldenseMatrix",  setClass("lgeMatrix", contains = "ldenseMatrix",
144           ## checks that length( @ x) == prod( @ Dim):           ## checks that length( @ x) == prod( @ Dim):
145           validity = function(object) .Call("lgeMatrix_validate", object)           validity = function(object) stopifnot(length(object@x) == prod(object@Dim))
146           )           )
147  ## i.e. "lgeMatrix" cannot be packed, but "ldenseMatrix" can ..  ## i.e. "lgeMatrix" cannot be packed, but "ldenseMatrix" can ..
148    
149  # numeric, dense, non-packed, triangular matrices  ## numeric, dense, non-packed, triangular matrices
150  setClass("ltrMatrix",  setClass("ltrMatrix",
151           contains = c("lgeMatrix", "triangularMatrix"),           contains = c("lgeMatrix", "triangularMatrix"),
152           prototype = prototype(uplo = "U", diag = "N"),           prototype = prototype(uplo = "U", diag = "N"))
          validity = function(object) .Call("ltrMatrix_validate", object)  
          )  
153    
154  # numeric, dense, packed, triangular matrices  ## numeric, dense, packed, triangular matrices
155  setClass("ltpMatrix",  setClass("ltpMatrix",
156           contains = c("ldenseMatrix", "triangularMatrix"),           contains = c("ldenseMatrix", "triangularMatrix"),
157           prototype = prototype(uplo = "U", diag = "N"),           prototype = prototype(uplo = "U", diag = "N")
158           validity = function(object) .Call("ltpMatrix_validate", object)           ## validity: ldense*, triangular*  should suffice
159           )           )
160    
161  # numeric, dense, non-packed symmetric matrices  ## numeric, dense, non-packed symmetric matrices
162  setClass("lsyMatrix",  setClass("lsyMatrix",
163           contains = c("lgeMatrix", "symmetricMatrix"),           contains = c("lgeMatrix", "symmetricMatrix"),
164           prototype = prototype(uplo = "U"),           prototype = prototype(uplo = "U")
165           validity = function(object) .Call("lsyMatrix_validate", object)           ##, validity = function(object) .Call("lsyMatrix_validate", object)
166           )           )
167    
168  # numeric, dense, packed symmetric matrices  ## numeric, dense, packed symmetric matrices
169  setClass("lspMatrix",  setClass("lspMatrix",
170           prototype = prototype(uplo = "U"),           prototype = prototype(uplo = "U"),
171           contains = c("ldenseMatrix", "symmetricMatrix"),           contains = c("ldenseMatrix", "symmetricMatrix"),
172           validity = function(object) .Call("lspMatrix_validate", object)           validity = function(object) .Call("dspMatrix_validate", object)
173             ## "dsp" and "lsp" have the same validate
174           )           )
175    
176  ##-------------------- S P A R S E (non-virtual) --------------------------  ##-------------------- S P A R S E (non-virtual) --------------------------
177    
178  ##---------- numeric sparse matrix classes --------------------------------  ##---------- numeric sparse matrix classes --------------------------------
179    
180  # numeric, sparse, triplet general matrices  ## numeric, sparse, triplet general matrices
181  setClass("dgTMatrix",  setClass("dgTMatrix",
182           contains = c("TsparseMatrix", "dsparseMatrix"),           contains = c("TsparseMatrix", "dsparseMatrix"),
183           validity = function(object) .Call("dgTMatrix_validate", object)           validity = function(object) .Call("dgTMatrix_validate", object)
184           )           )
185    
186  ## Should not have dtTMatrix inherit from dgTMatrix because a dtTMatrix could  ## Should not have dtTMatrix inherit from dgTMatrix because a dtTMatrix could
187  # be less than fully stored if diag = "U".  Methods for the dgTMatrix  ## be less than fully stored if diag = "U".  Methods for the dgTMatrix
188  # class would not produce correct results even though all the slots  ## class would not produce correct results even though all the slots
189  # are present.  ## are present.
190    
191  # numeric, sparse, triplet triangular matrices  ## numeric, sparse, triplet triangular matrices
192  setClass("dtTMatrix",  setClass("dtTMatrix",
193           contains = c("TsparseMatrix", "dsparseMatrix", "triangularMatrix"),           contains = c("TsparseMatrix", "dsparseMatrix", "triangularMatrix"),
194           prototype = prototype(uplo = "U", diag = "N"),           prototype = prototype(uplo = "U", diag = "N"),
# Line 189  Line 196 
196           )           )
197    
198  ## Should not have dsTMatrix inherit from dgTMatrix because a dsTMatrix  ## Should not have dsTMatrix inherit from dgTMatrix because a dsTMatrix
199  # is not fully stored.  Methods for the dgTMatrix class would not  ## is not fully stored.  Methods for the dgTMatrix class would not
200  # produce correct results even though all the slots are present.  ## produce correct results even though all the slots are present.
201    
202  # numeric, sparse, triplet symmetric matrices  ## numeric, sparse, triplet symmetric matrices
203  setClass("dsTMatrix",  setClass("dsTMatrix",
204           contains = c("TsparseMatrix", "dsparseMatrix", "symmetricMatrix"),           contains = c("TsparseMatrix", "dsparseMatrix", "symmetricMatrix"),
205           prototype = prototype(uplo = "U"),           prototype = prototype(uplo = "U"),
206           validity = function(object) .Call("dsTMatrix_validate", object)           validity = function(object) .Call("dsTMatrix_validate", object)
207           )           )
208    
209  # numeric, sparse, sorted compressed sparse column-oriented general matrices  ## numeric, sparse, sorted compressed sparse column-oriented general matrices
210  setClass("dgCMatrix",  setClass("dgCMatrix",
211           contains = c("CsparseMatrix", "dsparseMatrix"),           contains = c("CsparseMatrix", "dsparseMatrix"),
212           prototype = prototype(p = 0:0),# to be valid           prototype = prototype(p = 0:0),# to be valid
# Line 207  Line 214 
214           )           )
215    
216  ## see comments for dtTMatrix above  ## see comments for dtTMatrix above
217  # numeric, sparse, sorted compressed sparse column-oriented triangular matrices  ## numeric, sparse, sorted compressed sparse column-oriented triangular matrices
218  setClass("dtCMatrix",  setClass("dtCMatrix",
219           contains = c("CsparseMatrix", "dsparseMatrix", "triangularMatrix"),           contains = c("CsparseMatrix", "dsparseMatrix", "triangularMatrix"),
220           prototype = prototype(p = 0:0, uplo = "U", diag = "N"),# to be valid           prototype = prototype(p = 0:0, uplo = "U", diag = "N"),# to be valid
# Line 215  Line 222 
222           )           )
223    
224  ## see comments for dsTMatrix above  ## see comments for dsTMatrix above
225  # numeric, sparse, sorted compressed sparse column-oriented symmetric matrices  ## numeric, sparse, sorted compressed sparse column-oriented symmetric matrices
226  setClass("dsCMatrix",  setClass("dsCMatrix",
227           contains = c("CsparseMatrix", "dsparseMatrix", "symmetricMatrix"),           contains = c("CsparseMatrix", "dsparseMatrix", "symmetricMatrix"),
228           prototype = prototype(p = 0:0, uplo = "U"),# to be valid           prototype = prototype(p = 0:0, uplo = "U"),# to be valid
229           validity = function(object) .Call("dsCMatrix_validate", object)           validity = function(object) .Call("dsCMatrix_validate", object)
230           )           )
231    
232  # numeric, sparse, sorted compressed sparse row-oriented general matrices  ## numeric, sparse, sorted compressed sparse row-oriented general matrices
233  setClass("dgRMatrix",  setClass("dgRMatrix",
234           representation(j = "integer", p = "integer", factors = "list"),           representation(j = "integer", p = "integer", factors = "list"),
235           contains = "dsparseMatrix",           contains = "dsparseMatrix",
236           ##TODO: validity = function(object) .Call("dgRMatrix_validate", object)           ##TODO: validity = function(object) .Call("dgRMatrix_validate", object)
237           )           )
238    
239  # numeric, sparse, sorted compressed sparse row-oriented triangular matrices  ## numeric, sparse, sorted compressed sparse row-oriented triangular matrices
240  setClass("dtRMatrix",  setClass("dtRMatrix",
241           contains = c("dgRMatrix", "triangularMatrix"),           contains = c("dgRMatrix", "triangularMatrix"),
242           ##TODO: validity = function(object) .Call("dtRMatrix_validate", object)           ##TODO: validity = function(object) .Call("dtRMatrix_validate", object)
243           )           )
244    
245  # numeric, sparse, sorted compressed sparse row-oriented symmetric matrices  ## numeric, sparse, sorted compressed sparse row-oriented symmetric matrices
246  setClass("dsRMatrix",  setClass("dsRMatrix",
247           contains = c("dgRMatrix", "symmetricMatrix"),           contains = c("dgRMatrix", "symmetricMatrix"),
248           ##TODO: validity = function(object) .Call("dsRMatrix_validate", object)           ##TODO: validity = function(object) .Call("dsRMatrix_validate", object)
# Line 246  Line 253 
253  ## these classes are used in symbolic analysis to determine the  ## these classes are used in symbolic analysis to determine the
254  ## locations of non-zero entries  ## locations of non-zero entries
255    
256  # logical, sparse, triplet general matrices  ## logical, sparse, triplet general matrices
257  setClass("lgTMatrix",  setClass("lgTMatrix",
258           contains = c("TsparseMatrix", "lsparseMatrix"),           contains = c("TsparseMatrix", "lsparseMatrix"),
259           validity = function(object) .Call("lgTMatrix_validate", object)           validity = function(object) .Call("lgTMatrix_validate", object)
260           )           )
261    
262  # logical, sparse, triplet triangular matrices  ## logical, sparse, triplet triangular matrices
263  setClass("ltTMatrix",  setClass("ltTMatrix",
264           contains = c("TsparseMatrix", "lsparseMatrix", "triangularMatrix"),           contains = c("TsparseMatrix", "lsparseMatrix", "triangularMatrix"),
265           validity = function(object) .Call("ltTMatrix_validate", object)           validity = function(object) .Call("ltTMatrix_validate", object)
266           )           )
267    
268  # logical, sparse, triplet symmetric matrices  ## logical, sparse, triplet symmetric matrices
269  setClass("lsTMatrix",  setClass("lsTMatrix",
270           contains = c("TsparseMatrix", "lsparseMatrix", "symmetricMatrix"),           contains = c("TsparseMatrix", "lsparseMatrix", "symmetricMatrix"),
271           validity = function(object) .Call("lsTMatrix_validate", object)           validity = function(object) .Call("lsTMatrix_validate", object)
272           )           )
273    
274  # logical, sparse, sorted compressed sparse column-oriented general matrices  ## logical, sparse, sorted compressed sparse column-oriented general matrices
275  setClass("lgCMatrix",  setClass("lgCMatrix",
276           contains = c("lsparseMatrix", "CsparseMatrix"),           contains = c("lsparseMatrix", "CsparseMatrix"),
277           prototype = prototype(p = 0:0),# to be valid           prototype = prototype(p = 0:0),# to be valid
278           validity = function(object) .Call("lgCMatrix_validate", object)           validity = function(object) .Call("lgCMatrix_validate", object)
279           )           )
280    
281  # logical, sparse, sorted compressed sparse column-oriented triangular matrices  ## logical, sparse, sorted compressed sparse column-oriented triangular matrices
282  setClass("ltCMatrix",  setClass("ltCMatrix",
283           contains = c("lsparseMatrix", "CsparseMatrix", "triangularMatrix"),           contains = c("lsparseMatrix", "CsparseMatrix", "triangularMatrix"),
284           prototype = prototype(p = 0:0, uplo = "U", diag = "N"),# to be valid           prototype = prototype(p = 0:0, uplo = "U", diag = "N"),# to be valid
285           validity = function(object) .Call("ltCMatrix_validate", object)           validity = function(object) .Call("ltCMatrix_validate", object)
286           )           )
287    
288  # logical, sparse, sorted compressed sparse column-oriented symmetric matrices  ## logical, sparse, sorted compressed sparse column-oriented symmetric matrices
289  setClass("lsCMatrix",  setClass("lsCMatrix",
290           contains = c("lsparseMatrix", "CsparseMatrix", "symmetricMatrix"),           contains = c("lsparseMatrix", "CsparseMatrix", "symmetricMatrix"),
291           prototype = prototype(p = 0:0, uplo = "U"),# to be valid           prototype = prototype(p = 0:0, uplo = "U"),# to be valid
292           validity = function(object) .Call("lsCMatrix_validate", object)           validity = function(object) .Call("lsCMatrix_validate", object)
293           )           )
294    
295  # logical, sparse, sorted compressed sparse row-oriented general matrices  ## logical, sparse, sorted compressed sparse row-oriented general matrices
296  setClass("lgRMatrix",  setClass("lgRMatrix",
297           representation(j = "integer", p = "integer"),           representation(j = "integer", p = "integer"),
298           contains = "lsparseMatrix",           contains = "lsparseMatrix",
299           validity = function(object) .Call("lgRMatrix_validate", object)           validity = function(object) .Call("lgRMatrix_validate", object)
300           )           )
301    
302  # logical, sparse, sorted compressed sparse row-oriented triangular matrices  ## logical, sparse, sorted compressed sparse row-oriented triangular matrices
303  setClass("ltRMatrix",  setClass("ltRMatrix",
304           contains = c("lgRMatrix", "triangularMatrix"),           contains = c("lgRMatrix", "triangularMatrix"),
305           validity = function(object) .Call("ltRMatrix_validate", object)           validity = function(object) .Call("ltRMatrix_validate", object)
306           )           )
307    
308  # logical, sparse, sorted compressed sparse row-oriented symmetric matrices  ## logical, sparse, sorted compressed sparse row-oriented symmetric matrices
309  setClass("lsRMatrix",  setClass("lsRMatrix",
310           contains = c("lgRMatrix", "symmetricMatrix"),           contains = c("lgRMatrix", "symmetricMatrix"),
311           validity = function(object) .Call("lsRMatrix_validate", object)           validity = function(object) .Call("lsRMatrix_validate", object)
# Line 368  Line 375 
375           validity = function(object) .Call("LU_validate", object))           validity = function(object) .Call("LU_validate", object))
376    
377  ## Deprecated:  ## Deprecated:
378                         # positive-definite symmetric matrices as matrices                         ## positive-definite symmetric matrices as matrices
379  setClass("pdmatrix", contains="matrix")  setClass("pdmatrix", contains="matrix")
380    
381  #                        # factors of positive-definite symmetric matrices  ##                       # factors of positive-definite symmetric matrices
382  # setClass("pdfactor", representation("matrix", logDet = "numeric"))  ## setClass("pdfactor", representation("matrix", logDet = "numeric"))
383    
384                         # correlation matrices and standard deviations                         ## correlation matrices and standard deviations
385  setClass("corrmatrix", representation("matrix", stdDev = "numeric"))  setClass("corrmatrix", representation("matrix", stdDev = "numeric"))
386    
387  ## -------------------- lmer-related Classes --------------------------------  ## -------------------- lmer-related Classes --------------------------------
# Line 411  Line 418 
418                          devComp = "numeric", # Components of deviance                          devComp = "numeric", # Components of deviance
419                          deviance = "numeric", # Current deviance (ML and REML)                          deviance = "numeric", # Current deviance (ML and REML)
420                          nc = "integer", # number of columns in (augmented)                          nc = "integer", # number of columns in (augmented)
421                                          # model matrices and number of observations                                          ## model matrices and number of observations
422                          Gp = "integer", # Pointers to groups of rows in RZX                          Gp = "integer", # Pointers to groups of rows in RZX
423                          status = "logical"                          status = "logical"
424                          ),                          ),

Legend:
Removed from v.945  
changed lines
  Added in v.946

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