[petsc-users] Sparse Matrix Matrix Multiply

Barry Smith bsmith at petsc.dev
Thu Aug 12 11:09:59 CDT 2021


   I don't understand. Why do you wish the new matrix-matrix product vector to have the same nonzero pattern as the basic dm matrix? 

   If you multiple two dm matrices together it will generally have a larger stencil then the dm matrix but this is normal and the new product matrix handles it correctly. You should not copy this new "larger" matrix into a dm matrix. When you do MatAXPY() or MatAYPX() you should put the result into the product matrix, not the dm matrix and you can use SUBSET_NONZERO_PATTERN to make it reasonably efficient.

  Barry


> On Aug 12, 2021, at 10:31 AM, Matthew Knepley <knepley at gmail.com> wrote:
> 
> On Thu, Aug 12, 2021 at 10:44 AM Alfredo J Duarte Gomez <aduarteg at utexas.edu <mailto:aduarteg at utexas.edu>> wrote:
> Good morning,
> 
> I am currently having some trouble in the creation of some matrices.
> 
> I am using structured dmda objects to create matrices using the DMCreate() function.
> 
> One of these matrices will be the result of a matrix-matrix product of two of these dm matrices.
> 
> I know that the matrix product will have more nonzero entries or at least a bigger stencil than the original dm matrices, however I accounted for that when I set the DMDA stencil width in the initial creation.
> 
> By default, we put zeros into those locations, so you would expand that stencil when doing MatMatMult(). You can use
> 
>   -dm_preallocate_only
> 
> to prevent the zeros from being included. However, then your target matrix would not have those locations, so you would
> need to turn that off before creating the product matrix, or you could just make two DMDA with different stencils, since they
> are really small. This later solutions sounds cleaner to me.
> 
>   Thanks,
> 
>      Matt
>  
> The problem is that even with that, the resulting matrix-matrix product has a bigger stencil as evidenced by failure in subsequent matrix copy/addition operations using SAME_NONZERO_PATTERN.
> 
> Judging by the difference of the nonzero entries I believe that initial zero entries (the ones I initialized to eventually hold this expaned stencil) on the original dm matrices are being combined to further expand the stencil of the product matrix. 
> 
> Is there any way of getting a matrix-matrix product that will keep the same nonzero pattern as the dm matrices?
> 
> I have tried both MatMatMult() and the MatProductCreate() sequence so far, but both produce nonzero patterns that do not match the dm nonzero pattern.
> 
> Thank you,
> 
> -Alfredo
> 
> 
> 
> -- 
> Alfredo Duarte
> Graduate Research Assistant
> The University of Texas at Austin
> 
> 
> -- 
> 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
> 
> https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20210812/3c65c495/attachment-0001.html>


More information about the petsc-users mailing list