From 316efe6dfe3f29ad945fa5882a47514d2cd187b0 Mon Sep 17 00:00:00 2001
From: Rene Brun <Rene.Brun@cern.ch>
Date: Mon, 10 Apr 2006 15:30:16 +0000
Subject: [PATCH] From Anna Kreshuk:
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

A new optional package "fftw" is introduced.
It is a wrapper to the FFTW3 library. To use those functions,
FFTW3 should already be installed by the user, and ROOT should be configured
  --with-fftw3-incdir = "the directory where fftw3.h is"
  --with-fftw3-libdir = "the directory where the fftw library is"
eg
  --with-fftw3-incdir=$HOME/fftw-3.1.1/api \
  --with-fftw3-libdir=$HOME/fftw-3.1.1/.libs \

A new class TVirtualFFT provides an abstract interface for Fast Fourier
Transforms. The available transform types:
FFT:
====
- "C2CFORWARD" - a complex input/output discrete Fourier transform (DFT)
                 in one or more dimensions, -1 in the exponent
- "C2CBACKWARD"- a complex input/output discrete Fourier transform (DFT)
                 in one or more dimensions, +1 in the exponent
- "R2C"        - a real-input/complex-output discrete Fourier transform (DFT)
                 in one or more dimensions,
- "C2R"        - inverse transforms to "R2C", taking complex input
                 (storing the non-redundant half of a logically Hermitian array)
                 to real output
- "R2HC"       - a real-input DFT with output in ���alfcomplex���format,
                 i.e. real and imaginary parts for a transform of size n stored as
                 r0, r1, r2, ..., rn/2, i(n+1)/2-1, ..., i2, i1
- "HC2R"       - computes the reverse of FFTW_R2HC, above
- "DHT"        - computes a discrete Hartley transform

Sine/cosine transforms:
=======================
Different types of transforms are specified by parameter kind of the SineCosine() static
function. 4 different kinds of sine and cosine transforms are available
 DCT-I  (REDFT00 in FFTW3 notation)- kind=0
 DCT-II (REDFT10 in FFTW3 notation)- kind=1
 DCT-III(REDFT01 in FFTW3 notation)- kind=2
 DCT-IV (REDFT11 in FFTW3 notation)- kind=3
 DST-I  (RODFT00 in FFTW3 notation)- kind=4
 DST-II (RODFT10 in FFTW3 notation)- kind=5
 DST-III(RODFT01 in FFTW3 notation)- kind=6
 DST-IV (RODFT11 in FFTW3 notation)- kind=7
Formulas and detailed descriptions can be found in the chapter
"What FFTW really computes" of the FFTW manual

NOTE: FFTW computes unnormalized transforms, so doing a transform, followed by its
      inverse will give the original array, multiplied by normalization constant
      (transform size(N) for FFT, 2*(N-1) for DCT-I, 2*(N+1) for DST-I, 2*N for
      other sine/cosine transforms)

How to use it:
Call to the static function FFT returns a pointer to a fast fourier transform
with requested parameters. Call to the static function SineCosine returns a
pointer to a sine or cosine transform with requested parameters. Example:
{
   Int_t N = 10; Double_t *in = new Double_t[N];
   TVirtualFFT *fftr2c = TVirtualFFT::FFT(1, &N, "R2C");
   fftr2c->SetPoints(in);
   fftr2c->Transform();
   Double_t re, im;
   for (Int_t i=0; i<N; i++)
      fftr2c->GetPointComplex(i, re, im);
   ...
   fftr2c->SetPoints(in2);
   ...
   fftr2c->SetPoints(in3);
   ...
}


git-svn-id: http://root.cern.ch/svn/root/trunk@14621 27541ba8-7e3a-0410-8455-c3a389f83636
---
 Makefile            |  8 +++++++-
 base/inc/LinkDef1.h |  3 ++-
 config/Makefile.in  |  5 +++++
 config/rootrc.in    |  6 +++++-
 configure           | 44 ++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 63 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index d6ff2a26995..249ee750ae5 100644
--- a/Makefile
+++ b/Makefile
@@ -118,6 +118,9 @@ endif
 ifeq ($(BUILDFPYTHIA6),yes)
 MODULES      += pythia6
 endif
+ifeq ($(BUILDFFTW3), yes)
+MODULES      += fftw
+endif
 ifeq ($(BUILDFVENUS),yes)
 MODULES      += venus
 endif
@@ -200,7 +203,7 @@ MODULES      += unix winnt x11 x11ttf win32gdk gl rfio thread \
                 rootx rootd proofd proof dcache chirp hbook alien asimage \
                 ldap mlp krb5auth rpdutils globusauth pyroot ruby gfal \
                 qt qtroot xrootd netx proofx clarens peac oracle xmlparser \
-                mathcore mathmore reflex cintex roofit minuit2 monalisa
+                mathcore mathmore reflex cintex roofit minuit2 monalisa fftw
 MODULES      := $(sort $(MODULES))   # removes duplicates
 endif
 
@@ -952,6 +955,9 @@ showbuild:
 	@echo "RUBYLIBDIR         = $(RUBYLIBDIR)"
 	@echo "RUBYLIB            = $(RUBYLIB)"
 	@echo "RUBYINCDIR         = $(RUBYINCDIR)"
+	@echo "FFTW3LIBDIR        = $(FFTW3LIBDIR)"
+	@echo "FFTW3LIB           = $(FFTW3LIB)"
+	@echo "FFTW3INCDIR        = $(FFTW3INCDIR)"
 	@echo "SAPDBINCDIR        = $(SAPDBINCDIR)"
 	@echo "SRPLIBDIR          = $(SRPLIBDIR)"
 	@echo "SRPINCDIR          = $(SRPINCDIR)"
diff --git a/base/inc/LinkDef1.h b/base/inc/LinkDef1.h
index 1ee70214ba4..8dfa08d4577 100644
--- a/base/inc/LinkDef1.h
+++ b/base/inc/LinkDef1.h
@@ -1,4 +1,4 @@
-/* @(#)root/base:$Name:  $:$Id: LinkDef1.h,v 1.34 2006/03/08 21:09:42 brun Exp $ */
+/* @(#)root/base:$Name:  $:$Id: LinkDef1.h,v 1.35 2006/04/07 08:43:59 brun Exp $ */
 
 /*************************************************************************
  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
@@ -164,5 +164,6 @@
 
 #pragma link C++ class TVirtualPadEditor;
 
+#pragma link C++ class TVirtualFFT;
 
 #endif
diff --git a/config/Makefile.in b/config/Makefile.in
index 848dd81239e..2def8aa7902 100644
--- a/config/Makefile.in
+++ b/config/Makefile.in
@@ -137,6 +137,11 @@ FPYTHIA6LIBDIR   := @pythia6libdir@
 FPYTHIA6LIB      := @pythia6lib@
 FPYTHIA6CPPFLAGS := @pythia6cppflags@
 
+BUILDFFTW3      := @buildfftw3@
+FFTW3LIBDIR     := @fftw3libdir@
+FFTW3LIB        := @fftw3lib@
+FFTW3INCDIR     := $(filter-out /usr/include, @fftw3incdir@)
+
 BUILDFVENUS    := @buildvenus@
 FVENUSLIBDIR   := @venuslibdir@
 FVENUSLIB      := @venuslib@
diff --git a/config/rootrc.in b/config/rootrc.in
index 8114206273c..2b9a80af511 100644
--- a/config/rootrc.in
+++ b/config/rootrc.in
@@ -1,4 +1,4 @@
-# @(#)root/config:$Name:  $:$Id: rootrc.in,v 1.133 2006/04/06 23:01:45 rdm Exp $
+# @(#)root/config:$Name:  $:$Id: rootrc.in,v 1.134 2006/04/10 13:48:39 rdm Exp $
 # Author: Fons Rademakers  22/09/95
 
 # ROOT Environment settings are handled via the class TEnv. To see
@@ -503,6 +503,10 @@ WinNT.*.Plugin.TVirtualGLImp: * TGWin32GL    RGL          "TGWin32GL()"
 Unix.*.Plugin.TGLManager:   *   TX11GLManager    RGL "TX11GLManager()"
 WinNT.*.Plugin.TGLManager:  *   TGWin32GLManager RGL "TGWin32GLManager()"
 Plugin.TGLHistPainter:        * TGLHistPainter   RGL "TGLHistPainter(TH1*)"
+Plugin.TVirtualFFT:     fftwc2c TFFTComplex     FFTW   "TFFTComplex(Int_t, Int_t *,Bool_t)"
++Plugin.TVirtualFFT:    fftwc2r TFFTComplexReal FFTW   "TFFTComplexReal(Int_t,Int_t *, Bool_t)"
++Plugin.TVirtualFFT:    fftwr2c TFFTRealComplex FFTW   "TFFTRealComplex(Int_t,Int_t *, Bool_t)"
++Plugin.TVirtualFFT:    fftwr2r TFFTReal        FFTW   "TFFTReal(Int_t, Int_t *,Bool_t)"
 
 # Example of custom setting for the Rint application (root.exe).
 # This overrides the default specified above for a generic application.
diff --git a/configure b/configure
index 5a399538d34..62df3a5f835 100755
--- a/configure
+++ b/configure
@@ -38,6 +38,7 @@ options="                    \
    enable_dcache             \
    enable_exceptions         \
    enable_explicitlink       \
+   enable_fftw3              \
    enable_gfal               \
    enable_globus             \
    enable_krb5               \
@@ -86,6 +87,7 @@ enable_explicitlink=no
 enable_cintex=no
 enable_mathcore=no
 enable_mathmore=no
+enable_fftw3=no
 enable_pythia=no
 enable_qt=no
 enable_reflex=no
@@ -121,6 +123,7 @@ GFAL             \
 CERNLIB          \
 PYTHIA           \
 PYTHIA6          \
+FFTW3            \
 PYTHONDIR        \
 VENUS            \
 DCACHE           \
@@ -807,6 +810,7 @@ enable/disable options, prefix with either --enable- or --disable-
   dcache             dCache support, requires libdcap from DESY
   exceptions         Turn on compiler exception handling capability
   explicitlink       Explicitly link with all dependent libraries
+  fftw3              FFTW3 library of fast Fourier transforms support
   gfal               GFAL support, requires libgfal
   globus             Globus authentication support, requires Globus toolkit
   krb5               Kerberos5 support, requires Kerberos libs
@@ -855,6 +859,8 @@ with options, prefix with --with-, enables corresponding support
   dcap-incdir        dCache support, location of dcap.h
   dcap-libdir        dCache support, location of libdcap
   dicttype           dictionary type: "cint" (default), "reflex", or "gccxml"
+  fftw3-incdir       FFTW3 support, location of fftw3.h
+  fftw3-libdir       FFTW3 support, location of libfftw3 (libfftw3-3 for windows)
   gfal-incdir        GFAL support, location of gfal_api.h
   gfal-libdir        GFAL support, location of libgfal
   gccxml             Gccxml support, directory of the gccxml installation
@@ -1022,6 +1028,8 @@ if test $# -gt 0 ; then
       --with-dcap-incdir=*)    dcapincdir=$optarg    ; enable_dcache="yes"  ;;
       --with-dcap-libdir=*)    dcaplibdir=$optarg    ; enable_dcache="yes"  ;;
       --with-dicttype=*)       dicttype=$optarg      ;;
+      --with-fftw3-incdir=*)   fftw3incdir=$optarg   ; enable_fftw3="yes"   ;;
+      --with-fftw3-libdir=*)   fftw3libdir=$optarg   ; enable_fftw3="yes"   ;;
       --with-gfal-incdir=*)    gfalincdir=$optarg    ; enable_gfal="yes"    ;;
       --with-gfal-libdir=*)    gfallibdir=$optarg    ; enable_gfal="yes"    ;;
       --with-globus=*)         globusdir=$optarg     ; enable_globus="yes"  ;;
@@ -1747,6 +1755,38 @@ if test ! "x$enable_monalisa" = "xno"; then
     fi
 fi
 
+######################################################################
+#
+### echo %%% FFTW3 Support - Third party libraries
+#
+# (See http://www.fftw.org)
+#
+#
+#
+#
+
+if test ! "x$enable_fftw3" = "xno"; then
+    # Check for FFTW3 include and library
+    check_header "fftw3.h" "$fftw3incdir" $FFTW3 $FFTW3/include \
+    /usr/local/include /usr/include
+    fftw3inc=$found_hdr
+    fftw3incdir=$found_dir
+
+    if test "x$platform" = "xwin32"; then
+       check_library "libfftw3-3" "$enable_shared" "$fftw3libdir" \
+	    $FFTW3 $FFTW3/lib /usr/local/include /usr/include
+    else
+	check_library "libfftw3" "$enable_shared" "$fftw3libdir" \
+	    $FFTW3 $FFTW3/lib /usr/local/include /usr/include
+    fi
+    fftw3lib=$found_lib
+    fftw3libdir=$found_dir
+
+    if test "x$fftw3incdir" = "x" || test "x$fftw3lib" = "x"; then
+        enable_fftw3="no"
+    fi
+fi
+
 ######################################################################
 #
 ### echo %%% CERNLIB Usage - Third party libraries
@@ -3649,6 +3689,9 @@ sed -e "s|@globusincdir@|$globusincdir|"        \
     -e "s|@monalisaincdir@|$monalisaincdir|"    \
     -e "s|@monalisalib@|$monalisalib|"          \
     -e "s|@monalisalibdir@|$monalisalibdir|"    \
+    -e "s|@fftw3incdir@|$fftw3incdir|"           \
+    -e "s|@fftw3lib@|$fftw3lib|"                 \
+    -e "s|@fftw3libdir@|$fftw3libdir|"           \
     -e "s|@mysqlincdir@|$mysqlincdir|"          \
     -e "s|@mysqllib@|$mysqllib|"                \
     -e "s|@mysqllibdir@|$mysqllibdir|"          \
@@ -3735,6 +3778,7 @@ sed -e "s|@srcdir@|$srcdir|"                    \
     -e "s|@buildasimage@|$enable_asimage|"      \
     -e "s|@buildpythia@|$enable_pythia|"        \
     -e "s|@buildpythia6@|$enable_pythia6|"      \
+    -e "s|@buildfftw3@|$enable_fftw3|"          \
     -e "s|@buildvenus@|$enable_venus|"          \
     -e "s|@buildpython@|$enable_python|"        \
     -e "s|@buildruby@|$enable_ruby|"            \
-- 
GitLab