Hi,<br><br>I wanted to solve some least squares problems using PETSc. My test matrix is size 3x2 but I wish to use this code for solving large ill-conditioned rectangular systems later. <br><br>Looking at the PETSc manual I the found the KSPLSQR routine which implements the LSQR algorithm. <br>
<br>However I am unsure how to use this routine. I am pasting the lines of the code which I use to set up the solver. <br><br>Through the terminal I pass the option -ksp_type lsqr while running exectuable. <br><br> ierr = KSPCreate(PETSC_COMM_WORLD,&ksp);CHKERRQ(ierr);<br>
<br> ierr = KSPSetOperators(ksp,A,PETSC_NULL,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr);<br><br>ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);<br><br> ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr); <br><br> ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr); <br>
<br>As you can see I have used PETSC_NULL for the preconditioner matrix since I wish to use the *unpreconditioned* version of the LSQR algorithm. This gives me an error. <br><br>If I pass the matrix A it gives me an error again. I am not sure how to tell PETSc not to use a preconditioner. <br>
<br>Could you please tell me how I should use KSPSetOperators statement in this case to use the unpreconditioned algorithm.<br><br>If you have a better sparse matrix least squares algorithm implemented please let me know. <br>
<br><br> <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>