[petsc-users] How can I convert parall matrix to MATSEQDENSE

Cong Li solvercorleone at gmail.com
Sun Aug 18 10:07:10 CDT 2013


Thanks for the answer.

Do you mean get each process's local data and save them in the C array
locally, then let the program call MPI_Gather to combine the arrrays on one
process?

Actuall I am trying to implement block cg method for my research.
It is like this AX=B, X and B are mxk matrices, A is mxm large sparse marix.

Given initial guess X0, R0=B-AX
P=R0
for i=1,2,...do
     gamma(i)=inv(Pi(transpose)APi)Pi(transpose)Ri
     X(i+1) = Xi +P(i) gamma(i)
.....
.....psi(i) = - inv(Pi(transpose)APi)PiA(transpose)R(i+1)
.....

Since the program store Pi(transpose)APi in MATMPIAJI (beacase I am using
MatPtAP call and A is MATMPIAIJ, I have to save the result in MATMPIAIJ for
the compatibabilty concern), I need to convert Pi(transpose)APi to
MATSEQDENSE to get its inverse.

By the way, I also think elemental is a good choice, but I don't how to
call its functions from PETSc, could you show me an example (data type
conversion from MATMPIAIJ to elemental type, and how can I call elemental
function in PETSc code) ?

Thanks so much

Cong


On Sun, Aug 18, 2013 at 10:12 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:

> Cong Li <solvercorleone at gmail.com> writes:
>
> > Hi, all
> >
> > Could someone tell me how I can convert a parallel MATDENSE (or
> MATMPIAIJ)
> > matrix to a MATSEQDENSE matrix?
>
> Get the array and use MPI_Gather.  With MATMPIAIJ, you almost certainly
> should not compute an explicit inverse.
>
> > I need this converted sequential matrix for direct solver to get its
> > inverse matrix.
>
> You can do that with Elemental without needing to serialize the matrix
> inversion.  Also, why do you need an explicit inverse?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20130819/f6a31c05/attachment.html>


More information about the petsc-users mailing list