<div dir="auto">Cool, thanks a lot! </div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 25 May 2020, 18:52 Jed Brown, <<a href="mailto:jed@jedbrown.org">jed@jedbrown.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Edoardo alinovi <<a href="mailto:edoardo.alinovi@gmail.com" target="_blank" rel="noreferrer">edoardo.alinovi@gmail.com</a>> writes:<br>
<br>
> Dear Guys,<br>
><br>
> I have quick question for you. Can anyone tell me if MatDiagonalSet needs<br>
> also MatAssemblyBegin/MatAssemblyEnd to be called afterwards or not?<br>
<br>
It's called internally so you don't have to call again.<br>
<br>
> Basically, I am trying to compute: sum (a_nb*\phi_nb), where anb are the<br>
> off diagonal coeffs of the matrix and phi_nb the corresponding field<br>
> values.<br>
><br>
> I was thinking to set the matrix diagonal to zero using MatDiagonalSet and<br>
> then simply use MatMult(A, x) to accomplish my task. Do we have a better<br>
> way in PETSc? Any suggestion in welcome :)<br>
<br>
An alternative would be to extract the diagonal and subtract off the<br>
result of VecPointwiseMult(w, diag, phi).<br>
</blockquote></div>