SCM

SCM Repository

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

Annotation of /pkg/R/AllClass.R

Parent Directory Parent Directory | Revision Log Revision Log


Revision 868 - (view) (download)

1 : bates 10 .onLoad <- function(lib, pkg) {
2 : maechler 513 if(is.null(getOption("max.print")))
3 :     options(max.print = 10000)#-> show() of large matrices
4 : bates 10 }
5 :    
6 : maechler 513 ## ------------- Virtual Classes ----------------------------------------
7 :    
8 : maechler 676 # Mother class of all Matrix objects
9 : maechler 664 setClass("Matrix", representation(Dim = "integer", Dimnames = "list",
10 :     "VIRTUAL"),
11 : maechler 538 prototype = prototype(Dim = integer(2), Dimnames = list(NULL,NULL)),
12 : bates 477 validity = function(object) {
13 :     Dim <- object@Dim
14 :     if (length(Dim) != 2)
15 :     return("Dim slot must be of length 2")
16 :     if (any(Dim < 0))
17 :     return("Dim slot must contain non-negative values")
18 : maechler 538 Dn <- object@Dimnames
19 :     if (!is.list(Dn) || length(Dn) != 2)
20 :     return("'Dimnames' slot must be list of length 2")
21 : maechler 664 ## 'else' ok :
22 : bates 477 TRUE
23 :     })
24 : bates 10
25 : bates 477 # Virtual class of numeric matrices
26 :     setClass("dMatrix",
27 : maechler 664 representation(x = "numeric", "VIRTUAL"), contains = "Matrix")
28 : bates 477
29 :     # Virtual class of integer matrices
30 :     setClass("iMatrix",
31 : maechler 664 representation(x = "integer", "VIRTUAL"), contains = "Matrix")
32 : bates 477
33 :     # Virtual class of logical matrices
34 : bates 692 setClass("lMatrix", representation("VIRTUAL"), contains = "Matrix")
35 :     ## Note that logical sparse matrices do not need an x slot so the x
36 :     ## slot is part of the ldenseMatrix class
37 : bates 477
38 : maechler 610 # Virtual class of complex matrices
39 : bates 477 setClass("zMatrix", # letter 'z' is as in the names of Lapack subroutines
40 : maechler 664 representation(x = "complex", "VIRTUAL"), contains = "Matrix")
41 : bates 477
42 : maechler 848 # Virtual class of dense matrices
43 :     setClass("denseMatrix", representation("VIRTUAL"), contains = "Matrix")
44 :    
45 : bates 477 # Virtual class of dense, numeric matrices
46 :     setClass("ddenseMatrix",
47 : maechler 664 representation(rcond = "numeric", factors = "list", "VIRTUAL"),
48 : maechler 848 contains = c("dMatrix", "denseMatrix"))
49 : maechler 498
50 : bates 692 # Virtual class of dense, logical matrices
51 :     setClass("ldenseMatrix",
52 :     representation(x = "logical", factors = "list", "VIRTUAL"),
53 : maechler 848 contains = c("lMatrix", "denseMatrix"))
54 : bates 692
55 : maechler 676 ## virtual SPARSE ------------
56 :    
57 : maechler 868 setClass("sparseMatrix", representation("VIRTUAL"), contains = "Matrix")
58 : maechler 676
59 : maechler 868 ## general Triplet Matrices (dgT, lgT, ..):
60 :     setClass("gTMatrix", representation(i = "integer", j = "integer", "VIRTUAL"),
61 :     contains = "sparseMatrix")
62 :    
63 : maechler 848 setClass("dsparseMatrix", representation("VIRTUAL"),
64 :     contains = c("dMatrix", "sparseMatrix"))
65 : maechler 676
66 : maechler 848 setClass("lsparseMatrix", representation("VIRTUAL"),
67 :     contains = c("lMatrix", "sparseMatrix"))
68 : bates 692
69 : maechler 513 ## ------------------ Proper (non-virtual) Classes ----------------------------
70 :    
71 :     ##---------------------- DENSE -----------------------------------------
72 :    
73 : bates 477 # numeric, dense, general matrices
74 :     setClass("dgeMatrix", contains = "ddenseMatrix",
75 : maechler 664 ## checks that length( @ x) == prod( @ Dim):
76 : maechler 513 validity = function(object) .Call("dgeMatrix_validate", object)
77 :     )
78 :     ## i.e. "dgeMatrix" cannot be packed, but "ddenseMatrix" can ..
79 : bates 477
80 : maechler 498 # numeric, dense, non-packed, triangular matrices
81 : bates 477 setClass("dtrMatrix",
82 :     representation(uplo = "character", diag = "character"),
83 :     contains = "dgeMatrix",
84 :     prototype = prototype(uplo = "U", diag = "N"),
85 : maechler 513 validity = function(object) .Call("dtrMatrix_validate", object)
86 :     )
87 : bates 10
88 : maechler 498 # numeric, dense, packed, triangular matrices
89 : bates 477 setClass("dtpMatrix",
90 : bates 10 representation(uplo = "character", diag = "character"),
91 : bates 477 contains = "ddenseMatrix",
92 : bates 10 prototype = prototype(uplo = "U", diag = "N"),
93 : maechler 513 validity = function(object) .Call("dtpMatrix_validate", object)
94 :     )
95 : bates 10
96 : bates 477 # numeric, dense, non-packed symmetric matrices
97 :     setClass("dsyMatrix",
98 :     representation(uplo = "character"),
99 :     prototype = prototype(uplo = "U"),
100 :     contains = "dgeMatrix",
101 :     validity = function(object) .Call("dsyMatrix_validate", object)
102 :     )
103 : bates 10
104 : maechler 513 # numeric, dense, packed symmetric matrices
105 : bates 477 setClass("dspMatrix",
106 : bates 10 representation(uplo = "character"),
107 : bates 477 prototype = prototype(uplo = "U"),
108 : maechler 513 contains = "ddenseMatrix",
109 : bates 477 validity = function(object) .Call("dspMatrix_validate", object)
110 :     )
111 : bates 10
112 : maechler 628 # numeric, dense, non-packed, positive-definite, symmetric matrices
113 : bates 477 setClass("dpoMatrix", contains = "dsyMatrix",
114 :     validity = function(object) .Call("dpoMatrix_validate", object)
115 :     )
116 : bates 10
117 : maechler 628 # numeric, dense, packed, positive-definite, symmetric matrices
118 : bates 482 setClass("dppMatrix", contains = "dspMatrix",
119 : bates 477 validity = function(object) .Call("dppMatrix_validate", object)
120 : bates 10 )
121 :    
122 : maechler 676 ##-------------------- S P A R S E (non-virtual) --------------------------
123 : maechler 513
124 : bates 692 ##---------- numeric sparse matrix classes --------------------------------
125 : maechler 848
126 : bates 477 # numeric, sparse, triplet general matrices
127 :     setClass("dgTMatrix",
128 : maechler 868 representation(factors = "list"),
129 :     contains = c("gTMatrix", "dsparseMatrix"),
130 : bates 477 validity = function(object) .Call("dgTMatrix_validate", object)
131 : bates 10 )
132 :    
133 : bates 477 # numeric, sparse, triplet triangular matrices
134 :     setClass("dtTMatrix",
135 : bates 13 representation(uplo = "character", diag = "character"),
136 : bates 477 contains = "dgTMatrix",
137 :     validity = function(object) .Call("dtTMatrix_validate", object)
138 :     )
139 : bates 10
140 : bates 477 # numeric, sparse, triplet symmetric matrices
141 : bates 482 setClass("dsTMatrix",
142 : bates 477 representation(uplo = "character"),
143 : bates 482 contains = "dgTMatrix",
144 : bates 477 validity = function(object) .Call("dsTMatrix_validate", object)
145 :     )
146 : bates 10
147 : bates 477 # numeric, sparse, sorted compressed sparse column-oriented general matrices
148 :     setClass("dgCMatrix",
149 :     representation(i = "integer", p = "integer", factors = "list"),
150 : maechler 676 contains = "dsparseMatrix",
151 : bates 477 validity = function(object) .Call("dgCMatrix_validate", object)
152 :     )
153 : bates 10
154 : bates 477 # numeric, sparse, sorted compressed sparse column-oriented triangular matrices
155 :     setClass("dtCMatrix",
156 :     representation(uplo = "character", diag = "character"),
157 :     contains = "dgCMatrix",
158 : bates 593 validity = function(object) .Call("tsc_validate", object)
159 : bates 477 )
160 :    
161 :     # numeric, sparse, sorted compressed sparse column-oriented symmetric matrices
162 :     setClass("dsCMatrix",
163 :     representation(uplo = "character"),
164 :     contains = "dgCMatrix",
165 :     validity = function(object) .Call("dsCMatrix_validate", object)
166 :     )
167 :    
168 :     # numeric, sparse, sorted compressed sparse row-oriented general matrices
169 :     setClass("dgRMatrix",
170 :     representation(j = "integer", p = "integer", factors = "list"),
171 : maechler 676 contains = "dsparseMatrix",
172 : maechler 851 ##TODO: validity = function(object) .Call("dgRMatrix_validate", object)
173 : bates 477 )
174 :    
175 :     # numeric, sparse, sorted compressed sparse row-oriented triangular matrices
176 :     setClass("dtRMatrix",
177 :     representation(uplo = "character", diag = "character"),
178 :     contains = "dgRMatrix",
179 : maechler 856 ##TODO: validity = function(object) .Call("dtRMatrix_validate", object)
180 : bates 477 )
181 :    
182 :     # numeric, sparse, sorted compressed sparse row-oriented symmetric matrices
183 :     setClass("dsRMatrix",
184 :     representation(uplo = "character"),
185 :     contains = "dgRMatrix",
186 : maechler 851 ##TODO: validity = function(object) .Call("dsRMatrix_validate", object)
187 : bates 477 )
188 :    
189 : bates 692 ##---------- logical sparse matrix classes --------------------------------
190 :    
191 :     ## these classes are used in symbolic analysis to determine the
192 : maechler 848 ## locations of non-zero entries
193 : bates 692
194 :     # logical, sparse, triplet general matrices
195 :     setClass("lgTMatrix",
196 : maechler 868 contains = c("gTMatrix", "lsparseMatrix"),
197 : bates 692 validity = function(object) .Call("lgTMatrix_validate", object)
198 :     )
199 :    
200 :     # logical, sparse, triplet triangular matrices
201 :     setClass("ltTMatrix",
202 :     representation(uplo = "character", diag = "character"),
203 :     contains = "lgTMatrix",
204 :     validity = function(object) .Call("ltTMatrix_validate", object)
205 :     )
206 :    
207 :     # logical, sparse, triplet symmetric matrices
208 :     setClass("lsTMatrix",
209 :     representation(uplo = "character"),
210 :     contains = "lgTMatrix",
211 :     validity = function(object) .Call("lsTMatrix_validate", object)
212 :     )
213 :    
214 :     # logical, sparse, sorted compressed sparse column-oriented general matrices
215 :     setClass("lgCMatrix",
216 :     representation(i = "integer", p = "integer"),
217 :     contains = "lsparseMatrix",
218 :     validity = function(object) .Call("lgCMatrix_validate", object)
219 :     )
220 :    
221 :     # logical, sparse, sorted compressed sparse column-oriented triangular matrices
222 :     setClass("ltCMatrix",
223 :     representation(uplo = "character", diag = "character"),
224 :     contains = "lgCMatrix",
225 :     validity = function(object) .Call("ltCMatrix_validate", object)
226 :     )
227 :    
228 :     # logical, sparse, sorted compressed sparse column-oriented symmetric matrices
229 :     setClass("lsCMatrix",
230 :     representation(uplo = "character"),
231 :     contains = "lgCMatrix",
232 :     validity = function(object) .Call("lsCMatrix_validate", object)
233 :     )
234 :    
235 :     # logical, sparse, sorted compressed sparse row-oriented general matrices
236 :     setClass("lgRMatrix",
237 :     representation(j = "integer", p = "integer"),
238 :     contains = "lsparseMatrix",
239 :     validity = function(object) .Call("lgRMatrix_validate", object)
240 :     )
241 :    
242 :     # logical, sparse, sorted compressed sparse row-oriented triangular matrices
243 :     setClass("ltRMatrix",
244 :     representation(uplo = "character", diag = "character"),
245 :     contains = "lgRMatrix",
246 :     validity = function(object) .Call("ltRMatrix_validate", object)
247 :     )
248 :    
249 :     # logical, sparse, sorted compressed sparse row-oriented symmetric matrices
250 :     setClass("lsRMatrix",
251 :     representation(uplo = "character"),
252 :     contains = "lgRMatrix",
253 :     validity = function(object) .Call("lsRMatrix_validate", object)
254 :     )
255 :    
256 : bates 477 ## Compressed sparse column matrix in blocks
257 : bates 692
258 : maechler 513 setClass("dgBCMatrix",
259 :     representation(p = "integer", i = "integer", x = "array"))
260 : bates 477
261 : bates 692 ## Factorization classes
262 :    
263 : maechler 513 setClass("Cholesky", contains = "dtrMatrix")
264 :    
265 : bates 638 setClass("pCholesky", contains = "dtpMatrix")
266 :    
267 : bates 631 setClass("BunchKaufman", representation(perm = "integer"), contains = "dtrMatrix",
268 :     validity = function(object) .Call("BunchKaufman_validate", object));
269 :    
270 : bates 638 setClass("pBunchKaufman", representation(perm = "integer"), contains = "dtpMatrix",
271 :     validity = function(object) .Call("pBunchKaufman_validate", object));
272 :    
273 : maechler 513 setClass("dCholCMatrix",
274 :     representation(perm = "integer", Parent = "integer", D = "numeric"),
275 :     contains = "dtCMatrix",
276 :     validity = function(object) .Call("dCholCMatrix_validate", object))
277 :    
278 : bates 730 setClass("lCholCMatrix",
279 :     representation(perm = "integer", Parent = "integer"),
280 :     contains = "ltCMatrix",
281 :     validity = function(object) .Call("lCholCMatrix_validate", object))
282 :    
283 : bates 638 ##-------------------- permutation ----------------------------------------
284 : maechler 513
285 : bates 638 setClass("pMatrix", representation(perm = "integer"), contains = "Matrix",
286 :     validity = function(object) {
287 :     dd <- object@Dim
288 :     n <- dd[1]
289 :     perm <- object@perm
290 :     if (dd[2] != n) return("pMatrix must be symmetric")
291 :     if (length(perm) != n)
292 :     return(paste("length of 'perm' slot must be", n))
293 :     if (!(all(range(perm) == c(1, n)) && length(unique(perm)) == n))
294 :     return("'perm' slot is not a valid permutation")
295 :     TRUE
296 :     })
297 :    
298 : maechler 513 ## --------------------- non-"Matrix" Classes --------------------------------
299 :    
300 : bates 10 setClass("determinant",
301 :     representation(modulus ="numeric",
302 :     logarithm = "logical",
303 :     sign = "integer",
304 :     call = "call"))
305 :    
306 : maechler 498 setClass("LU", representation(x = "numeric",
307 : bates 652 perm = "integer"),
308 : maechler 513 validity = function(object) .Call("LU_validate", object))
309 : bates 10
310 : maechler 521 ## Deprecated:
311 : bates 10 # positive-definite symmetric matrices as matrices
312 :     setClass("pdmatrix", contains="matrix")
313 :    
314 : bates 593 # # factors of positive-definite symmetric matrices
315 :     # setClass("pdfactor", representation("matrix", logDet = "numeric"))
316 : bates 10
317 :     # correlation matrices and standard deviations
318 :     setClass("corrmatrix", representation("matrix", stdDev = "numeric"))
319 : bates 769
320 :     ## -------------------- lmer-related Classes --------------------------------
321 :    
322 :     setOldClass("data.frame")
323 :     setOldClass("family")
324 :     setOldClass("logLik")
325 :     setOldClass("terms")
326 :    
327 :     setClass("VarCorr",
328 :     representation(scale="numeric",
329 :     reSumry="list",
330 :     useScale="logical"),
331 :     prototype = list(scale = 1.0, useScale = TRUE))
332 :    
333 :     ## mixed effects representation
334 :     setClass("mer",
335 :     representation(
336 :     flist = "list", # list of grouping factors
337 :     perm = "list", # list of permutations of levels (0-based)
338 :     Parent = "list",# list of Parent arrays for ZZpO
339 :     D = "list", # list of diagonal factors (upper triangle)
340 :     bVar = "list", # list of conditional variance factors (upper triangle)
341 :     L = "list", # list of blocks of L
342 :     ZZpO = "list", # list of diagonal blocks of Z'Z+Omega
343 :     Omega = "list", # list of relative precision matrices
344 :     method = "character", # parameter estimation method
345 :     RXX = "matrix", # Augmented RXX component or its inverse
346 :     RZX = "matrix", # Augmented RZX component or its inverse
347 :     XtX = "matrix", # Original X'X matrix
348 :     ZtZ = "list", # list of blocks of Z'Z
349 :     ZtX = "matrix", # Original Z'X matrix
350 :     cnames = "list",# column names of model matrices
351 :     devComp = "numeric", # Components of deviance
352 :     deviance = "numeric", # Current deviance (ML and REML)
353 :     nc = "integer", # number of columns in (augmented)
354 :     # model matrices and number of observations
355 :     Gp = "integer", # Pointers to groups of rows in RZX
356 :     status = "logical"
357 :     ),
358 :     validity = function(object) {
359 :     .Call("lmer_validate", object, PACKAGE = "Matrix")
360 :     })
361 :    
362 :     ## Representation of a linear or generalized linear mixed effects model
363 :     setClass("lmer",
364 :     representation(assign = "integer", call = "call",
365 :     family = "family", fitted = "numeric",
366 :     fixed = "numeric", frame = "data.frame",
367 :     logLik = "logLik", residuals = "numeric",
368 :     terms = "terms"),
369 :     contains = "mer")
370 : maechler 848
371 : bates 769 ## Representation of a generalized linear mixed effects model
372 :     ##setClass("glmer",
373 :     ## representation(family = "family", glmmll = "numeric", fixed = "numeric"),
374 :     ## contains = "lmer")
375 :    
376 :     setClass("summary.lmer",
377 :     representation(useScale="logical",
378 :     showCorrelation="logical"),
379 :     contains = "lmer")
380 :    
381 :     setClass("lmer.ranef",
382 :     representation(varFac = "list", stdErr = "numeric"),
383 :     contains = "list")
384 :    
385 :     setClass("lmer.ranef.confint", contains = "list")
386 :    
387 :     setClass("lmer.coef",
388 :     representation(varFac = "list", stdErr = "numeric"),
389 :     contains = "list")

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