# HG changeset patch # User jwe # Date 988784109 0 # Node ID ba548facf43beed1a580a07b9b537aba44f1abd8 # Parent 2184d16975a2f7990e60c28f965f2262304df22b [project @ 2001-05-02 06:15:06 by jwe] diff -r 2184d16975a2 -r ba548facf43b ChangeLog --- a/ChangeLog Wed May 02 05:01:31 2001 +0000 +++ b/ChangeLog Wed May 02 06:15:09 2001 +0000 @@ -1,3 +1,10 @@ +2001-05-02 Mumit Khan + + * configure.in: Support for --with-fftw. + (FFT_DIR, FFTW_LIBS): New substitutions. + * Makeconf.in (FFTW_LIBS): New variable. + * acconfig.h (HAVE_FFTW): New macro. + 2001-04-26 John W. Eaton * aclocal.m4 (OCTAVE_ENABLE_READLINE): Require readline unless diff -r 2184d16975a2 -r ba548facf43b Makeconf.in --- a/Makeconf.in Wed May 02 05:01:31 2001 +0000 +++ b/Makeconf.in Wed May 02 06:15:09 2001 +0000 @@ -153,6 +153,7 @@ LIBCRUFT = @LIBCRUFT@ BLAS_LIBS = @BLAS_LIBS@ +FFTW_LIBS = @FFTW_LIBS@ LIBS = @LIBS@ # The arguments passed to configure. diff -r 2184d16975a2 -r ba548facf43b acconfig.h --- a/acconfig.h Wed May 02 05:01:31 2001 +0000 +++ b/acconfig.h Wed May 02 06:15:09 2001 +0000 @@ -58,6 +58,9 @@ /* Define if you have BSD style signals. */ #undef HAVE_BSD_SIGNALS +/* Define if you have FFTW installed. */ +#undef HAVE_FFTW + /* Define if you have POSIX style signals. */ #undef HAVE_POSIX_SIGNALS diff -r 2184d16975a2 -r ba548facf43b configure.in --- a/configure.in Wed May 02 05:01:31 2001 +0000 +++ b/configure.in Wed May 02 06:15:09 2001 +0000 @@ -21,7 +21,7 @@ ### Software Foundation, 59 Temple Place - Suite 330, Boston, MA ### 02111-1307, USA. -AC_REVISION($Revision: 1.346 $) +AC_REVISION($Revision: 1.347 $) AC_PREREQ(2.9) AC_INIT(src/octave.cc) AC_CONFIG_HEADER(config.h) @@ -351,6 +351,38 @@ AC_DEFINE(HAVE_HDF5)])])]) fi +# Checks for FFTW header and library. + +# subdirectories of libcruft to build if they aren't found on the system: +FFT_DIR="fftpack" +AC_SUBST(FFT_DIR) + +# Installed fftw library, if any. +FFTW_LIBS='' +AC_SUBST(FFTW_LIBS) + +AC_ARG_WITH(fftw, + [ --with-fftw use installed fftw instead of included fftpack], + with_fftw=yes, with_fftw=yes) + +if test "$with_fftw" = "yes"; then + AC_CHECK_HEADERS(dfftw.h fftw.h) + if test "$ac_cv_header_dfftw_h" = yes \ + || test "$ac_cv_header_fftw_h" = yes; then + AC_CHECK_LIB(dfftw, fftw_create_plan, FFTW_LIBS="-ldfftw", + [AC_CHECK_LIB(fftw, fftw_create_plan, FFTW_LIBS="-lfftw", with_fftw=no)]) + else + with_fftw=no + fi +fi + +if test "$with_fftw" = yes; then + FFT_DIR='' + AC_DEFINE(HAVE_FFTW) +fi + +# ---------------------------------------------------------------------- + ### We need these before trying to find libf2c. OCTAVE_PROG_AR @@ -1346,6 +1378,7 @@ Fortran compiler: $FORT Fortran libraries: $FLIBS BLAS libraries: $BLAS_LIBS + FFTW libraries: $FFTW_LIBS HDF5 libraries: $HDF5_LIBS LIBS: $LIBS Default pager: $DEFAULT_PAGER diff -r 2184d16975a2 -r ba548facf43b libcruft/ChangeLog --- a/libcruft/ChangeLog Wed May 02 05:01:31 2001 +0000 +++ b/libcruft/ChangeLog Wed May 02 06:15:09 2001 +0000 @@ -1,3 +1,7 @@ +2001-05-02 Mumit Khan + + * Makefile.in (CRUFT_DIRS): Substitute @FFT_DIR@. + 2001-04-25 John W. Eaton * Makefile.in (install): Don't use mk-libdir-link. diff -r 2184d16975a2 -r ba548facf43b libcruft/Makefile.in --- a/libcruft/Makefile.in Wed May 02 05:01:31 2001 +0000 +++ b/libcruft/Makefile.in Wed May 02 06:15:09 2001 +0000 @@ -28,7 +28,7 @@ # e.g. if they are already present on the system. For these, their # dirname is substituted by configure and may be the empty string. -CRUFT_DIRS = amos @BLAS_DIR@ blas-xtra dassl fftpack @LAPACK_DIR@ \ +CRUFT_DIRS = amos @BLAS_DIR@ blas-xtra dassl @FFT_DIR@ @LAPACK_DIR@ \ lapack-xtra linpack minpack misc odepack ordered-qz quadpack \ ranlib slatec-err slatec-fn villad diff -r 2184d16975a2 -r ba548facf43b liboctave/CMatrix.cc --- a/liboctave/CMatrix.cc Wed May 02 05:01:31 2001 +0000 +++ b/liboctave/CMatrix.cc Wed May 02 06:15:09 2001 +0000 @@ -55,6 +55,10 @@ #include "mx-inlines.cc" #include "oct-cmplx.h" +#ifdef HAVE_FFTW +#include "oct-fftw.h" +#endif + // Fortran functions we call. extern "C" @@ -954,6 +958,102 @@ return retval; } +#ifdef HAVE_FFTW + +ComplexMatrix +ComplexMatrix::fourier (void) const +{ + size_t nr = rows (); + size_t nc = cols (); + + ComplexMatrix retval (nr, nc); + + size_t npts, nsamples; + + if (nr == 1 || nc == 1) + { + npts = nr > nc ? nr : nc; + nsamples = 1; + } + else + { + npts = nr; + nsamples = nc; + } + + const Complex *in (data ()); + Complex *out (retval.fortran_vec ()); + + for (size_t i = 0; i < nsamples; i++) + { + octave_fftw::fft (&in[npts * i], &out[npts * i], npts); + } + + return retval; +} + +ComplexMatrix +ComplexMatrix::ifourier (void) const +{ + size_t nr = rows (); + size_t nc = cols (); + + ComplexMatrix retval (nr, nc); + + size_t npts, nsamples; + + if (nr == 1 || nc == 1) + { + npts = nr > nc ? nr : nc; + nsamples = 1; + } + else + { + npts = nr; + nsamples = nc; + } + + const Complex *in (data ()); + Complex *out (retval.fortran_vec ()); + + for (size_t i = 0; i < nsamples; i++) + { + octave_fftw::ifft (&in[npts * i], &out[npts * i], npts); + } + + return retval; +} + +ComplexMatrix +ComplexMatrix::fourier2d (void) const +{ + int nr = rows (); + int nc = cols (); + + ComplexMatrix retval (*this); + // Note the order of passing the rows and columns to account for + // column-major storage. + octave_fftw::fft2d (retval.fortran_vec (), nc, nr); + + return retval; +} + +ComplexMatrix +ComplexMatrix::ifourier2d (void) const +{ + int nr = rows (); + int nc = cols (); + + ComplexMatrix retval (*this); + // Note the order of passing the rows and columns to account for + // column-major storage. + octave_fftw::ifft2d (retval.fortran_vec (), nc, nr); + + return retval; +} + +#else + ComplexMatrix ComplexMatrix::fourier (void) const { @@ -1154,6 +1254,8 @@ return retval; } +#endif + ComplexDET ComplexMatrix::determinant (void) const { diff -r 2184d16975a2 -r ba548facf43b liboctave/ChangeLog --- a/liboctave/ChangeLog Wed May 02 05:01:31 2001 +0000 +++ b/liboctave/ChangeLog Wed May 02 06:15:09 2001 +0000 @@ -1,3 +1,12 @@ +2001-05-02 Mumit Khan + + * oct-fftw.h, oct-fftw.cc: New files. + * Makefile.in (INCLUDES, SOURCES): Add new files. + * CMatrix.cc (ComplexMatrix::{fourier, ifourier, fourier2d, + ifourier2d}): Use fftw if available. + * dMatrix.cc (Matrix::{fourier, ifourier, fourier2d, ifourier2d}): + Likewise. + 2001-04-25 John W. Eaton * Makefile.in (install-lib): Don't use mk-libdir-link. diff -r 2184d16975a2 -r ba548facf43b liboctave/Makefile.in --- a/liboctave/Makefile.in Wed May 02 05:01:31 2001 +0000 +++ b/liboctave/Makefile.in Wed May 02 06:15:09 2001 +0000 @@ -51,9 +51,9 @@ dir-ops.h file-ops.h file-stat.h getopt.h glob-match.h \ idx-vector.h lo-ieee.h lo-mappers.h lo-specfun.h lo-sysdep.h \ lo-utils.h mach-info.h oct-alloc.h oct-cmplx.h oct-env.h \ - oct-getopt.h oct-group.h oct-kpse.h oct-passwd.h oct-rl-edit.h \ - oct-rl-hist.h oct-shlib.h oct-syscalls.h oct-time.h pathlen.h \ - pathsearch.h prog-args.h statdefs.h str-vec.h sun-utils.h \ + oct-fftw.h oct-getopt.h oct-group.h oct-kpse.h oct-passwd.h \ + oct-rl-edit.h oct-rl-hist.h oct-shlib.h oct-syscalls.h oct-time.h \ + pathlen.h pathsearch.h prog-args.h statdefs.h str-vec.h sun-utils.h \ sysdir.h systime.h syswait.h \ $(MATRIX_INC) \ $(MX_OP_INC) \ @@ -90,10 +90,10 @@ file-stat.cc filemode.c getopt.c getopt1.c glob-match.cc \ idx-vector.cc lo-cutils.c lo-ieee.cc lo-mappers.cc lo-specfun.cc \ lo-sysdep.cc lo-utils.cc mach-info.cc mkdir.c oct-alloc.cc \ - oct-env.cc oct-getopt.c oct-group.cc oct-kpse.c oct-passwd.cc \ - oct-rl-edit.c oct-rl-hist.c oct-shlib.cc oct-syscalls.cc \ - oct-time.cc pathsearch.cc prog-args.cc rename.c rmdir.c \ - strftime.c strptime.c str-vec.cc tempname.c tempnam.c \ + oct-env.cc oct-fftw.cc oct-getopt.c oct-group.cc oct-kpse.c \ + oct-passwd.cc oct-rl-edit.c oct-rl-hist.c oct-shlib.cc \ + oct-syscalls.cc oct-time.cc pathsearch.cc prog-args.cc rename.c \ + rmdir.c strftime.c strptime.c str-vec.cc tempname.c tempnam.c \ $(TEMPLATE_SRC) \ $(TI_SRC) \ $(MATRIX_SRC) \ diff -r 2184d16975a2 -r ba548facf43b liboctave/dMatrix.cc --- a/liboctave/dMatrix.cc Wed May 02 05:01:31 2001 +0000 +++ b/liboctave/dMatrix.cc Wed May 02 06:15:09 2001 +0000 @@ -50,6 +50,10 @@ #include "mx-inlines.cc" #include "oct-cmplx.h" +#ifdef HAVE_FFTW +#include "oct-fftw.h" +#endif + // Fortran functions we call. extern "C" @@ -648,6 +652,104 @@ } } +#ifdef HAVE_FFTW + +ComplexMatrix +Matrix::fourier (void) const +{ + size_t nr = rows (); + size_t nc = cols (); + + ComplexMatrix retval (nr, nc); + + size_t npts, nsamples; + + if (nr == 1 || nc == 1) + { + npts = nr > nc ? nr : nc; + nsamples = 1; + } + else + { + npts = nr; + nsamples = nc; + } + + ComplexMatrix tmp (*this); + Complex *in (tmp.fortran_vec ()); + Complex *out (retval.fortran_vec ()); + + for (size_t i = 0; i < nsamples; i++) + { + octave_fftw::fft (&in[npts * i], &out[npts * i], npts); + } + + return retval; +} + +ComplexMatrix +Matrix::ifourier (void) const +{ + size_t nr = rows (); + size_t nc = cols (); + + ComplexMatrix retval (nr, nc); + + size_t npts, nsamples; + + if (nr == 1 || nc == 1) + { + npts = nr > nc ? nr : nc; + nsamples = 1; + } + else + { + npts = nr; + nsamples = nc; + } + + ComplexMatrix tmp (*this); + Complex *in (tmp.fortran_vec ()); + Complex *out (retval.fortran_vec ()); + + for (size_t i = 0; i < nsamples; i++) + { + octave_fftw::ifft (&in[npts * i], &out[npts * i], npts); + } + + return retval; +} + +ComplexMatrix +Matrix::fourier2d (void) const +{ + int nr = rows (); + int nc = cols (); + + ComplexMatrix retval (*this); + // Note the order of passing the rows and columns to account for + // column-major storage. + octave_fftw::fft2d (retval.fortran_vec (), nc, nr); + + return retval; +} + +ComplexMatrix +Matrix::ifourier2d (void) const +{ + int nr = rows (); + int nc = cols (); + + ComplexMatrix retval (*this); + // Note the order of passing the rows and columns to account for + // column-major storage. + octave_fftw::ifft2d (retval.fortran_vec (), nc, nr); + + return retval; +} + +#else + ComplexMatrix Matrix::fourier (void) const { @@ -848,6 +950,8 @@ return retval; } +#endif + DET Matrix::determinant (void) const { diff -r 2184d16975a2 -r ba548facf43b src/ChangeLog --- a/src/ChangeLog Wed May 02 05:01:31 2001 +0000 +++ b/src/ChangeLog Wed May 02 06:15:09 2001 +0000 @@ -1,3 +1,7 @@ +2001-05-02 Mumit Khan + + * Makefile.in (octave): Add $(FFTW_LIBS). + 2001-04-27 John W. Eaton * DLD-FUNCTIONS/sort.cc (mx_sort): Check for NaNs in comparisons. diff -r 2184d16975a2 -r ba548facf43b src/Makefile.in --- a/src/Makefile.in Wed May 02 05:01:31 2001 +0000 +++ b/src/Makefile.in Wed May 02 06:15:09 2001 +0000 @@ -259,7 +259,7 @@ octave.o builtins.o ops.o $(XERBLA) $(DLD_STATIC_OBJ) \ $(OCTAVE_LFLAGS) \ $(OCTAVE_LIBS) \ - $(LEXLIB) $(BLAS_LIBS) $(LIBS) $(FLIBS) + $(LEXLIB) $(BLAS_LIBS) $(FFTW_LIBS) $(LIBS) $(FLIBS) stmp-pic: pic @if [ -f stmp-pic ]; then \