Description Usage Arguments Value Author(s) Examples
This routine use the GMRFLib implementation to solve linear systems with a SPD matrix.
1 2 | inla.qsolve(Q, B, reordering, method = c("solve", "forward", "backward"))
|
Q |
A SPD matrix, either as a (dense) matrix, sparse-matrix or a filename containing the matrix (in the fmesher-format). |
B |
The right hand side matrix, either as a (dense) matrix, sparse-matrix or a filename
containing the matrix (in the fmesher-format).
(Must be a matrix or sparse-matrix even if |
reordering |
The type of reordering algorithm to be used; either one of the names listed in |
method |
The system to solve, one of |
inla.qsolve
returns a matrix X
, which is the solution of Q X = B
, L X = B
or L^T X = B
depending on the value of method
.
Havard Rue hrue@math.ntnu.no
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | n = 10
QQ = matrix(runif(n^2), n, n)
Q = inla.as.dgTMatrix(QQ %*% t(QQ))
B = matrix(runif(n^2-n), n, n-1)
X = inla.qsolve(Q, B, method = "solve")
print(paste("err", sum(abs( Q %*% X - B))))
L = t(chol(Q))
X = inla.qsolve(Q, B, method = "forward")
print(paste("err", sum(abs( L %*% X - B))))
X = inla.qsolve(Q, B, method = "backward")
print(paste("err", sum(abs( t(L) %*% X - B))))
Q.file = INLA:::inla.write.fmesher.file(Q)
B.file = INLA:::inla.write.fmesher.file(B)
X = inla.qsolve(Q.file, B.file, method = "backward")
print(paste("err", sum(abs( t(L) %*% X - B))))
unlink(Q.file)
unlink(B.file)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.