<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Salazar:</div><div class="gmail_quote">Use <span style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14px">VecGetArray()/VecRestoreArray(</span><span style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14px">). They access arrays, do not create any </span><span style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14px">temporary sequential vectors.</span></div><div class="gmail_quote"><span style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14px"><br></span></div><div class="gmail_quote"><span style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14px">Hong</span></div><div class="gmail_quote"><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div style="word-wrap:break-word;color:rgb(0,0,0);font-size:14px;font-family:Calibri,sans-serif">
<div>Hello</div>
<div><br>
</div>
<div>Suppose I have four vectors A,B, C and D with the same number of components. I would like to do the following component wise vector operation:</div>
<div><br>
</div>
<div>(A – B) / (C + D)</div>
<div><br>
</div>
<div>I could calculate A-B and C+D and store the results in temporary PETSc vector temp_result1 and temp_result2 (I need to keep A,B, C and D unchanged) and then call VecPointwiseDivide(temp_result1,temp_result1,temp_result2) and get my result in temp_result1.</div>
<div><br>
</div>
<div>On the other hand, to avoid creating two temporary PETSc vectors, I could call VecGetArray()/VecRestoreArray() on the four vectors, iterate over the local indices and perform the same operations at once and store the result in another vector. What is the
best way and why? I think that VecGetArray() creates temporary sequential vectors as well. I’m not sure if this is what the above mentioned PETSc routines internally do.</div>
<div><br>
</div>
<div>Thanks</div><span class=""><font color="#888888">
<div>Miguel</div>
<div><br>
</div>
<div><br>
</div>
</font></span></div>
</blockquote></div><br></div></div>