[petsc-users] Preserving nonzero structure during MatMatMult

Matthew Knepley knepley at gmail.com
Thu Sep 3 18:57:28 CDT 2015


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


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



-- 
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150903/765de781/attachment.html>


More information about the petsc-users mailing list