<div dir="ltr"><div dir="ltr">Hi Leonardo,</div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Fri, Mar 27, 2026 at 11:35 AM Leonardo De Novellis via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<div style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(33,33,33)" dir="auto">
Dear Users Support Team,</div>
<div style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(33,33,33)" dir="auto">
I have a couple of questions regarding QR decompositions in PETSc.</div>
<div style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(33,33,33)" dir="auto">
<br>
</div>
<div style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(33,33,33)" dir="auto">
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).</div>
<div style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(33,33,33)" dir="auto">
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.</div>
<div style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(33,33,33)" dir="auto">
Currently, I am running my code on only 1 core, and A is of type seqaij. With this setup, the following code works fine:</div>
<div style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(33,33,33)" dir="auto">
<br>
</div>
<div style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(33,33,33)" dir="auto">
call KSPSetType(ksp, KSPPREONLY, ierr)</div>
<div style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(33,33,33)" dir="auto">
call KSPGetPC(ksp, pc, ierr)</div>
<div style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(33,33,33)" dir="auto">
call PCSetType(pc, PCQR, ierr)</div>
<div style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(33,33,33)" dir="auto">
call KSPSetOperators(ksp, A, A, ierr)</div>
<div style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(33,33,33)" dir="auto">
t1 = MPI_Wtime()</div>
<div style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(33,33,33)" dir="auto">
call KSPSolve(ksp, b, x, ierr)</div>
<div style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(33,33,33)" dir="auto">
t2 = MPI_Wtime()</div>
<div style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(33,33,33)" dir="auto">
<br>
</div>
<div style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(33,33,33)" dir="auto">
I eventually want to run this in parallel on multiple cores. Will PCQR work for an mpiaij / mpidense matrix?</div></div></blockquote><div><br></div><div>No it is only serial. We could call the ScLAPACK or Elemental version of QR, but we don't right now.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(33,33,33)" dir="auto"> If not, what would you suggest as a direct solving approach for this system?</div></div></blockquote><div><br></div><div>It would be easy to make the normal equations (dot products would make the matrix on all procs) and factor.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>
<div style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(33,33,33)" dir="auto">
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?</div></div></blockquote><div><br></div><div>I would definitely recommend using BV. I have been meaning to pull that into PETSc because it is so great, but have not done it yet. You can just reconfigure with --download-slepc and run with it.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>
<div style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(33,33,33)" dir="auto">
Kind regards,</div>
<div style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(33,33,33)" dir="auto">
Leonardo</div>
<div id="m_1865389270752926436ms-outlook-mobile-body-separator-line" style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt">
<div style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt">
<br>
</div>
</div>
<div style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt" id="m_1865389270752926436ms-outlook-mobile-signature">
<div style="font-family:Aptos,Aptos_MSFontService,-apple-system,Roboto,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(33,33,33)">
<br>
</div>
</div>
</div>
</blockquote></div><div><br clear="all"></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!Z4T-_YeS6p8NNr11QP3I3s_AuA703BYFYU_kioU8FmIJV9NlyY9GTk0HN36-zO9hRinjxpI1ipiRQTzD2Xzg$" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>