SCM Repository

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

Diff of /pkg/R/AllClass.R

revision 1155, Thu Jan 12 14:34:42 2006 UTC revision 1156, Thu Jan 12 23:39:56 2006 UTC
# Line 7  Line 7
7
8  ## Mother class of all Matrix objects  ## Mother class of all Matrix objects
9  setClass("Matrix",  setClass("Matrix",
10           representation(Dim = "integer", Dimnames = "list", factors = "list",           representation(Dim = "integer", Dimnames = "list", "VIRTUAL"),
"VIRTUAL"),
11           prototype = prototype(Dim = integer(2), Dimnames = list(NULL,NULL)),           prototype = prototype(Dim = integer(2), Dimnames = list(NULL,NULL)),
12           validity = function(object) {           validity = function(object) {
13               Dim <- object@Dim               Dim <- object@Dim
# Line 23  Line 22
22               TRUE               TRUE
23           })           })
24
25    ## The class of composite matrices - i.e. those for which it makes sense to
26    ## create a factorization
27    setClass("compMatrix",  representation(factors = "list", "VIRTUAL"),
28             contains = "Matrix")
29
30  setClass("symmetricMatrix",  setClass("symmetricMatrix",
31           representation(uplo = "character", "VIRTUAL"),           representation(uplo = "character", "VIRTUAL"),
32           contains = "Matrix")           contains = "Matrix")
# Line 101  Line 105
105  ##----------------------  DENSE  -----------------------------------------  ##----------------------  DENSE  -----------------------------------------
106
107  ## numeric, dense, general matrices  ## numeric, dense, general matrices
108  setClass("dgeMatrix", contains = "ddenseMatrix",  setClass("dgeMatrix", contains = c("ddenseMatrix", "compMatrix"),
109           ## checks that length( @ x) == prod( @ Dim):           ## checks that length( @ x) == prod( @ Dim):
110           validity =           validity =
111           function(object) .Call("dgeMatrix_validate", object, PACKAGE = "Matrix")           function(object) .Call("dgeMatrix_validate", object, PACKAGE = "Matrix")
# Line 115  Line 119
119           ##> WITHOUT a coerce to dge* (losing triangularity)           ##> WITHOUT a coerce to dge* (losing triangularity)
120           ##> gives error from callNextMethod() in crossprod() dispatch {R bug?}           ##> gives error from callNextMethod() in crossprod() dispatch {R bug?}
121           ##> contains = c("ddenseMatrix", "dgeMatrix", "triangularMatrix"),           ##> contains = c("ddenseMatrix", "dgeMatrix", "triangularMatrix"),
122           contains = c("dgeMatrix", "triangularMatrix"),           contains = c("ddenseMatrix", "triangularMatrix"),
123           prototype = prototype(uplo = "U", diag = "N"),           prototype = prototype(uplo = "U", diag = "N"),
124           validity =           validity =
125           function(object) .Call("dtrMatrix_validate", object, PACKAGE = "Matrix")           function(object) .Call("dtrMatrix_validate", object, PACKAGE = "Matrix")
# Line 145  Line 149
149  ## numeric, dense, packed symmetric matrices  ## numeric, dense, packed symmetric matrices
150  setClass("dspMatrix",  setClass("dspMatrix",
151           prototype = prototype(uplo = "U"),           prototype = prototype(uplo = "U"),
152           contains = c("ddenseMatrix", "symmetricMatrix"),           contains = c("ddenseMatrix", "compMatrix", "symmetricMatrix"),
153           validity =           validity =
154           function(object) .Call("dspMatrix_validate", object, PACKAGE = "Matrix")           function(object) .Call("dspMatrix_validate", object, PACKAGE = "Matrix")
155           )           )
# Line 165  Line 169
169  ##----- logical dense Matrices -- e.g. as result of <ddenseMatrix>  COMPARISON  ##----- logical dense Matrices -- e.g. as result of <ddenseMatrix>  COMPARISON
170
171  ## numeric, dense, general matrices  ## numeric, dense, general matrices
172  setClass("lgeMatrix", contains = "ldenseMatrix",  setClass("lgeMatrix", contains = c("ldenseMatrix", "compMatrix"),
173           ## checks that length( @ x) == prod( @ Dim):           ## checks that length( @ x) == prod( @ Dim):
174           validity = function(object) stopifnot(length(object@x) == prod(object@Dim))           validity = function(object) stopifnot(length(object@x) == prod(object@Dim))
175           )           )
# Line 173  Line 177
177
178  ## numeric, dense, non-packed, triangular matrices  ## numeric, dense, non-packed, triangular matrices
179  setClass("ltrMatrix",  setClass("ltrMatrix",
180           contains = c("lgeMatrix", "triangularMatrix"),           contains = c("ldenseMatrix", "triangularMatrix"),
181           prototype = prototype(uplo = "U", diag = "N"))           prototype = prototype(uplo = "U", diag = "N"))
182
183  ## numeric, dense, packed, triangular matrices  ## numeric, dense, packed, triangular matrices
# Line 193  Line 197
197  ## numeric, dense, packed symmetric matrices  ## numeric, dense, packed symmetric matrices
198  setClass("lspMatrix",  setClass("lspMatrix",
199           prototype = prototype(uplo = "U"),           prototype = prototype(uplo = "U"),
200           contains = c("ldenseMatrix", "symmetricMatrix"),           contains = c("ldenseMatrix", "compMatrix", "symmetricMatrix"),
201           validity = function(object)           validity = function(object)
202           .Call("dspMatrix_validate", object, PACKAGE = "Matrix")           .Call("dspMatrix_validate", object, PACKAGE = "Matrix")
203           ## "dsp" and "lsp" have the same validate           ## "dsp" and "lsp" have the same validate
# Line 212  Line 216
216
217  ## numeric, sparse, triplet general matrices  ## numeric, sparse, triplet general matrices
218  setClass("dgTMatrix",  setClass("dgTMatrix",
219           contains = c("TsparseMatrix", "dsparseMatrix"),           contains = c("TsparseMatrix", "dsparseMatrix", "compMatrix"),
220           validity =           validity =
221           function(object) .Call("dgTMatrix_validate", object, PACKAGE = "Matrix")           function(object) .Call("dgTMatrix_validate", object, PACKAGE = "Matrix")
222           )           )
# Line 236  Line 240
240
241  ## numeric, sparse, triplet symmetric matrices  ## numeric, sparse, triplet symmetric matrices
242  setClass("dsTMatrix",  setClass("dsTMatrix",
243           contains = c("TsparseMatrix", "dsparseMatrix", "symmetricMatrix"),           contains = c("TsparseMatrix", "dsparseMatrix", "symmetricMatrix", "compMatrix"),
244           prototype = prototype(uplo = "U"),           prototype = prototype(uplo = "U"),
245           validity =           validity =
246           function(object) .Call("dsTMatrix_validate", object, PACKAGE = "Matrix")           function(object) .Call("dsTMatrix_validate", object, PACKAGE = "Matrix")
# Line 244  Line 248
248
249  ## numeric, sparse, sorted compressed sparse column-oriented general matrices  ## numeric, sparse, sorted compressed sparse column-oriented general matrices
250  setClass("dgCMatrix",  setClass("dgCMatrix",
251           contains = c("CsparseMatrix", "dsparseMatrix"),           contains = c("CsparseMatrix", "dsparseMatrix", "compMatrix"),
252           prototype = prototype(p = 0:0),# to be valid           prototype = prototype(p = 0:0),# to be valid
253           validity =           validity =
254           function(object) .Call("dgCMatrix_validate", object, PACKAGE = "Matrix")           function(object) .Call("dgCMatrix_validate", object, PACKAGE = "Matrix")
# Line 262  Line 266
266  ## see comments for dsTMatrix above  ## see comments for dsTMatrix above
267  ## numeric, sparse, sorted compressed sparse column-oriented symmetric matrices  ## numeric, sparse, sorted compressed sparse column-oriented symmetric matrices
268  setClass("dsCMatrix",  setClass("dsCMatrix",
269           contains = c("CsparseMatrix", "dsparseMatrix", "symmetricMatrix"),           contains = c("CsparseMatrix", "dsparseMatrix", "symmetricMatrix", "compMatrix"),
270           prototype = prototype(p = 0:0, uplo = "U"),# to be valid           prototype = prototype(p = 0:0, uplo = "U"),# to be valid
271           validity =           validity =
272           function(object) .Call("dsCMatrix_validate", object, PACKAGE = "Matrix")           function(object) .Call("dsCMatrix_validate", object, PACKAGE = "Matrix")
# Line 271  Line 275
275  ## numeric, sparse, sorted compressed sparse row-oriented general matrices  ## numeric, sparse, sorted compressed sparse row-oriented general matrices
276  setClass("dgRMatrix",  setClass("dgRMatrix",
277           representation(j = "integer", p = "integer"),           representation(j = "integer", p = "integer"),
278           contains = "dsparseMatrix",           contains = c("dsparseMatrix", "compMatrix"),
279           ##TODO: validity = function(object) .Call("dgRMatrix_validate", object, PACKAGE = "Matrix")           ##TODO: validity = function(object) .Call("dgRMatrix_validate", object, PACKAGE = "Matrix")
280           )           )
281
# Line 279  Line 283
283  setClass("dtRMatrix",  setClass("dtRMatrix",
284           contains = c("dgRMatrix", "triangularMatrix"),           contains = c("dgRMatrix", "triangularMatrix"),
285           ##TODO: validity = function(object) .Call("dtRMatrix_validate", object, PACKAGE = "Matrix")           ##TODO: validity = function(object) .Call("dtRMatrix_validate", object, PACKAGE = "Matrix")
286             ##TODO: Should this contain dgRMatrix or dsparseMatrix?
287           )           )
288
289  ## numeric, sparse, sorted compressed sparse row-oriented symmetric matrices  ## numeric, sparse, sorted compressed sparse row-oriented symmetric matrices
# Line 294  Line 299
299
300  ## logical, sparse, triplet general matrices  ## logical, sparse, triplet general matrices
301  setClass("lgTMatrix",  setClass("lgTMatrix",
302           contains = c("TsparseMatrix", "lsparseMatrix"),           contains = c("TsparseMatrix", "lsparseMatrix", "compMatrix"),
303           validity =           validity =
304           function(object) .Call("lgTMatrix_validate", object, PACKAGE = "Matrix")           function(object) .Call("lgTMatrix_validate", object, PACKAGE = "Matrix")
305           )           )
# Line 309  Line 314
314
315  ## logical, sparse, triplet symmetric matrices  ## logical, sparse, triplet symmetric matrices
316  setClass("lsTMatrix",  setClass("lsTMatrix",
317           contains = c("TsparseMatrix", "lsparseMatrix", "symmetricMatrix"),           contains = c("TsparseMatrix", "lsparseMatrix", "symmetricMatrix", "compMatrix"),
318           validity =           validity =
319           function(object) .Call("lsTMatrix_validate", object, PACKAGE = "Matrix")           function(object) .Call("lsTMatrix_validate", object, PACKAGE = "Matrix")
320           )           )
321
322  ## logical, sparse, sorted compressed sparse column-oriented general matrices  ## logical, sparse, sorted compressed sparse column-oriented general matrices
323  setClass("lgCMatrix",  setClass("lgCMatrix",
324           contains = c("lsparseMatrix", "CsparseMatrix"),           contains = c("lsparseMatrix", "CsparseMatrix", "compMatrix"),
325           prototype = prototype(p = 0:0),# to be valid           prototype = prototype(p = 0:0),# to be valid
326           validity =           validity =
327           function(object) .Call("lgCMatrix_validate", object, PACKAGE = "Matrix")           function(object) .Call("lgCMatrix_validate", object, PACKAGE = "Matrix")
# Line 332  Line 337
337
338  ## logical, sparse, sorted compressed sparse column-oriented symmetric matrices  ## logical, sparse, sorted compressed sparse column-oriented symmetric matrices
339  setClass("lsCMatrix",  setClass("lsCMatrix",
340           contains = c("lsparseMatrix", "CsparseMatrix", "symmetricMatrix"),           contains = c("lsparseMatrix", "CsparseMatrix", "symmetricMatrix", "compMatrix"),
341           prototype = prototype(p = 0:0, uplo = "U"),# to be valid           prototype = prototype(p = 0:0, uplo = "U"),# to be valid
342           validity =           validity =
343           function(object) .Call("lsCMatrix_validate", object, PACKAGE = "Matrix")           function(object) .Call("lsCMatrix_validate", object, PACKAGE = "Matrix")
# Line 484  Line 489
489                          Zt = "dgCMatrix",  # sparse representation of Z'                          Zt = "dgCMatrix",  # sparse representation of Z'
490                          X = "matrix",      # X                          X = "matrix",      # X
491                          y = "numeric",     # y                          y = "numeric",     # y
492                            wts = "numeric",   # weights
493                            wrkres = "numeric",# working residuals (copy of y for LMMs)
494                          method = "character", # parameter estimation method                          method = "character", # parameter estimation method
495                          useScale = "logical", # should scale factor be included                          useScale = "logical", # should scale factor be included
496                          family = "family", # glm family                          family = "family", # glm family

Legend:
 Removed from v.1155 changed lines Added in v.1156