<html><body><div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000"><div>I am looking for QR factorization of (sequential) dense matrix: is this available in PETSc ? I "just" need the diagonal of R (I do not need neither the full content of R, nor Q)<br></div><div><br></div><div>I found that (old !) thread <a href="https://lists.mcs.anl.gov/pipermail/petsc-users/2013-November/019577.html">https://lists.mcs.anl.gov/pipermail/petsc-users/2013-November/019577.html</a> that says it could be implemented: has it been done ?<br></div><div>As for a direct solve, the way to go is "KSPSetType(ksp, KSPPREONLY); PCSetType(pc, PCLU);", I was expecting something like "KSPSetType(ksp, KSPPREONLY); PCSetType(pc, PCQR);"... But it seems there is no PCQR available. Or is it possible to do that using "an iterative way" with a specific kind of KSP that triggers a Gram Schmidt orthogonalization in back-end ? (I have seen a KSPLSQR but could I get Q and R back ? As I understand this, I would say no: I would say the user can only get the solution)<br></div><div><br></div><div>Is it possible to QR a (sequential) dense matrix in PETSc ? If yes, what are the steps to follow ?<br></div><div><br></div><div>Franck<br></div><div><br></div><div><div>My understanding is that DGEQRF from lapack can do "more" than what I need, but, no sure to get if I can use it from PETSc through a KSP:</div>>> git grep DGEQRF<br>include/petscblaslapack_stdcall.h:# define LAPACKgeqrf_ DGEQRF<br>>> git grep LAPACKgeqrf_<br>include/petscblaslapack.h:PETSC_EXTERN void LAPACKgeqrf_(PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);<br>include/petscblaslapack_mangle.h:#define LAPACKgeqrf_ PETSCBLAS(geqrf,GEQRF)<br>include/petscblaslapack_stdcall.h:# define LAPACKgeqrf_ SGEQRF<br>include/petscblaslapack_stdcall.h:# define LAPACKgeqrf_ DGEQRF<br>include/petscblaslapack_stdcall.h:# define LAPACKgeqrf_ CGEQRF<br>include/petscblaslapack_stdcall.h:# define LAPACKgeqrf_ ZGEQRF<br>include/petscblaslapack_stdcall.h:PETSC_EXTERN void PETSC_STDCALL LAPACKgeqrf_(PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);<br>src/dm/dt/interface/dt.c: PetscStackCallBLAS("LAPACKgeqrf",LAPACKgeqrf_(&M,&N,A,&lda,tau,work,&ldwork,&info));<br>src/dm/dt/interface/dtfv.c: LAPACKgeqrf_(&M,&N,A,&lda,tau,work,&ldwork,&info);<br>src/ksp/ksp/impls/gmres/agmres/agmres.c: PetscStackCallBLAS("LAPACKgeqrf",LAPACKgeqrf_(&lC, &KspSize, agmres->hh_origin, &ldH, agmres->tau, agmres->work, &lwork, &info));<br>src/ksp/pc/impls/bddc/bddcprivate.c: PetscStackCallBLAS("LAPACKgeqrf",LAPACKgeqrf_(&Blas_M,&Blas_N,qr_basis,&Blas_LDA,qr_tau,&lqr_work_t,&lqr_work,&lierr));<br>src/ksp/pc/impls/bddc/bddcprivate.c: PetscStackCallBLAS("LAPACKgeqrf",LAPACKgeqrf_(&Blas_M,&Blas_N,qr_basis,&Blas_LDA,qr_tau,qr_work,&lqr_work,&lierr));<br>src/ksp/pc/impls/gamg/agg.c: PetscStackCallBLAS("LAPACKgeqrf",LAPACKgeqrf_(&Mdata, &N, qqc, &LDA, TAU, WORK, &LWORK, &INFO));<br>src/tao/leastsquares/impls/pounders/pounders.c: PetscStackCallBLAS("LAPACKgeqrf",LAPACKgeqrf_(&blasnp,&blasnplus1,mfqP->Q_tmp,&blasnpmax,mfqP->tau_tmp,mfqP->mwork,&blasmaxmn,&info));<br>src/tao/leastsquares/impls/pounders/pounders.c: PetscStackCallBLAS("LAPACKgeqrf",LAPACKgeqrf_(&blasn,&blask,mfqP->Q,&blasnpmax,mfqP->tau,mfqP->mwork,&blasmaxmn,&info));</div></div></body></html>