[petsc-users] Copy dense matrix into half part of another dense matrix

Pierre Jolivet pierre at joliv.et
Mon Jan 27 07:42:01 CST 2025



> On 27 Jan 2025, at 2:23 PM, medane.tchakorom at univ-fcomte.fr wrote:
> 
> Dear PETSc users,
> 
> I hope this message finds you well. I don’t know If my question is relevant, but I’am currently working with DENSE type matrix, and would like to copy one matrix R_part [ n/2 x m] (resulted from a MatMatMult operation) into another dense matrix R_full [n x m].  
> Both matrices being on the same communicator, I would like to efficiently copy R_part in the first half of R_full. 
> I have being using MatSetValues, but for large matrices, the subsequent assembling operation is costly.

Could you please share the output of -log_view as well as a single file that will be generated with -info dump (e.g., dump.0, the file associated to process #0)?
This shouldn’t be that costly, so there may be an option missing, like MAT_NO_OFF_PROC_ENTRIES.
Anyway, if you want to optimize this, the fastest way would be to call MatDenseGetArray[Read,Write]() and then do the necessary PetscArraycpy().

Thanks,
Pierre

> Please could you suggest me some strategies or functions to do this efficiently. 
> 
> Thank you for your time and assistance.
> 
> Best regards,
> Tchakorom Medane
> 



More information about the petsc-users mailing list