Extending using Numeric, a quest for patterns

Greg Landrum gReGlAnDrUm at earthlink.net
Fri Mar 16 17:42:23 EST 2001


Hi all,

I'm in the process of converting some of the time-critical sections of my
code to C extension modules.  I use Numeric heavily, so I'm working with a
lot of Numeric arrays.  I've figured out how to do most everything I need to
do, but I'm hung up a bit on one particular piece.  So I'm looking for some
pointers towards either more documentation or suggestions for patterns to
use.

The core of the Python for the bit I'm interested in converting is:
          posArray = array(pos1+pos2)
          avgVect = sum(posArray)/len(posArray)
          devs = posArray-avgVect
          devs *= devs
          e = sum(sum(devs))
where pos1 and pos2 are python lists.

What I think would make a lot of this easier is if I could figure out how to
use the ufuncs from C code.  I pored over the source and the docs, but I was
pretty much totally unsuccessful in this undertaking.

Is there a straightforward way of doing this?

Thanks,
-greg





More information about the Python-list mailing list