[PYTHON MATRIX-SIG] Calling all extensions and Sparselib
Tom Schwaller
tom.schwaller@linux-magazin.de
Tue, 05 Nov 1996 00:59:55 +0100
>
> I assume you mean dlmodule. I have not look at that module before -- I'd
> assume it was Sun specific. Is it portable and is there documentation
> for it?
Hmm, the dl interface is implemented on all architectures I know.
When you have dynamic loading of modules running,
then the dlmodule should work too..
> >
> > 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)
> >
>
> I think something like this is possible. I would prefer separating the
> return type from the parameter types and making the return type optional
> with a default of returning None. I would also like an optional argument
> for the library which holds the function. The default libraries list
> could be kept in the dynamic load module.
Good point.
>
> Generating compiled functions on the fly can be done right now if you
> have a set interface. Doing it portably could be difficult. But it
> can be done by (1) writing the text to a file, (2) executing a makefile
> that (a) compiles the text file, (b) places it into a library, (c) relinks
> the dynamically loaded module that holds the interface function with
> the library, (d) copy the module to python's sharedmodule directory,
> (3) reload the module.
Thats exactly the approcha of the mentioned Tcl module, whichhhhh works
quite well..
>
> As to interpreted functions being to slow for heavy computations, I think
> it will depend on the problem. But in general, I think it will be true.
> I'm hopeful that if the function is using the array operations then
> it will run in a reasonable amount of time. Even if it does not, there
> is always late friday afternoons. Where letting the machine run over the
> weekend is much better than staying into the evening and writing the
> C functions.
>
I had some tests 2 years ago with PDE stuff where I used
Python to plug in functions (written very fast with Python)
and the results where absolutely disapointing.
Also Tests with nonlinear optimisation stuff were very bad..
> > 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.
>
> Which sparse matrix library do you use? I don't need to use sparse
> matrices at the moment, but I would be willing to help someone else
> in setting up the interface with NumPy.
Im not exactly shure which one I one discoverd on the net, but I think
it's
http://math.nist.gov/spblas/
There are also C++ Wrapper code at
http://math.nist.gov/sparselib++
Very important for our purpose is
http://math.nist.gov/acmd/Staff/KRemington/spblasc/spblasc.html
http://www.cs.umn.edu/research/darpa/p_sparslib/psp-abs.html
is also very interesting.
I propose to use the first code (Sparselib) and here"s another link
http://math.nist.gov/iml++
which one should consider for preconditioning stuff..
Hope this is interesting stuff, if you do not know it.
Tom
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================