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 578, Sat Feb 26 18:25:09 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))
# Line 57  Line 66 
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  tru + trn  # a 'dgeMatrix'  tru + trn  # a 'dgeMatrix'
80    
81  try( t(tru) ) ## FIXME !  as(t(tru),"dgeMatrix")
82  try( t(trn) ) ## FIXME  as(t(trn),"dgeMatrix")
83    as(t(t(tru)), "dgeMatrix")# pretty non sense

Legend:
Removed from v.578  
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