Hi Dave,

Thank you very much for your reply. That is indeed the problem. I have been 
working with matrices in Slepc but I don’t really understand it. I tried to 
preallocate but it still does not work. If you look at my code below:

ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr);
ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,h_dim,h_dim);                    
  // h_dim is the dimension of the square matrix A
ierr = MatSetFromOptions(A);CHKERRQ(ierr);
ierr = MatSetUp(A);CHKERRQ(ierr);
ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr);

MatSeqAIJSetPreallocation(A,0,nnz);                                       // I 
try to preallocate here, where nnz is the array containing the number of 
non-zero entries each row

for (int i=0;i<row.size();i++) {
MatSetValue(A,row[i],column[i],h[i],INSERT_VALUES);
}

I am not sure what other information I need to give for the pre-allocation…

Cheers,

Yang Bo



On 21 May 2020, at 4:08 PM, Dave May 
<[email protected]<mailto:[email protected]>> wrote:

-info | grep malloc

________________________________

CONFIDENTIALITY: This email is intended solely for the person(s) named and may 
be confidential and/or privileged. If you are not the intended recipient, 
please delete it, notify us and do not copy, use, or disclose its contents.
Towards a sustainable earth: Print only when necessary. Thank you.

Reply via email to