<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Apr 8, 2017 at 8:26 AM, Kaushik Kulkarni <span dir="ltr"><<a href="mailto:kaushikggg@gmail.com" target="_blank">kaushikggg@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div dir="auto">I guess there is a miscalculation:</div><div>2*row1 + row2 = (4, 0, 0)</div></div></blockquote><div><br></div><div>You are right here, but I think it is still rank deficient.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div dir="auto">Thanks,</div><div dir="auto">Kaushik<br><div class="gmail_extra" dir="auto"><br><div class="gmail_quote">On Apr 8, 2017 6:52 PM, "Matthew Knepley" <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:<br type="attribution"><blockquote class="m_4105581865856356402quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div class="m_4105581865856356402quoted-text">On Sat, Apr 8, 2017 at 6:54 AM, Kaushik Kulkarni <span dir="ltr"><<a href="mailto:kaushikggg@gmail.com" target="_blank">kaushikggg@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-family:verdana,sans-serif">Hello,<br></div><div style="font-family:verdana,sans-serif">I just started with PETSc and was trying the KSP Solvers. I was trying for the problem - <br><br>int main(int argc, char *argv[])<br>{ <br> /// matrix creation variables.<br> PetscInt *idxm = new PetscInt[3];<br> PetscInt *idxn = new PetscInt[3];<br></div></div></blockquote><div><br></div></div><div>Note that the problem below is rank deficient (2 * row 1 + row 2 = 0). Its not clear to me whether b is</div><div>in the range space of the operator.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div class="m_4105581865856356402elided-text"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-family:verdana,sans-serif"> PetscReal loc[] = { 1.0, -2.0, -6.0,<br> <wbr> 2.0, 4.0, 12.0,<br> <wbr> 1.0, -4.0,-12.0};<br> PetscReal b_array[] = { 12.0, <br> -17.0,<br> 22.0};<br> PetscInt i;<br> KSP ksp; <br> <br> /// Declaring the vectors<br> Vec x, b;<br><br> // Declaring matrices<br> Mat A;<br><br> PetscInitialize(&argc,&argv,(c<wbr>har*)0,help);<br> // Creating vectors<br> VecCreateSeq(PETSC_COMM_SELF, 3, &x);<br> VecCreateSeq(PETSC_COMM_SELF, 3, &b);<br> // Creating matrix<br> MatCreateSeqAIJ(PETSC_COMM_SEL<wbr>F, 3, 3, 3, NULL, &A);<br> // Creating the indices<br> for(i=0; i<3; i++) {<br> idxm[i] = i;<br> idxn[i] = i;<br> }<br> // Assembling the vector b and x<br> VecSetValues(b, 3, idxm, b_array, INSERT_VALUES);<br> VecAssemblyBegin(b);<br> VecAssemblyEnd(b);<br> <br> //Assembling the Matrix <br> MatSetValues(A, 3, idxm, 3, idxn, loc, INSERT_VALUES);<br> MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY);<br> MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY);<br><br> // KSP related operations<br> KSPCreate(PETSC_COMM_SELF, &ksp);<br> KSPSetType(ksp, KSPGMRES);<br> KSPSetOperators(ksp, A, A);<br> KSPSetFromOptions(ksp);<br> KSPSolve(ksp,b,x);<br> KSPDestroy(&ksp);<br><br> VecView(x, PETSC_VIEWER_STDOUT_SELF);<br><br> PetscFinalize();<br> return 0;<br>}<br><br></div><div style="font-family:verdana,sans-serif">But the obtained solution is found out to be- (inf, inf, inf).<br><br></div><div style="font-family:verdana,sans-serif">I wanted to know whether I am doing something wrong or is the problem inherently not solvable using GMRES. Currently I am running the code in a sequential manner(no parallelism intended).<br><br></div><div style="font-family:verdana,sans-serif">Thank you. <br clear="all"></div></div>
</blockquote></div></div><font color="#888888"><br><br clear="all"><span class="HOEnZb"><font color="#888888"><div><br></div>-- <br><div class="m_4105581865856356402m_2936315764055467821gmail_signature" data-smartmail="gmail_signature">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>
</font></span></font></div></div>
</blockquote></div><br></div></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">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></div>