[PYTHON MATRIX-SIG] which fft library should I do?

Konrad HINSEN hinsenk@ere.umontreal.ca
Tue, 5 Mar 1996 16:25:36 -0500


> I think that the library used should come in C at least, and in Fortran
> if possible, mostly due to the portability problem.  While "serious" fft
> users would probably do it on a fast machine w/ a fortran library, I
> think that I want to be able to do FFT on MacPython or PythonWin without
> a fortran compiler.

I agree. I remember having seen a list of mathematical libraries
in C somewhere, which is where you should start looking for
C libraries. I suppose it was in news.answers, but I am not sure.

> PS: How bad of a performance hit does one take w/ f2c-output code as
> opposed to handcoded C on code like this?

That depends a lot on your C compiler and on your application.  Many C
compilers are not very good at standard optimizations for numerical
code. The difficulties caused by the language itself are few: pointer
aliasing (a Fortran compiler may assume that two array arguments
passed to a subroutine do not refer to overlapping memory blocks; a C
compiler may not), the power operator (few C compilers can optimize
e.g. small integer powers) and intrinsic functions (although some C
compilers already come with a good substitute in the form of #pragmas
in math.h and corresponding optimizations).

Another question is whether the code produced by f2c is sufficiently
portable. After all, f2c has to be configured for some features of the
C compiler, and there are C compilers for which this is impossible.
For example, the C compiler must provide two floating-point precisions
of which the larger one uses exactly twice as many bytes as the
smaller one. I remember one compiler (Pure-C for the Atari ST) for
which I could not configure f2c, because "float" takes 4 bytes and
"double" 10.

Another problem is the f2c library. The generic source code is
very Unix-specific. I don't know whether there are any ports
to other operating systems.

All that means that a real C library is best. One can still
have an alternate Fortran library binding for people with
a Fortran compiler and a need for speed. As long as the
high-level interface is the same, few users should see the
difference.

-------------------------------------------------------------------------------
Konrad Hinsen                     | E-Mail: hinsenk@ere.umontreal.ca
Departement de chimie             | Tel.: +1-514-343-6111 ext. 3953
Universite de Montreal            | Fax:  +1-514-343-7586
C.P. 6128, succ. Centre-Ville     | Deutsch/Esperanto/English/Nederlands/
Montreal (QC) H3C 3J7             | Francais (phase experimentale)
-------------------------------------------------------------------------------

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

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