# \donttest{
if (FALSE) {
#solve a system of equations:
a <- gpu.matrix(rnorm(9),nrow=3,ncol=3)
b <- c(1,1,1)
betas <- solve(a,b)
a %*% betas
#the inverse matrix
inv <- solve(a)
a %*% inv
#inverse using ginv
inv_2 <- ginv(a)
a %*% inv_2
#chol_solve: it can be applies only if
# in the equation Ax=b A is real symmetric positive-definite square matrix.
a <- gpu.matrix(rnorm(9),3,3)
A <- tcrossprod(a) #A is symmetrix positive-definite
b <- gpu.matrix(rnorm(3))
x_solve <- solve(A,b) #using solve to compare results
x_chol_solve <- chol_solve(t(chol(A)),b) #using chol_solve
#NOTE: notice that the input for chol_solve is the Cholesky decomposition
# of matrix A.
}
# }
Run the code above in your browser using DataLab