ufuncs, iterators

Simon Burton simon at arrowtheory.com
Thu Aug 18 19:28:26 CDT 2005


Along the lines of python's numarray [1], we need some way of
operating pointwise (and inner/outer operations) on Mat/Vec objects. 

In particular, we need things like the following:
(a) v=add.reduce(m)	(sum along rows/cols of a Mat to produce a Vec)
(b) m=add.outer(v1,v2)	(sum of all elements of two Vecs to produce a Mat)
(c) m=add(m1,m2)		(pointwise sum)
(d) m=exp(m)		(pointwise exp)

Right now we can do (a) and (b) using dgemm and single column/row matrices with just 1s,
and we can do (c) using SetValues. But for (d): it looks like we will be writing a c-loop ?

And I don't think the PETSc interface to dgemm (MatMatMult*) is general enough to do (b)
(we need one of the products to be added to the other product, so beta=1).

It would be easy enough to use numarray to "shadow" the PETSc arrays (using *GetArray)
and then make numarray do the work, but this seems doomed to failure because
numarray is inherently dense.


[1]: http://stsdas.stsci.edu/numarray/numarray-1.3.html/node35.html

Simon Burton, B.Sc.
Licensed PO Box 8066
ANU Canberra 2601
Ph. 61 02 6249 6940

More information about the petsc-dev mailing list