[petsc-users] Solving A*X = B where A and B are matrices

Jelena Slivka slivkaje at gmail.com
Sat Dec 1 12:05:06 CST 2012


Hello!
I am trying to solve A*X = B where A and B are matrices, and then find
trace of the resulting matrix X. My approach has been to partition matrix B
in column vectors bi and then solve each system A*xi = bi. Then, for all
vectors xi I would extract i-th element xi(i) and sum those elements in
order to get Trace(X).
Pseudo-code:
1) load matrices A and B
2) transpose matrix B (so that each right-hand side bi is in the row, as
operation MatGetColumnVector is slow)
3) set up KSPSolve
4) create vector diagonal (in which xi(i) elements will be stored)
5) for each row i of matrix B owned by current process:
          - create vector bi by extracting row i from matrix B
          - apply KSPsolve to get xi
          - insert value xi(i) in diagonal vector (only the process
which
            holds the ith value of vector x(i) should do so)
6) sum vector diagonal to get the trace.
However, my code (attached, along with the test case) runs fine on one
process, but hangs if started on multiple processes. Could you please help
me figure out what am I doing wrong?
Also, could you please tell me is it possible to use Cholesky factorization
when running on multiple processes (I see that I cannot use it when I set
the format of matrix A to MPIAIJ)?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20121201/39dfd09a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Experiment.c
Type: text/x-csrc
Size: 3789 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20121201/39dfd09a/attachment.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Abin
Type: application/octet-stream
Size: 136 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20121201/39dfd09a/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Bbin
Type: application/octet-stream
Size: 136 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20121201/39dfd09a/attachment-0001.obj>


More information about the petsc-users mailing list