SCM

SCM Repository

[matrix] Diff of /pkg/man/pMatrix-class.Rd
ViewVC logotype

Diff of /pkg/man/pMatrix-class.Rd

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 60  Line 60 
60  solve(pm1)  solve(pm1)
61  pm1 \%*\% t(pm1) # check that the transpose is the inverse  pm1 \%*\% t(pm1) # check that the transpose is the inverse
62  stopifnot(identical(diag(3), as(pm1 \%*\% t(pm1), "matrix")))  stopifnot(identical(diag(3), as(pm1 \%*\% t(pm1), "matrix")))
63    
64    set.seed(11)
65    ## random permutation matrix :
66    (p10 <- as(sample(10),"pMatrix"))
67    
68    ## Permute rows / columns of a numeric matrix :
69  (mm <- round(array(rnorm(3 * 3), c(3, 3)), 2))  (mm <- round(array(rnorm(3 * 3), c(3, 3)), 2))
70  mm \%*\% pm1  mm \%*\% pm1
71  pm1 \%*\% mm  pm1 \%*\% mm
72  try(as(as.integer(c(3,3,1)), "pMatrix"))# Error: not a permutation  try(as(as.integer(c(3,3,1)), "pMatrix"))# Error: not a permutation
73    
74  as(pm1, "lgTMatrix")  as(pm1, "lgTMatrix")
75    p10[1:7, 1:4] # gives an "lgTMatrix" (most economic!)
76  }  }
77  \keyword{classes}  \keyword{classes}
78    

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