[petsc-users] MatSetValuesCOO after MatDuplicate

Maxime Bouyges maxime.bouyges at gmail.com
Wed Apr 26 15:07:01 CDT 2023


Dear PETSc developers,

I am trying to use the MatSetValuesCOO function (very appropriate and 
performant for my case) but I am encountering a problem when I use it on 
a Mat obtained with MatDuplicate. It seems that the non-zero pattern is 
preserved by MatDuplicate, but not the "COO information". Here are the 
few steps to reproduce the problem:
MatCreate(comm, A)
MatSetUp(A)
MatSetPreallocationCOO(A, ncoo, coo_i, coo_j)
MatSetValuesCOO(A, coo_v, INSERT_VALUES) # -> works ok
MatDuplicate(A, MAT_DO_NOT_COPY_VALUES, B)
MatSetValuesCOO(B, coo_v, INSERT_VALUES) # -> seg-fault

Is this an expected behaviour? Of course if I call again 
MatSetPreallocationCOO on the duplicated matrix it's ok but the 
performance is lost in my case. Is there a way to fix it? Thank you in 
advance.

Best regards,

Maxime Bouyges



More information about the petsc-users mailing list