SCM

SCM Repository

[matrix] Annotation of /pkg/tests/validObj.R
ViewVC logotype

Annotation of /pkg/tests/validObj.R

Parent Directory Parent Directory | Revision Log Revision Log


Revision 516 - (view) (download)

1 : maechler 509 library(Matrix)
2 :    
3 : maechler 516 ### Do all kinds of object creation and coercion
4 : maechler 509
5 : maechler 516
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

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