SCM

SCM Repository

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

Diff of /pkg/tests/matprod.R

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

revision 1330, Fri Jul 21 08:28:18 2006 UTC revision 1331, Sat Jul 22 17:59:53 2006 UTC
# Line 7  Line 7 
7  m5 <- 1 + as(diag(-1:4)[-5,], "dgeMatrix")  m5 <- 1 + as(diag(-1:4)[-5,], "dgeMatrix")
8  ## named dimnames:  ## named dimnames:
9  dimnames(m5) <- list(Rows= LETTERS[1:5], paste("C", 1:6, sep=""))  dimnames(m5) <- list(Rows= LETTERS[1:5], paste("C", 1:6, sep=""))
10    m. <- as(m5,"matrix")
11  stopifnot(dim(m5) == 5:6,  stopifnot(dim(m5) == 5:6,
12            class(cm5 <- crossprod(m5)) == "dpoMatrix")            class(cm5 <- crossprod(m5)) == "dpoMatrix")
13  assert.EQ.mat((c.m5 <- t(m5) %*% m5), as(cm5, "matrix"))  assert.EQ.mat((c.m5 <- t(m5) %*% m5), as(cm5, "matrix"))
14    ## crossprod() with numeric vector RHS and LHS
15    ## not sensical for tcrossprod() because of 'vec' --> cbind(vec) promotion:
16    assert.EQ.mat( crossprod(rep(1,5), m5),  rbind( colSums(m5)))
17    assert.EQ.mat( crossprod(rep(1,5), m.),  rbind( colSums(m5)))
18    assert.EQ.mat( crossprod(m5, rep(1,5)),  cbind( colSums(m5)))
19    assert.EQ.mat( crossprod(m., rep(1,5)),  cbind( colSums(m5)))
20    
21  ## classes differ; but the 'dimnames' are *both* missing -- FIXME  ## classes differ; but the 'dimnames' are *both* missing -- FIXME
22  tc.m5 <- m5 %*% t(m5)  tc.m5 <- m5 %*% t(m5)
23  (tcm5 <- tcrossprod(m5)) # "dpo*"  (tcm5 <- tcrossprod(m5)) # "dpo*"

Legend:
Removed from v.1330  
changed lines
  Added in v.1331

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