[petsc-users] Shell matrix in petsc4py?

Jonathan Tu jonathantu at gmail.com
Wed Jul 30 18:29:18 CDT 2014


Hi,

I would like to solve a large linear system.  I have a linear operator that
operates on a "state" vector.  The linear operator does things like take
the sum of the state elements, take the cross product of the state with a
known vector, and then multiply the state by a large (distributed) matrix.
 You could imagine it like this:

[sum of elements, cross product with other vector, multiplication with
large matrix] = A * x

Now, I realize it is possible to implement all of this using a large
matrix.  After all, these are all linear operations.  However, I thought it
might be faster and less error-prone to use some of numpy's built-in
operations, for the sums and cross products, and only use a distributed
matrix for the last part of the output.

>From the PETSc documentation, it seems like a matrix shell would be perfect
for this.  I could define my own mult operator that does all of these
things in steps, using built-in numpy functions when appropriate and direct
matrix multiplication when appropriate.  However, I cannot figure out how
to do this in petsc4py.  I found somewhere online that perhaps createPython
is the way I need to go about this, but I couldn't figure out the details.

Any ideas?



Jonathan Tu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140730/00bea4a8/attachment-0001.html>


More information about the petsc-users mailing list