Rev 1528 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
.onLoad <- function(lib, pkg) {if(is.null(getOption("max.print")))options(max.print = 10000)#-> show() of large matrices}## ------------- Virtual Classes ----------------------------------------# Mother class of all Matrix objectssetClass("Matrix", representation(Dim = "integer", Dimnames = "list","VIRTUAL"),prototype = prototype(Dim = integer(2), Dimnames = list(NULL,NULL)),validity = function(object) {Dim <- object@Dimif (length(Dim) != 2)return("Dim slot must be of length 2")if (any(Dim < 0))return("Dim slot must contain non-negative values")Dn <- object@Dimnamesif (!is.list(Dn) || length(Dn) != 2)return("'Dimnames' slot must be list of length 2")## 'else' ok :TRUE})# Virtual class of numeric matricessetClass("dMatrix",representation(x = "numeric", "VIRTUAL"), contains = "Matrix")# Virtual class of integer matricessetClass("iMatrix",representation(x = "integer", "VIRTUAL"), contains = "Matrix")# Virtual class of logical matricessetClass("lMatrix", representation("VIRTUAL"), contains = "Matrix")## Note that logical sparse matrices do not need an x slot so the x## slot is part of the ldenseMatrix class# Virtual class of complex matricessetClass("zMatrix", # letter 'z' is as in the names of Lapack subroutinesrepresentation(x = "complex", "VIRTUAL"), contains = "Matrix")# Virtual class of dense, numeric matricessetClass("ddenseMatrix",representation(rcond = "numeric", factors = "list", "VIRTUAL"),contains = "dMatrix")# Virtual class of dense, logical matricessetClass("ldenseMatrix",representation(x = "logical", factors = "list", "VIRTUAL"),contains = "lMatrix")## virtual SPARSE ------------setClass("sparseMatrix", contains = "Matrix")# "VIRTUAL"setClass("dsparseMatrix", contains = c("dMatrix", "sparseMatrix"))# "VIRTUAL"setClass("lsparseMatrix", contains = c("lMatrix", "sparseMatrix"))# "VIRTUAL"## ------------------ Proper (non-virtual) Classes ----------------------------##---------------------- DENSE -----------------------------------------# numeric, dense, general matricessetClass("dgeMatrix", contains = "ddenseMatrix",## checks that length( @ x) == prod( @ Dim):validity = function(object) .Call("dgeMatrix_validate", object))## i.e. "dgeMatrix" cannot be packed, but "ddenseMatrix" can ..# numeric, dense, non-packed, triangular matricessetClass("dtrMatrix",representation(uplo = "character", diag = "character"),contains = "dgeMatrix",prototype = prototype(uplo = "U", diag = "N"),validity = function(object) .Call("dtrMatrix_validate", object))# numeric, dense, packed, triangular matricessetClass("dtpMatrix",representation(uplo = "character", diag = "character"),contains = "ddenseMatrix",prototype = prototype(uplo = "U", diag = "N"),validity = function(object) .Call("dtpMatrix_validate", object))# numeric, dense, non-packed symmetric matricessetClass("dsyMatrix",representation(uplo = "character"),prototype = prototype(uplo = "U"),contains = "dgeMatrix",validity = function(object) .Call("dsyMatrix_validate", object))# numeric, dense, packed symmetric matricessetClass("dspMatrix",representation(uplo = "character"),prototype = prototype(uplo = "U"),contains = "ddenseMatrix",validity = function(object) .Call("dspMatrix_validate", object))# numeric, dense, non-packed, positive-definite, symmetric matricessetClass("dpoMatrix", contains = "dsyMatrix",validity = function(object) .Call("dpoMatrix_validate", object))# numeric, dense, packed, positive-definite, symmetric matricessetClass("dppMatrix", contains = "dspMatrix",validity = function(object) .Call("dppMatrix_validate", object))##-------------------- S P A R S E (non-virtual) --------------------------##---------- numeric sparse matrix classes --------------------------------# numeric, sparse, triplet general matricessetClass("dgTMatrix",representation(i = "integer", j = "integer", factors = "list"),contains = "dsparseMatrix",validity = function(object) .Call("dgTMatrix_validate", object))# numeric, sparse, triplet triangular matricessetClass("dtTMatrix",representation(uplo = "character", diag = "character"),contains = "dgTMatrix",validity = function(object) .Call("dtTMatrix_validate", object))# numeric, sparse, triplet symmetric matricessetClass("dsTMatrix",representation(uplo = "character"),contains = "dgTMatrix",validity = function(object) .Call("dsTMatrix_validate", object))# numeric, sparse, sorted compressed sparse column-oriented general matricessetClass("dgCMatrix",representation(i = "integer", p = "integer", factors = "list"),contains = "dsparseMatrix",validity = function(object) .Call("dgCMatrix_validate", object))# numeric, sparse, sorted compressed sparse column-oriented triangular matricessetClass("dtCMatrix",representation(uplo = "character", diag = "character"),contains = "dgCMatrix",validity = function(object) .Call("tsc_validate", object))# numeric, sparse, sorted compressed sparse column-oriented symmetric matricessetClass("dsCMatrix",representation(uplo = "character"),contains = "dgCMatrix",validity = function(object) .Call("dsCMatrix_validate", object))# numeric, sparse, sorted compressed sparse row-oriented general matricessetClass("dgRMatrix",representation(j = "integer", p = "integer", factors = "list"),contains = "dsparseMatrix",validity = function(object) .Call("dgRMatrix_validate", object))# numeric, sparse, sorted compressed sparse row-oriented triangular matricessetClass("dtRMatrix",representation(uplo = "character", diag = "character"),contains = "dgRMatrix",validity = function(object) .Call("dtRMatrix_validate", object))# numeric, sparse, sorted compressed sparse row-oriented symmetric matricessetClass("dsRMatrix",representation(uplo = "character"),contains = "dgRMatrix",validity = function(object) .Call("dsRMatrix_validate", object))##---------- logical sparse matrix classes --------------------------------## these classes are used in symbolic analysis to determine the## locations of non-zero entries# logical, sparse, triplet general matricessetClass("lgTMatrix",representation(i = "integer", j = "integer"),contains = "lsparseMatrix",validity = function(object) .Call("lgTMatrix_validate", object))# logical, sparse, triplet triangular matricessetClass("ltTMatrix",representation(uplo = "character", diag = "character"),contains = "lgTMatrix",validity = function(object) .Call("ltTMatrix_validate", object))# logical, sparse, triplet symmetric matricessetClass("lsTMatrix",representation(uplo = "character"),contains = "lgTMatrix",validity = function(object) .Call("lsTMatrix_validate", object))# logical, sparse, sorted compressed sparse column-oriented general matricessetClass("lgCMatrix",representation(i = "integer", p = "integer"),contains = "lsparseMatrix",validity = function(object) .Call("lgCMatrix_validate", object))# logical, sparse, sorted compressed sparse column-oriented triangular matricessetClass("ltCMatrix",representation(uplo = "character", diag = "character"),contains = "lgCMatrix",validity = function(object) .Call("ltCMatrix_validate", object))# logical, sparse, sorted compressed sparse column-oriented symmetric matricessetClass("lsCMatrix",representation(uplo = "character"),contains = "lgCMatrix",validity = function(object) .Call("lsCMatrix_validate", object))# logical, sparse, sorted compressed sparse row-oriented general matricessetClass("lgRMatrix",representation(j = "integer", p = "integer"),contains = "lsparseMatrix",validity = function(object) .Call("lgRMatrix_validate", object))# logical, sparse, sorted compressed sparse row-oriented triangular matricessetClass("ltRMatrix",representation(uplo = "character", diag = "character"),contains = "lgRMatrix",validity = function(object) .Call("ltRMatrix_validate", object))# logical, sparse, sorted compressed sparse row-oriented symmetric matricessetClass("lsRMatrix",representation(uplo = "character"),contains = "lgRMatrix",validity = function(object) .Call("lsRMatrix_validate", object))## Compressed sparse column matrix in blockssetClass("dgBCMatrix",representation(p = "integer", i = "integer", x = "array"))## Factorization classessetClass("Cholesky", contains = "dtrMatrix")setClass("pCholesky", contains = "dtpMatrix")setClass("BunchKaufman", representation(perm = "integer"), contains = "dtrMatrix",validity = function(object) .Call("BunchKaufman_validate", object));setClass("pBunchKaufman", representation(perm = "integer"), contains = "dtpMatrix",validity = function(object) .Call("pBunchKaufman_validate", object));setClass("dCholCMatrix",representation(perm = "integer", Parent = "integer", D = "numeric"),contains = "dtCMatrix",validity = function(object) .Call("dCholCMatrix_validate", object))setClass("lCholCMatrix",representation(perm = "integer", Parent = "integer"),contains = "ltCMatrix",validity = function(object) .Call("lCholCMatrix_validate", object))##-------------------- permutation ----------------------------------------setClass("pMatrix", representation(perm = "integer"), contains = "Matrix",validity = function(object) {dd <- object@Dimn <- dd[1]perm <- object@permif (dd[2] != n) return("pMatrix must be symmetric")if (length(perm) != n)return(paste("length of 'perm' slot must be", n))if (!(all(range(perm) == c(1, n)) && length(unique(perm)) == n))return("'perm' slot is not a valid permutation")TRUE})## --------------------- non-"Matrix" Classes --------------------------------setClass("determinant",representation(modulus ="numeric",logarithm = "logical",sign = "integer",call = "call"))setClass("LU", representation(x = "numeric",perm = "integer"),validity = function(object) .Call("LU_validate", object))## Deprecated:# positive-definite symmetric matrices as matricessetClass("pdmatrix", contains="matrix")# # factors of positive-definite symmetric matrices# setClass("pdfactor", representation("matrix", logDet = "numeric"))# correlation matrices and standard deviationssetClass("corrmatrix", representation("matrix", stdDev = "numeric"))