Check the output of MatMatMult(). If your matrix product has all diagonal entries? How large is your matrix? Hong
________________________________ From: petsc-users <petsc-users-boun...@mcs.anl.gov> on behalf of Yang Juntao <y.jun...@hotmail.com> Sent: Thursday, June 4, 2020 4:01 AM To: petsc-users@mcs.anl.gov <petsc-users@mcs.anl.gov> Subject: [petsc-users] Slow speed to SetValues for matrix created by PETSC by mat_initial_matrix Hello, I computed a preconditioned matrix by MatMatMulti(), and I generated the new matrix with option MAT_INITIAL_MATRIX. However I need to change the generated matrix by insert value 1 to half of the diagonal. MatSetValue() is used but the speed a much slower than MatSetValue with matrix setup by MatCreate() and MatSeqAIJPreallocation(). I would like to ask is it due to the preallocation setting of MAT_INITIAL_MATRIX generated matrix and how I can change it? Thanks in advance JT