Hi

I have some code which does (on a symmetric matrix 'x')

    backsolve(chol(x), diag(nrow(x)))

and I am wondering what is the recommended way to accomplish this when x
is also sparse (from package:Matrix). I know that package:Matrix
provides a chol method for such matrices, but not a backsolve method. On
the other hand, package:SparseM does provide a backsolve method, but
doesn't actually return a sparse matrix. Moreover, I am a little
hesitant to use SparseM, as the vignette seems to be from 2003.

I did notice that help(topic = "solve", package = "Matrix") says "In
‘solve(a,b)’ in the ‘Matrix’ package, ‘a’ may also be a
‘MatrixFactorization’ instead of directly a matrix." which makes me
think this is the right way:

    Matrix::solve(Cholesky(x), .sparseDiagonal(nrow(x)))

but unfortunately this didn't give the same result as:

    Matrix::solve(chol(x), .sparseDiagonal(nrow(x)))

so I'm asking here in case someone has any suggestions.

Regards,
Ben

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to