cholsolve {sparseinv} | R Documentation |
Solve the equation Qx = y
Description
This function is similar to solve(Q,y)
but with the added benefit that it allows for permuted matrices. This function does the job in order to minimise
user error when attempting to re-permute the matrices prior or after solving. The user also has an option for the permuted Cholesky factorisation of Q to be carried out
internally.
Usage
cholsolve(Q = NULL, y = NULL, perm = FALSE, cholQ = NULL,
cholQp = NULL, P = NULL)
Arguments
Q |
matrix (if of class |
y |
matrix with the same number of rows as Q |
perm |
if FLASE no permutation is carried out, if TRUE permuted Cholesky factors are used |
cholQ |
the lower Cholesky factor of Q (if known already) |
cholQp |
the lower Cholesky factor of a permuted Q (if known already) |
P |
the permutation matrix (if known already) |
Value
x solution to Qx = y
References
Havard Rue and Leonhard Held (2005). Gaussian Markov Random Fields: Theory and Applications. Chapman & Hall/CRC Press
Examples
require(Matrix)
Q = sparseMatrix(i = c(1, 1, 2, 2),
j = c(1, 2, 1, 2),
x = c(0.1, 0.2, 0.2, 1))
y = matrix(c(1, 2), 2, 1)
cholsolve(Q, y)