[petsc-users] petsc4py and numpy

Aron Ahmadia aron.ahmadia at kaust.edu.sa
Tue May 8 09:21:45 CDT 2012


>
> b) In MATLAB, arrays are used everywhere, also for small collections,
> where one would use tuples or lists in Python (e.g. multiple return values
> from a function). When I encounter an array in the original MATLAB code, I
> have to decide whether a tuple, a list, a numpy.ndarray or a
> PETSc.Vec/PETSc.Mat is appropriate.


ndarray for numerical data, Python dicts and lists for more flexibility,
PETSc Vecs and Mats if you need the PETSc API.  Conversion between ndarray
and PETSc Vecs is practically free, so I would keep them as numpy arrays
for as long as possible (this is the strategy in pyclaw).


> One approach would be to use PETSc wherever the array can be larger than a
> typical tuple. Is there a performance penalty associated with using PETSc
> Vec/Mat for rather small arrays?
>

I agree with Matt, no performance penalty here.

A
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120508/9f5932f4/attachment.htm>


More information about the petsc-users mailing list