SCM

SCM Repository

[matrix] View of /pkg/tests/dpoMatrix.R
ViewVC logotype

View of /pkg/tests/dpoMatrix.R

Parent Directory Parent Directory | Revision Log Revision Log


Revision 652 - (download) (annotate)
Wed Mar 16 01:08:36 2005 UTC (14 years, 5 months ago) by bates
File size: 732 byte(s)
Updates to multiplication and other methods
### Testing positive definite matrices

library(Matrix)

stopifnot(c(0,0) == dim(Hilbert(0)))

h9 <- Hilbert(9)
str(h9)
all.equal(determinant(h9)$modulus, -96.7369450737858, tol= 1e-15)
stopifnot(0 == length(h9@factors))# nothing yet
str(f9 <- as(chol(h9), "dtrMatrix"))
## h9 now has factorization
stopifnot(names(h9@factors) == "Cholesky")
stopifnot(all.equal(rcond(h9), 9.0938e-13))
stopifnot(all.equal(rcond(f9), 9.1272e-7, tol = 1e-6))# more precision fails
str(h9)# has 'rcond' and 'factors'
options(digits=4)
(cf9 <- crossprod(f9))# looks the same as  h9 :
stopifnot(all.equal(as(h9, "matrix"),
                    as(cf9,"matrix"), tol= 1e-15))

str(hp9 <- as(h9, "dppMatrix"))
(s9 <- solve(hp9, seq(nrow(hp9))))
hp9 %*% s9

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