[petsc-users] I am wondering if there is a way to implement SPMM
Cong Li
solvercorleone at gmail.com
Tue Aug 4 20:53:43 CDT 2015
Thank you very much for your help and suggestions.
With your help, finally I could continue my project.
Regards
Cong Li
On Wed, Aug 5, 2015 at 3:09 AM, Barry Smith <bsmith at mcs.anl.gov> wrote:
>
> From the manual page: Unless scall is MAT_REUSE_MATRIX C will be
> created.
>
> Since you want to use the C that is passed in you should use
> MAT_REUSE_MATRIX.
>
> Note that since your B and C matrices are dense the issue of sparsity
> pattern of C is not relevant.
>
> Barry
>
> > On Aug 4, 2015, at 11:59 AM, Cong Li <solvercorleone at gmail.com> wrote:
> >
> > Thanks very much. This answer is very helpful.
> > And I have a following question.
> > If I create B1, B2, .. by the way you suggested and then use MatMatMult
> to do SPMM.
> > PetscErrorCode MatMatMult(Mat A,Mat B,MatReuse scall,PetscReal fill,Mat
> *C)
> > should I use MAT_REUSE_MATRIX for MatReuse part of the arguement.
> >
> > Thanks
> >
> > Cong Li
> >
> > On Wed, Aug 5, 2015 at 1:27 AM, Barry Smith <bsmith at mcs.anl.gov> wrote:
> >
> > > On Aug 4, 2015, at 4:09 AM, Cong Li <solvercorleone at gmail.com> wrote:
> > >
> > > I am sorry that I should have explained it more clearly.
> > > Actually I want to compute a recurrence.
> > >
> > > Like, I want to firstly compute A*X1=B1, and then calculate A*B1=B2,
> A*B2=B3 and so on.
> > > Finally I want to combine all these results into a bigger matrix
> C=[B1,B2 ...]
> >
> > First create C with MatCreateDense(,&C). Then call
> MatDenseGetArray(C,&array); then create B1 with
> MatCreateDense(....,array,&B1); then create
> > B2 with MatCreateDense(...,array+shift,&B2) etc where shift equals the
> number of __local__ rows in B1 times the number of columns in B1, then
> create B3 with a larger shift etc.
> >
> > Note that you are "sharing" the array space of C with B1, B2, B3,
> ..., each Bi contains its columns of the C matrix.
> >
> > Barry
> >
> >
> >
> > >
> > > Is there any way to do this efficiently.
> > >
> > >
> > >
> > > On Tue, Aug 4, 2015 at 5:45 PM, Patrick Sanan <patrick.sanan at gmail.com>
> wrote:
> > > On Tue, Aug 04, 2015 at 03:42:14PM +0900, Cong Li wrote:
> > > > Thanks for your reply.
> > > >
> > > > I have an other question.
> > > > I want to do SPMM several times and combine result matrices into one
> bigger
> > > > matrix.
> > > > for example
> > > > I firstly calculate AX1=B1, AX2=B2 ...
> > > > then I want to combine B1, B2.. to get a C, where C=[B1,B2...]
> > > >
> > > > Could you please suggest a way of how to do this.
> > > This is just linear algebra, nothing to do with PETSc specifically.
> > > A * [X1, X2, ... ] = [AX1, AX2, ...]
> > > >
> > > > Thanks
> > > >
> > > > Cong Li
> > > >
> > > > On Tue, Aug 4, 2015 at 3:27 PM, Jed Brown <jed at jedbrown.org> wrote:
> > > >
> > > > > Cong Li <solvercorleone at gmail.com> writes:
> > > > >
> > > > > > Hello,
> > > > > >
> > > > > > I am a PhD student using PETsc for my research.
> > > > > > I am wondering if there is a way to implement SPMM (Sparse
> matrix-matrix
> > > > > > multiplication) by using PETSc.
> > > > >
> > > > >
> > > > >
> http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatMatMult.html
> > > > >
> > >
> >
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150805/45600e59/attachment.html>
More information about the petsc-users
mailing list