The R Project SVN R-packages

Rev

Rev 4006 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4006 Rev 5017
Line 75... Line 75...
75
stopifnot(inherits(tt, "try-error"),
75
stopifnot(inherits(tt, "try-error"),
76
          is(fLU <- M@factors $ LU, "MatrixFactorization"))
76
          is(fLU <- M@factors $ LU, "MatrixFactorization"))
77
(e.lu <- expand(fLU))
77
(e.lu <- expand(fLU))
78
M2 <- with(e.lu, P %*% L %*% U)
78
M2 <- with(e.lu, P %*% L %*% U)
79
assert.EQ.mat(M2, as(M, "matrix"))
79
assert.EQ.mat(M2, as(M, "matrix"))
-
 
80
## now the sparse LU :
-
 
81
M. <- as(M,"sparseMatrix")
-
 
82
tt <- try(solve(M.)) # less nice: factor is *not* cached
-
 
83
## use a non-singular one:
-
 
84
M1 <- M. + 0.5*Diagonal(nrow(M.))
-
 
85
luM1 <- lu(M1)
-
 
86
d1 <- determinant(as(M1,"denseMatrix"))
-
 
87
stopifnot(identical(luM1, M1@factors$LU),
-
 
88
	  diag(luM1@L) == 1,# L is *unit*-triangular
-
 
89
	  all.equal(log(-prod(diag(luM1@U))), c(d1$modulus)))
80
 
90
 
81
cat('Time elapsed: ', proc.time(),'\n') # for ``statistical reasons''
91
cat('Time elapsed: ', proc.time(),'\n') # for ``statistical reasons''