[petsc-users] Preserving nonzero structure during MatMatMult

Ghosh, Swarnava sghosh2012 at gatech.edu
Thu Sep 3 20:31:06 CDT 2015


Hi Matt, 


The motivation is to calculate density matrix in electronic structure calculations. 
The density matrix can be obtained recursively iterations (known as density matrix purification). An example is 


X_{n+1} = 3 X_n^2 - 2 X_n^3 


Density matrix has property of off diagonal decay. 


To do this I was planning to setup the non-zero structure of these matrices using the decay estimates and then proceed with the iteration such that the non-zero structure of the product matrices are preserved. In doing so I would need to do MatMatMultSymbolic once. 


Another option I thought of is to truncate the values in the product matrix after MatMatMultNumeric. However this would require to do MatMatMultSymbolic for every subsequent matrix product and also matrix assembly after every truncation and would not be very efficient. 


Please let me know if you have any other thoughts regarding this. 




Regards. 
Swarnava 
----- Original Message -----

From: "Matthew Knepley" <knepley at gmail.com> 
To: "Swarnava Ghosh" <sghosh2012 at gatech.edu> 
Cc: "PETSc users list" <petsc-users at mcs.anl.gov> 
Sent: Thursday, September 3, 2015 7:57:28 PM 
Subject: Re: [petsc-users] Preserving nonzero structure during MatMatMult 




On Thu, Sep 3, 2015 at 6:55 PM, Ghosh, Swarnava < sghosh2012 at gatech.edu > wrote: 


Hi, 

I want to do the following: 
Matrices DM1, DM2 and DM3 (MPIAIJ type) have the same non zero structure. I want to multiply DM1*DM2=DM3. BUT the resulting matrix should preserve the initial non-zero pattern that was set to it. Basically multiplication should not create new non-zero locations. 

For this I do: 

/* after setting the nonzero locations/* 

ierr = MatAssemblyBegin(DM1,MAT_FINAL_ASSEMBLY); CHKERRQ(ierr); 
ierr = MatAssemblyEnd(DM1,MAT_FINAL_ASSEMBLY); CHKERRQ(ierr); 

MatSetOption(DM1,MAT_NEW_NONZERO_LOCATIONS,PETSC_FALSE); 
MatSetOption(DM1,MAT_KEEP_NONZERO_PATTERN,PETSC_TRUE); 


Similarly for the matrices DM2 and DM3, the above is done. 

However When I do MatMatMultSymbolic, the number of non-zeros change, 

BEFORE MULT: NNZ allocated : 531441.000000 NNZ used: 518155.000000 
AFTER MULT: NNZ allocated : 2350209.000000 NNZ used: 2350209.000000 


Could you let me know how do I preserve the nonzero locations after MatMatMult? 





We do not support that. What is the motivation? 


Thanks, 


Matt 

<blockquote>
Regards, 
Swarnava 
-- 
Swarnava Ghosh 
PhD Candidate, 
Structural Engineering, Mechanics and Materials 
School of Civil and Environmental Engineering 
Georgia Institute of Technology 
Atlanta, GA 30332 

</blockquote>




-- 

What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. 
-- Norbert Wiener 


-- 

Swarnava Ghosh 
PhD Candidate, 
Structural Engineering, Mechanics and Materials 
School of Civil and Environmental Engineering 
Georgia Institute of Technology 
Atlanta, GA 30332 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150903/beffad42/attachment.html>


More information about the petsc-users mailing list