Hello.
Let Q be a banded, symmetric, positive definite matrix. (The number of rows of Q is 2e+5) . I want to do the following:
- Compute the Cholesky factorization, Q=LU, where U=L^{T}
- Solve Lw = b
- Solve Um=w
- Sample z~N(0,1)
- Solve Uv=z
- Compute x=m+v
- Return x
Steps 2 and 3 give the solution of Qm=b.
I have asked this question here, but then Q was a triagonal, symmetric matrix. I used fuctions 'LAPACKE_dpbtrf, cblas_dtbsv'and solved the problem,
/* Colesky factorization */ info = LAPACKE_dpbtrf(LAPACK_COL_MAJOR, 'U', dim+1, 1, Sigmab, 2 ); if(info!= 0){mexPrintf( "C++ error: Cholesky failed"); } /* step 2*/ cblas_dtbsv(CblasColMajor, CblasUpper, CblasTrans, CblasNonUnit, dim, 1, Sigmab, 2, y1, 1); /* step 3*/ cblas_dtbsv(CblasColMajor, CblasUpper, CblasNoTrans, CblasNonUnit, dim, 1, Sigmab, 2, y1, 1); /* step 5 */ cblas_dtbsv(CblasColMajor, CblasUpper, CblasNoTrans, CblasNonUnit, dim, 1, Sigmab 2, y2, 1);
I found functions 'LAPACKE_dpbtrf, LAPACKE_dpbtrs'that give the solution of steps 2 and 3.
info = LAPACKE_dpbtrf(LAPACK_COL_MAJOR, 'L', dim, p, Sigma, p+1); if(info!= 0){mexPrintf( "C++ error: Cholesky failed"); } info = LAPACKE_dpbtrs(LAPACK_COL_MAJOR, 'L', dim, p, NRHS, Sigma, p+1, y1, dim); if(info!= 0){mexPrintf( "C++ error: the execution is not successful"); }
Firstly, I would like to ask if there is a better way to solve this and secondly I don't know how to find the solution of step 5.
Thank you very much.