SCM Repository

[matrix] Diff of /branches/Matrix-mer2/tests/validObj.R
 [matrix] / branches / Matrix-mer2 / tests / validObj.R

Diff of /branches/Matrix-mer2/tests/validObj.R

revision 509, Fri Feb 4 23:34:01 2005 UTC revision 516, Sat Feb 5 13:54:20 2005 UTC
# Line 1  Line 1
1  library(Matrix)  library(Matrix)
2
3  stopifnot(validObject(m1 <- Matrix(1:6, ncol=2)))  ### Do all kinds of object creation and coercion
stopifnot(validObject(m2 <- Matrix(1:7, ncol=3))) # a warning
4
5
6    chk.matrix <- function(M) {
7        ## check if "matrix" coercion looks ok
8        cl <- class(M)
9        d <- dim(M)
10        cat("class ", dQuote(cl), " [",d[1]," x ",d[2],"]; slots (",
11            paste(slotNames(M), collapse=","), ")\n", sep='')
12        stopifnot(validObject(M),
13                  identical(dim(m <- as(M,"matrix")), dim(M))
14                  )
15    }
16
17    ## "dge"
18    chk.matrix(m1 <- Matrix(1:6, ncol=2))
19    chk.matrix(m2 <- Matrix(1:7, ncol=3)) # a warning
20    ## "dpo"
21    chk.matrix(cm <- crossprod(m1))
22    chk.matrix(as(cm, "dsyMatrix"))
23    chk.matrix(as(cm, "dgeMatrix"))
24    try( chk.matrix(as(cm, "Matrix")) ) # gives an error
25
26    ## Cholesky
27    chk.matrix(ch <- chol(cm))
28    ## FIXME:
29    try( chk.matrix(ch2 <- chol(as(cm, "dsyMatrix"))) ) # should not give an error
30    try( chk.matrix(ch3 <- chol(as(cm, "dgeMatrix"))) ) # nor that one

Legend:
 Removed from v.509 changed lines Added in v.516