<p dir="ltr">I have a system of equations:</p>
<p dir="ltr">a11*x1 + a12*x2 + ... + a1n*xn = b1<br>
a21*x1 + a22*x2 + ... + a2n*xn = b2<br>
.<br>
.<br>
.<br>
an1*x1 + an2*x2 + ... + ann*xn = bn</p>
<p dir="ltr">Let's say I want to modify the first equation, but I don't want to lose the information there, so I will add first the first and second equations, store the result in the second equation and then modify the first equation. Like this:</p>
<p dir="ltr">x1 - x2 = 0<br>
(a11+a21)*x1 + (a12+a22)*x2 + ... + (a1n+a2n)*xn = b1+b2<br>
.<br>
.<br>
.<br>
an1*x1 + an2*x2 + ... + ann*xn = bn</p>
<p dir="ltr">And I want to do this for a few rows of my matrix. I have already built the nonzero structure so that these additions can be done without hitting a non preallocated location (for example a case where a21 was never allocated because it was meant to be zero always and now, with a11 present, it's different than zero). </p>
<p dir="ltr">Any hints?</p>
<p dir="ltr">Thanks!</p>
<p dir="ltr">Carles</p>
<div class="gmail_quote">El dia 19/11/2015 19:55, "Barry Smith" <<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>> va escriure:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
> On Nov 19, 2015, at 11:25 AM, Carles Bona <<a href="mailto:carlesbona@gmail.com">carlesbona@gmail.com</a>> wrote:<br>
><br>
> Dear all,<br>
><br>
> I would like to add some of my equations before I modify them.<br>
<br>
   Please explain what you mean by this. Algebraically exactly what do you want to do?<br>
<br>
<br>
> I haven't found any high level function that would allow me to add rows of a matrix (I am working with a parallel BAIJ). Is there any nice way of doing this?<br>
><br>
> I have tried with MatGetRow/MatRestoreRow, but I am struggling a bit to retain the cols and vals, as only one processor can call MatGetRow but if only that processor tries to allocate memory then one gets a segmentation fault. I guess I should allocate enough memory on all processors...<br>
><br>
> If I refrain from storing the cols and vals I need to call MatSetValues before returning the pointer, with a subsequent call to assemblybegin/end for each row, which slows down the code.<br>
><br>
> The other option would be to forget about these row additions after the matrix has been filled and try to fill it while taking into account these row additions at the same time. I guess I need to be constantly checking for indices then.<br>
><br>
> So, which option (not necessarily mentioned here) would you reccomend?<br>
><br>
> Thanks a lot,<br>
><br>
> Carles<br>
<br>
</blockquote></div>