csolve | R Documentation |
This is a wrapper for the Cholesky-solvers 'LLT' (dense case) or 'Simplicial-LLT' (sparse case) from Eigen. The function computes the solution:
\mathbf{b} = \mathbf{X}^{-1} \mathbf{y}
If no vector y
is passed, an identity matrix will be assigned
and the function returns the inverse of \mathbf{X}
.
In the case of multiple right hand sides (as is the case when computing an inverse matrix)
multiple threads will solve equal parts of it.
csolve(X,y=NULL)
X |
positive definite square matrix of type |
y |
numeric vector of length equal to columns/rows of |
Solution vector/matrix
# Least Squares Solving
# Generate random data
n = 1000
p = 500
M <- matrix(rnorm(n*p),n,p)
y <- rnorm(n)
# least squares solution:
b <- csolve(t(M) %c% M, t(M) %c% y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.