Re: [Rcpp-devel] Sparse matrix and RcppEigen

2015-06-10 Thread Balamuta, James Joseph
Thanks for the reproducible example! Here is the solution: library(Matrix) Omega <- Matrix(c(1,0.8,0.8,1),2,2) invSqrtV <- Diagonal(2,1) Omega.M <- as(as.matrix(Omega),"dgCMatrix") invSqrtV.M <- as.vector(diag(invSqrtV)) partialsolveCS <- ' using namespace Rcpp; using namespace Eigen; const Spar

Re: [Rcpp-devel] Sparse matrix and RcppEigen

2015-06-10 Thread Wagner Bonat
or when calling the compile statement of: “Error: No > such slot.” > > > So, I have a funny feeling the conversions in place do not account for the > sparse diagonal matrix class (ddiMatrix). > > It is at this point, that I can’t advise you anymore outside of saying &

Re: [Rcpp-devel] Sparse matrix and RcppEigen

2015-06-09 Thread Balamuta, James Joseph
o: Yixuan Qiu Cc: rcpp-devel@lists.r-forge.r-project.org Subject: Re: [Rcpp-devel] Sparse matrix and RcppEigen Dear all, As requested I will try provide a better explanation. Consider the code below: Let C = V^{1/2}%*%Omega%*%V^{1/2} and C^{1/2} be the Cholesky decomposition, such that C^{1/2}%*

Re: [Rcpp-devel] Sparse matrix and RcppEigen

2015-06-09 Thread Wagner Bonat
Dear all, As requested I will try provide a better explanation. Consider the code below: Let C = V^{1/2}%*%Omega%*%V^{1/2} and C^{1/2} be the Cholesky decomposition, such that C^{1/2}%*%C^{1/2}^T = C. My goal is to compute Omega^{-1/2}%*%V{-1/2}. My idea is to use that I know V^{-1/2} and rewrite

Re: [Rcpp-devel] Sparse matrix and RcppEigen

2015-06-08 Thread Yixuan Qiu
Hello Wagner, I think there is some confusion in your question. From your first code chunk, it seems that you first compute the Cholesky decomposition C=LL', and then calculate L^{-1} * V^{-1/2}. However, this is *NOT* equal to C^{-1/2} V^{-1/2}. In the usual sense, C^{1/2} is defined to be a matri

Re: [Rcpp-devel] Sparse matrix and RcppEigen

2015-06-08 Thread Balamuta, James Joseph
Greetings and Salutations Wagner, 1. I think you solved your own initial problem as it relates to solving matrices within eigen using the “solver” class. e.g. SparseMatrix A; SparseMatrix B; SolverClassName > solver(A); SparseMatrix x = solver.solve(B); 2. Taking a square root of a matrix in

[Rcpp-devel] Sparse matrix and RcppEigen

2015-06-08 Thread Wagner Bonat
Dear all, I need to solve a linear system using only the lower triangular matrix from the Cholesky decomposition of a SPD matrix. My goal is to compute C^{-1/2} V^{-1/2} where V^{-1/2} and C are known matrices. For general matrix class MatrixXd I can do using the code below. But, now I would like