SCM

SCM Repository

[matrix] View of /pkg/tests/mm-redo.R
ViewVC logotype

View of /pkg/tests/mm-redo.R

Parent Directory Parent Directory | Revision Log Revision Log


Revision 660 - (download) (annotate)
Thu Mar 17 17:53:43 2005 UTC (14 years, 5 months ago) by maechler
File size: 716 byte(s)
minor changes; less precision for platform portability
library(Matrix)

### Rebuild the 'mm' example matrix
### Use this if classes are changed

mmT <- as(mm, "dgTMatrix")
str(mmT)
mm3 <- cbind(i = mmT@i, j = mmT@j, x = mmT@x)
write.table(mm3, file = "mm-Matrix.tab", row.names=FALSE)# -> ASCII version

str(mmr <- read.table("mm-Matrix.tab", header = TRUE))
mmr$i <- as.integer(mmr$i)
mmr$j <- as.integer(mmr$j)

mmN <- with(mmr, new("dgTMatrix", Dim = c(max(i)+1:1,max(j)+1:1),
                     i = i, j = j, x = x))

stopifnot(identical(mmT, mmN)) # !!
## weaker (and hence TRUE too):
stopifnot(all.equal(as(mmN, "matrix"),
                    as(mmT, "matrix"), tol=0))

mm <- as(mmN, "dgCMatrix")
## save(mm, file = "....../Matrix/data/mm.rda", compress = TRUE)

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