[petsc-users] Basic vector calculation question
Salazar De Troya, Miguel
salazardetro1 at llnl.gov
Wed Jan 27 11:34:09 CST 2016
Hello
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:
(A – B) / (C + D)
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.
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.
Thanks
Miguel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160127/c680e0da/attachment.html>
More information about the petsc-users
mailing list