SCM

SCM Repository

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

Diff of /pkg/tests/validObj.R

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 538, Thu Feb 10 13:50:27 2005 UTC revision 579, Sun Feb 27 00:04:16 2005 UTC
# Line 34  Line 34 
34    
35  chk.matrix(m1 <- Matrix(1:6, ncol=2))  chk.matrix(m1 <- Matrix(1:6, ncol=2))
36  chk.matrix(m2 <- Matrix(1:7, ncol=3)) # a warning  chk.matrix(m2 <- Matrix(1:7, ncol=3)) # a warning
37    stopifnot(is(m1) == c("dgeMatrix", "ddenseMatrix", "dMatrix", "Matrix"),
38              dim(t(m1)) == 2:3,
39              identical(m1, t(t(m1))))
40    c.nam <- paste("C",1:2, sep='')
41    dimnames(m1) <- list(NULL, c.nam)
42    stopifnot(colnames(m1) == c.nam,
43              identical(dimnames(t(m1)), list(c.nam, NULL)),
44              identical(m1, t(t(m1))))
45    
46    
47  ## "dpo"  ## "dpo"
48  chk.matrix(cm <- crossprod(m1))  chk.matrix(cm <- crossprod(m1))
49  chk.matrix(as(cm, "dsyMatrix"))  chk.matrix(as(cm, "dsyMatrix"))
50  chk.matrix(as(cm, "dgeMatrix"))  chk.matrix(as(cm, "dgeMatrix"))
51  try( chk.matrix(as(cm, "Matrix")) ) # gives an error  try( chk.matrix(as(cm, "Matrix")) )# gives an error: "Matrix" has NULL 'dim()'
52    
53  ## Cholesky  ## Cholesky
54  chk.matrix(ch <- chol(cm))  chk.matrix(ch <- chol(cm))
# Line 52  Line 61 
61  assertError( new("dtrMatrix", Dim = c(2,2), x= 1:4) )# double 'Dim'  assertError( new("dtrMatrix", Dim = c(2,2), x= 1:4) )# double 'Dim'
62  if(FALSE)## FIXME: this creates an integer '@ x' !  if(FALSE)## FIXME: this creates an integer '@ x' !
63  assertError( new("dtrMatrix", Dim = as.integer(c(2,2)), x= 1:4) )# int 'x'  assertError( new("dtrMatrix", Dim = as.integer(c(2,2)), x= 1:4) )# int 'x'
64    ## This caused a segfault (before revision r1172 in ../src/dtrMatrix.c):
65  assertError( new("dtrMatrix", Dim = 2:2, x=as.double(1:4)) )# length(Dim) !=2  assertError( new("dtrMatrix", Dim = 2:2, x=as.double(1:4)) )# length(Dim) !=2
66  assertError( new("dtrMatrix", Dim = as.integer(c(2,2)), x= as.double(1:5)))  assertError( new("dtrMatrix", Dim = as.integer(c(2,2)), x= as.double(1:5)))
67    
68  tr22 <- new("dtrMatrix", Dim = as.integer(c(2,2)), x=as.double(1:4))  tr22 <- new("dtrMatrix", Dim = as.integer(c(2,2)), x=as.double(1:4))
69  try( t(tr22) ) # fails -- FIXME  tt22 <- t(tr22)
70    (tPt <- tr22 + tt22)
71    stopifnot(identical(10 * tPt, tPt * 10),
72              (t.22 <- (tr22 / .5)* .5)@x == c(1,0,3,4),
73              TRUE) ## not yet: class(t.22) == "dtrMatrix")
74    
75    
76  ## non-square  ## non-square  triagonal Matrices --- should this be forbidden anyway? ---
77  tru <- new("dtrMatrix", Dim = 2:3, x=as.double(1:6), uplo="L", diag="U")  tru <- new("dtrMatrix", Dim = 2:3, x=as.double(1:6), uplo="L", diag="U")
78  trn <- new("dtrMatrix", Dim = 2:3, x=as.double(1:6), uplo="L", diag="N")  trn <- new("dtrMatrix", Dim = 2:3, x=as.double(1:6), uplo="L", diag="N")
79  try( tru + trn ) # not yet  tru + trn  # a 'dgeMatrix'
   
 try( t(tru) ) ## FIXME !  
 try( t(trn) ) ## FIXME  
80    
81    as(t(tru),"dgeMatrix")
82    as(t(trn),"dgeMatrix")
83    as(t(t(tru)), "dgeMatrix")# pretty non sense

Legend:
Removed from v.538  
changed lines
  Added in v.579

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