[petsc-users] Questions on QR methods in PETSc

Leonardo De Novellis leonardo.denovellis at epfl.ch
Fri Mar 27 09:10:48 CDT 2026


Dear Users Support Team,
I have a couple of questions regarding QR decompositions in PETSc.

1) I would like to find the least-squares solution of a rectangular system of the form Ax = b, where A is a dense and tall-skinny matrix (size around 1000000 x 10).
Since A has very bad conditioning, I want to avoid iterative methods (such as KSPLSQR), since the number of iterations can get very large, and would like to use a direct QR solving method.
Currently, I am running my code on only 1 core, and A is of type seqaij. With this setup, the following code works fine:

call KSPSetType(ksp, KSPPREONLY, ierr)
call KSPGetPC(ksp, pc, ierr)
call PCSetType(pc, PCQR, ierr)
call KSPSetOperators(ksp, A, A, ierr)
t1 = MPI_Wtime()
call KSPSolve(ksp, b, x, ierr)
t2 = MPI_Wtime()

I eventually want to run this in parallel on multiple cores. Will PCQR work for an mpiaij / mpidense matrix? If not, what would you suggest as a direct solving approach for this system?

2) I would also like to compute an explicit QR decomposition of A, and want to do so in parallel. Is there any way to do so in PETSc? If not, as a possible alternative, would you recommend using SLEPc BVOrthogonalize function?

Kind regards,
Leonardo


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20260327/650c818d/attachment.html>


More information about the petsc-users mailing list