[petsc-users] petsc4py and numpy

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


Also, I'm excited by the new opportunities for parallel programming and
development offered by the IPython parallel programming extensions (
http://ipython.org/ipython-doc/dev/parallel/index.html), but have not had a
chance to try them out.  If you get a chance to use them for development,
please let us know if you find them to be useful.

A

On Tue, May 8, 2012 at 5:21 PM, Aron Ahmadia <aron.ahmadia at kaust.edu.sa>wrote:

> 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/3c9b71fc/attachment.htm>


More information about the petsc-users mailing list