[petsc-users] Off-diagonal matrix-vector product y=(A-diag(A))x

Barry Smith bsmith at mcs.anl.gov
Fri Apr 14 11:37:15 CDT 2017


   You can do MatGetDiagonal() then do a MatMult() followed by subtracting a VecPointsizeMult(). Sure it is extra work but likely it is good enough. Only if you run profiling on your full application and find substantial time in these two ops you could write a custom multiply by taking the MatMult_SeqAIJ and copying it and modifying it.


   Barry

> On Apr 14, 2017, at 3:55 AM, Ingo Gaertner <ingogaertner.tus at gmail.com> wrote:
> 
> Does PETSc include an efficient implementation for the operation
> y=(A-diag(A))x or y_i=\sum_{j!=i}A_{ij}x_j on a sparse matrix A?
> 
> In words, I need a matrix-vector product after the matrix diagonal has been set to zero. For efficiency reasons I can't copy and modify the matrix or first calculate the full product and then subtract the diagonal contribution.
> 
> Thanks
> Ingo



More information about the petsc-users mailing list