[PYTHON MATRIX-SIG] Calling all extensions...

Tom Schwaller tom.schwaller@linux-magazin.de
Sat, 02 Nov 1996 03:04:20 +0100


Doug Heisterkamp wrote:

> I have a low-level access module to ODRPACK.  One thing to note is that I
> have it setup so I can use Python, C, or Fortran functions in ODRPACK. I'm
> in the process of generalizing this into a separate module so I can use it
> with other libraries.  I will put it up for ftp soon (probably sometime
> next week).  ODRPACK itself is available from netlib.
> 


Funny enough, we redo all the work done many times before (Matlab,
Octave, Scilab and
the last in this series

http://zaphod.uni-muenster.de:80/xi/


Your general approach seems interesting. We should work much more in
that direction.

Btw, has anybody written a general module to dynamicaly load numericl
procedures
after declaring their argument types. There is a module in the python
distribution,
but it's very rudimentary.

I do not remeber the exact form in Scilab, but in Python it should work
like:

C-Function: double func(int n, double* a, int r, double s)

f=dynload(func, 'd', 'i', 'D', 'i', 'd') (or f=funcload('diDid') , or
f=funcload('d', 'iDid'))
res = f(10, arange(10), 3, 5.3)

Some months ago I also saw a Tcl-extenion for compiling simple
C-Cyntax like expressions (just Tcl strings) to C-Functions on the fly..

It works like the example above, but instead of having the C-function at
the beginning,
you declare it with something like:

f=declarefunc('d', 'iDid', 'nars', "\
              int j=0;
              double res=0;
              for (j=0; j<n; j++) {
                res += a[j];
              }
              return res*r - s;
              }")

res = f(10, arange(10), 3, 5.3))


This is a dirty, not so Python-like solution, but is there a better one
for scientific computations. For heavy computations you need compiled
functions, which you can
generate on the fly, evaluating a interpreted function 10000 time for a
computation
is to slow. Any comments on that.

What about sparse matrices. I remeber we had a discussion on that a very
long time ago.
I propose taking the sparsepack library and melting it with NumPy.

Tom

=================
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================