casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
FFTPack.h
Go to the documentation of this file.
00001 //# FFTPack.h: C++ wrapper functions for Fortran FFTPACK code
00002 //# Copyright (C) 1993,1994,1995,1997,1999,2000,2001
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 
00027 //# $Id: FFTPack.h 20299 2008-04-03 05:56:44Z gervandiepen $
00028 
00029 #ifndef SCIMATH_FFTPACK_H
00030 #define SCIMATH_FFTPACK_H
00031 
00032 #include <casa/aips.h>
00033 
00034   //# The SGI compiler with -LANG:std has some trouble including both Complexfwd.h
00035   //# and Complex.h so we bypass the problem by include Complex.h only.
00036 #if defined(AIPS_USE_NEW_SGI)
00037 #include <casa/BasicSL/Complex.h>
00038 #else
00039 #include <casa/BasicSL/Complexfwd.h>
00040 #endif
00041 
00042 namespace casa { //# NAMESPACE CASA - BEGIN
00043 
00044 // <summary>C++ interface to the Fortran FFTPACK library</summary>
00045 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
00046 // </reviewed>
00047 // <synopsis>
00048 // The static functions in this class are C++ wrappers to the Fortran FFTPACK
00049 // library. This library contains functions that perform fast Fourier
00050 // transforms (FFT's) and related transforms. 
00051 
00052 // An additional purpose of these definitions is to overload the functions so
00053 // that C++ users can access the functions in either fftpak (single precision)
00054 // or dfftpack (double precision) with identical function names.
00055 
00056 // These routines only do one-dimensional transforms with the first element of
00057 // the array being the "origin" of the transform. The <linkto
00058 // class="FFTServer">FFTServer</linkto> class uses some of these functions to
00059 // implement multi-dimensional transforms with the origin of the transform
00060 // either at the centre or the first element of the Array.
00061 
00062 // You must initialise the work array <src>wsave</src> before using the forward
00063 // transform (function with a suffix of f) or the backward transform (with a
00064 // suffix of b).
00065 
00066 // The transforms done by the functions in this class can be categorised as
00067 // follows:
00068 // <ul>
00069 // <li> Complex to Complex Transforms<br> 
00070 //      Done by the cttfi, cfftf & cfftb functions
00071 // <li> Real to Complex Transforms<br>
00072 //      Done by the rffti, rfftf & rfftb functions. A simpler interface is
00073 //      provided by the ezffti, ezfftf & ezfftb functions. The 'ez' functions
00074 //      do not destroy the input array and provide the result in a slightly
00075 //      less packed format. They are available in single precision only and
00076 //      internally use the rfft functions.
00077 // <li> Sine Transforms<br>
00078 //      Done by the sinti & sint functions. As the sine transform is its own
00079 //      inverse there is no need for any distinction between forward and
00080 //      backward transforms.
00081 // <li> Cosine Transforms<br>
00082 //      Done by the costi & cost functions. As the cosine transform is its own
00083 //      inverse there is no need for any distinction between forward and
00084 //      backward transforms.
00085 // <li> Sine quarter wave Transforms<br>
00086 //      Done by the sinqi, sinqf & sinqb functions.
00087 // <li> Cosine quarter wave Transforms<br>
00088 //      Done by the cosqi, cosqf & cosqb functions.
00089 // </ul>
00090 
00091 
00092 // <note role=warning> 
00093 // These functions assume that it is possible to convert between AIPS++ numeric
00094 // types and those used by Fortran. That it is possible to convert between
00095 // Float & float, Double & double and Int & int.
00096 // </note>
00097 
00098 // <note role=warning> 
00099 // These function also assume that a Complex array is stored as pairs of
00100 // floating point numbers, with no intervening gaps, and with the real
00101 // component first ie., <src>[re0,im0,re1,im1, ...]</src> so that the following
00102 // type casts work,
00103 // <srcblock>
00104 // Complex* complexPtr;
00105 // Float* floatPtr = (Float* ) complexPtr;
00106 // </srcblock>
00107 // and allow a Complex number to be accessed as a pair of real numbers. If this
00108 // assumption is bad then float Arrays will have to generated by copying the
00109 // complex ones. When compiled in debug mode mode the functions that require
00110 // this assumption will throw an exception (AipsError) if this assumption is
00111 // bad. Ultimately this assumption about Complex<->Float Array conversion
00112 // should be put somewhere central like Array2Math.cc.
00113 // </note>
00114 
00115 // </synopsis>
00116 
00117 
00118 class FFTPack
00119 {
00120 public:
00121 // cffti initializes the array wsave which is used in both <src>cfftf</src> and
00122 // <src>cfftb</src>. The prime factorization of n together with a tabulation of
00123 // the trigonometric functions are computed and stored in wsave.
00124 // 
00125 // Input parameter:
00126 // <dl compact>
00127 // <dt><b>n</b>
00128 // <dd>    The length of the sequence to be transformed
00129 // </dl>
00130 // Output parameter:
00131 // <dl compact>
00132 // <dt><b>wsave</b>
00133 // <dd>    A work array which must be dimensioned at least 4*n+15
00134 //         The same work array can be used for both cfftf and cfftb
00135 //         as long as n remains unchanged. Different wsave arrays
00136 //         are required for different values of n. The contents of
00137 //         wsave must not be changed between calls of cfftf or cfftb.
00138 // </dl>
00139 // <group>
00140 static void cffti(Int n, Float* wsave);
00141 static void cffti(Int n, Double* wsave);
00142 // </group>
00143 
00144 // cfftf computes the forward complex discrete Fourier
00145 // transform (the Fourier analysis). Equivalently, cfftf computes
00146 // the Fourier coefficients of a complex periodic sequence.
00147 // the transform is defined below at output parameter c.
00148 // 
00149 // The transform is not normalized. To obtain a normalized transform
00150 // the output must be divided by n. Otherwise a call of cfftf
00151 // followed by a call of cfftb will multiply the sequence by n.
00152 // 
00153 // The array wsave which is used by <src>cfftf</src> must be
00154 // initialized by calling <src>cffti(n,wsave)</src>.
00155 // 
00156 // Input parameters:
00157 // <dl compact>
00158 // <dt><b>n</b>
00159 // <dd>   The length of the complex sequence c. The method is
00160 //        more efficient when n is the product of small primes.
00161 // <dt><b>c</b>
00162 // <dd>    A complex array of length n which contains the sequence to be
00163 //         transformed.
00164 // <dt><b>wsave</b>
00165 // <dd>    A real work array which must be dimensioned at least 4n+15
00166 //         by the program that calls cfftf. The wsave array must be
00167 //         initialized by calling <src>cffti(n,wsave)</src> and a
00168 //         different wsave array must be used for each different
00169 //         value of n. This initialization does not have to be
00170 //         repeated so long as n remains unchanged thus subsequent
00171 //         transforms can be obtained faster than the first.
00172 //         The same wsave array can be used by cfftf and cfftb.
00173 // </dl>
00174 // Output parameters:
00175 // <dl compact>
00176 // <dt><b>c</b>
00177 // <dd>   for j=1,...,n<br>
00178 //            c(j)=the sum from k=1,...,n of<br>
00179 //                  c(k)*exp(-i*(j-1)*(k-1)*2*pi/n)<br>
00180 //                        where i=sqrt(-1)<br>
00181 // <dt><b>wsave</b>
00182 // <dd>    Contains initialization calculations which must not be
00183 //         destroyed between calls of cfftf or cfftb
00184 // </dl>
00185 // <group>
00186 static void cfftf(Int n, Complex* c, Float* wsave);
00187 static void cfftf(Int n, DComplex* c, Double* wsave);
00188 // </group>
00189 
00190 // cfftb computes the backward complex discrete Fourier
00191 // transform (the Fourier synthesis). Equivalently, cfftb computes
00192 // a complex periodic sequence from its Fourier coefficients.
00193 // The transform is defined below with output parameter c.
00194 // 
00195 // A call of cfftf followed by a call of cfftb will multiply the
00196 // sequence by n.
00197 // 
00198 // The array wsave which is used by <src>cfftb</src> must be
00199 // initialized by calling <src>cffti(n,wsave)</src>.
00200 // 
00201 // Input parameters:
00202 // <dl compact>
00203 // <dt><b>n</b>
00204 // <dd>          The length of the complex sequence c. The method is
00205 //               more efficient when n is the product of small primes.
00206 // <dt><b>c</b>
00207 // <dd>          A complex array of length n which contains the sequence to be
00208 //               transformed.
00209 // <dt><b>wsave</b> 
00210 // <dd>          A real work array which must be dimensioned at least 4n+15
00211 //               in the program that calls cfftb. The wsave array must be
00212 //               initialized by calling <src>cffti(n,wsave)</src>
00213 //               and a different wsave array must be used for each different
00214 //               value of n. This initialization does not have to be
00215 //               repeated so long as n remains unchanged thus subsequent
00216 //               transforms can be obtained faster than the first.
00217 //               The same wsave array can be used by cfftf and cfftb.
00218 // </dl>
00219 // Output parameters:
00220 // <dl compact>
00221 // <dt><b>c</b>     
00222 // <dd>          for j=1,...,n<br>
00223 //                 c(j)=the sum from k=1,...,n of<br>
00224 //                     c(k)*exp(i*(j-1)*(k-1)*2*pi/n)<br>
00225 
00226 // <dt><b>wsave</b>
00227 // <dd>          Contains initialization calculations which must not be
00228 //               destroyed between calls of cfftf or cfftb
00229 // </dl>
00230 // <group>
00231 static void cfftb(Int n, Complex* c, Float* wsave);
00232 static void cfftb(Int n, DComplex* c, Double* wsave);
00233 // </group>
00234 
00235 // rffti initializes the array wsave which is used in both <src>rfftf</src> and
00236 // <src>rfftb</src>. The prime factorization of n together with a tabulation of
00237 // the trigonometric functions are computed and stored in wsave.
00238 //
00239 // Input parameter:
00240 // <dl compact>
00241 // <dt><b>n</b>
00242 // <dd>       The length of the sequence to be transformed.
00243 // </dl>
00244 // Output parameter:
00245 // <dl compact>
00246 // <dt><b>wsave</b>
00247 // <dd>    A work array which must be dimensioned at least 2*n+15.
00248 //         The same work array can be used for both rfftf and rfftb
00249 //         as long as n remains unchanged. Different wsave arrays
00250 //         are required for different values of n. The contents of
00251 //         wsave must not be changed between calls of rfftf or rfftb.
00252 // </dl>
00253 // <group>
00254 static void rffti(Int n, Float* wsave);
00255 static void rffti(Int n, Double* wsave);
00256 // </group>
00257 
00258 // rfftf computes the Fourier coefficients of a real perodic sequence (Fourier
00259 // analysis). The transform is defined below at output parameter r.
00260 // 
00261 // Input parameters:
00262 // <dl compact>
00263 // <dt><b>n</b>
00264 // <dd>    The length of the array r to be transformed.  The method
00265 //         is most efficient when n is a product of small primes.
00266 //         n may change so long as different work arrays are provided
00267 // <dt><b>r</b>
00268 // <dd>    A real array of length n which contains the sequence
00269 //         to be transformed
00270 // <dt><b>wsave</b>
00271 // <dd>    A work array which must be dimensioned at least 2*n+15
00272 //         in the program that calls rfftf. The wsave array must be
00273 //         initialized by calling <src>rffti(n,wsave)</src> and a
00274 //         different wsave array must be used for each different
00275 //         value of n. This initialization does not have to be
00276 //         repeated so long as n remains unchanged thus subsequent
00277 //         transforms can be obtained faster than the first.
00278 //         The same wsave array can be used by rfftf and rfftb.
00279 // </dl>
00280 // output parameters
00281 // <dl compact>
00282 // <dt><b>r</b>
00283 // <dd>    r(1) = the sum from i=1 to i=n of r(i)<br>
00284 //         if n is even set l = n/2   , if n is odd set l = (n+1)/2<br>
00285 //         then for k = 2,...,l<br>
00286 //              r(2*k-2) = the sum from i = 1 to i = n of<br>
00287 //                         r(i)*cos((k-1)*(i-1)*2*pi/n)<br>
00288 //              r(2*k-1) = the sum from i = 1 to i = n of<br>
00289 //                         -r(i)*sin((k-1)*(i-1)*2*pi/n)<br>
00290 //         if n is even<br>
00291 //              r(n) = the sum from i = 1 to i = n of<br>
00292 //                   (-1)**(i-1)*r(i)<br>
00293 // 
00294 //         note:
00295 //              this transform is unnormalized since a call of rfftf
00296 //              followed by a call of rfftb will multiply the input
00297 //              sequence by n.
00298 // <dt><b>wsave</b>
00299 // <dd>    Contains results which must not be destroyed between
00300 //         calls of rfftf or rfftb.
00301 // </dl>
00302 // <group>
00303 static void rfftf(Int n, Float* r, Float* wsave);
00304 static void rfftf(Int n, Double* r, Double* wsave);
00305 // </group>
00306 
00307 
00308 // rfftb computes the real perodic sequence from its Fourier coefficients
00309 // (Fourier synthesis). The transform is defined below at output parameter r.
00310 // 
00311 // Input parameters:
00312 // <dl compact>
00313 // <dt><b>n</b>
00314 // <dd>    The length of the array r to be transformed.  The method
00315 //         is most efficient when n is a product of small primes.
00316 //         n may change so long as different work arrays are provided
00317 // <dt><b>r</b>
00318 // <dd>    A real array of length n which contains the sequence
00319 //         to be transformed
00320 // <dt><b>wsave</b>
00321 // <dd>    A work array which must be dimensioned at least 2*n+15
00322 //         in the program that calls rfftb. The wsave array must be
00323 //         initialized by calling <src>rffti(n,wsave)</src> and a
00324 //         different wsave array must be used for each different
00325 //         value of n. This initialization does not have to be
00326 //         repeated so long as n remains unchanged thus subsequent
00327 //         transforms can be obtained faster than the first.
00328 //         The same wsave array can be used by rfftf and rfftb.
00329 // </dl>
00330 // Output parameters:
00331 // <dl compact>
00332 // <dt><b>r</b>
00333 // <dd>    for n even and for i = 1,...,n<br>
00334 //              r(i) = r(1)+(-1)**(i-1)*r(n)<br>
00335 //                   plus the sum from k=2 to k=n/2 of<br>
00336 //                    2.*r(2*k-2)*cos((k-1)*(i-1)*2*pi/n)<br>
00337 //                   -2.*r(2*k-1)*sin((k-1)*(i-1)*2*pi/n)<br>
00338 //         for n odd and for i = 1,...,n<br>
00339 //              r(i) = r(1) plus the sum from k=2 to k=(n+1)/2 of<br>
00340 //                   2.*r(2*k-2)*cos((k-1)*(i-1)*2*pi/n)<br>
00341 //                  -2.*r(2*k-1)*sin((k-1)*(i-1)*2*pi/n)<br>
00342 // 
00343 //         note:
00344 //              this transform is unnormalized since a call of rfftf
00345 //              followed by a call of rfftb will multiply the input
00346 //              sequence by n.
00347 // <dt><b>wsave</b>
00348 // <dd>    Contains results which must not be destroyed between
00349 //         calls of rfftb or rfftf.
00350 // </dl>
00351 // <group>
00352 static void rfftb(Int n, Float* r, Float* wsave);
00353 static void rfftb(Int n, Double* r, Double* wsave);
00354 // </group>
00355 
00356 // ezffti initializes the array wsave which is used in both <src>ezfftf</src>
00357 // and <src>ezfftb</src>. The prime factorization of n together with a
00358 // tabulation of the trigonometric functions are computed and stored in wsave.
00359 // 
00360 // Input parameter:
00361 // <dl compact>
00362 // <dt><b>n</b>
00363 // <dd>    The length of the sequence to be transformed.
00364 // </dl>
00365 // Output parameter:
00366 // <dl compact>
00367 // <dt><b>wsave</b>
00368 // <dd>    A work array which must be dimensioned at least 3*n+15.
00369 //         The same work array can be used for both ezfftf and ezfftb
00370 //         as long as n remains unchanged. Different wsave arrays
00371 //         are required for different values of n.
00372 // </dl>
00373 static void ezffti(Int n, Float* wsave);
00374 
00375 // ezfftf computes the Fourier coefficients of a real
00376 // perodic sequence (Fourier analysis). The transform is defined
00377 // below at output parameters azero, a and b. ezfftf is a simplified
00378 // but slower version of rfftf.
00379 // 
00380 // Input parameters:
00381 // <dl compact>
00382 // <dt><b>n</b>
00383 // <dd>    The length of the array r to be transformed.  The method
00384 //         is most efficient when n is the product of small primes.
00385 // <dt><b>r</b>
00386 // <dd>    A real array of length n which contains the sequence
00387 //         to be transformed. r is not destroyed.
00388 // <dt><b>wsave</b>
00389 // <dd>    A work array which must be dimensioned at least 3*n+15
00390 //         in the program that calls ezfftf. The wsave array must be
00391 //         initialized by calling <src>ezffti(n,wsave)</src> and a
00392 //         different wsave array must be used for each different
00393 //         value of n. This initialization does not have to be
00394 //         repeated so long as n remains unchanged thus subsequent
00395 //         transforms can be obtained faster than the first.
00396 //         The same wsave array can be used by ezfftf and ezfftb.
00397 // </dl>
00398 // Output parameters:
00399 // <dl compact>
00400 // <dt><b>azero</b>
00401 // <dd>    The sum from i=1 to i=n of r(i)/n
00402 // <dt><b>a,b</b>
00403 // <dd>    Real arrays of length n/2 (n even) or (n-1)/2 (n odd)<br>
00404 //         for n even<br>
00405 //            b(n/2)=0, and <br>
00406 //            a(n/2) is the sum from i=1 to i=n of (-1)**(i-1)*r(i)/n<br>
00407 // 
00408 //         for n even define kmax=n/2-1<br>
00409 //         for n odd  define kmax=(n-1)/2<br>
00410 //         then for  k=1,...,kmax<br>
00411 //            a(k) equals the sum from i=1 to i=n of<br>
00412 //                   2./n*r(i)*cos(k*(i-1)*2*pi/n)<br>
00413 //            b(k) equals the sum from i=1 to i=n of<br>
00414 //                   2./n*r(i)*sin(k*(i-1)*2*pi/n)<br>
00415 // </dl>
00416 static void ezfftf(Int n, Float* r, Float* azero, Float* a, Float* b, 
00417             Float* wsave);
00418 
00419 // ezfftb computes a real perodic sequence from its
00420 // Fourier coefficients (Fourier synthesis). The transform is
00421 // defined below at output parameter r. ezfftb is a simplified
00422 // but slower version of rfftb.
00423 // 
00424 // Input parameters:
00425 // <dl compact>
00426 // <dt><b>n</b>       
00427 // <dd>    The length of the output array r.  The method is most
00428 //         efficient when n is the product of small primes.
00429 // <dt><b>azero</b>
00430 // <dd>    The constant Fourier coefficient
00431 // <dt><b>a,b</b>
00432 // <dd>    Arrays which contain the remaining Fourier coefficients
00433 //         these arrays are not destroyed.
00434 //         The length of these arrays depends on whether n is even or
00435 //         odd.
00436 //         If n is even n/2    locations are required,
00437 //         if n is odd (n-1)/2 locations are required.
00438 // <dt><b>wsave</b>
00439 // <dd>    A work array which must be dimensioned at least 3*n+15.
00440 //         in the program that calls ezfftb. The wsave array must be
00441 //         initialized by calling <src>ezffti(n,wsave)</src> and a
00442 //         different wsave array must be used for each different
00443 //         value of n. This initialization does not have to be
00444 //         repeated so long as n remains unchanged thus subsequent
00445 //         transforms can be obtained faster than the first.
00446 //         The same wsave array can be used by ezfftf and ezfftb.
00447 // </dl>
00448 // Output parameters:
00449 // <dl compact>
00450 // <dt><b>r</b>
00451 // <dd>    if n is even define kmax=n/2<br>
00452 //         if n is odd  define kmax=(n-1)/2<br>
00453 //         then for i=1,...,n<br>
00454 //              r(i)=azero plus the sum from k=1 to k=kmax of<br>
00455 //              a(k)*cos(k*(i-1)*2*pi/n)+b(k)*sin(k*(i-1)*2*pi/n)<br>
00456 //         where<br>
00457 //              c(k) = .5*cmplx(a(k),-b(k))   for k=1,...,kmax<br>
00458 //              c(-k) = conjg(c(k))<br>
00459 //              c(0) = azero<br>
00460 //                   and i=sqrt(-1)<br>
00461 // </dl>
00462 static void ezfftb(Int n, Float* r, Float* azero, Float* a, Float* b, 
00463             Float* wsave);
00464 
00465 // sinti initializes the array wsave which is used in
00466 // <src>sint</src>. The prime factorization of n together with a tabulation of
00467 // the trigonometric functions are computed and stored in wsave.
00468 // 
00469 // Input parameter:
00470 // <dl compact>
00471 // <dt><b>n</b>
00472 // <dd>    The length of the sequence to be transformed.  the method
00473 //         is most efficient when n+1 is a product of small primes.
00474 // </dl>
00475 // Output parameter:
00476 // <dl compact>
00477 // <dt><b>wsave</b>
00478 // <dd>    A work array with at least int(2.5*n+15) locations.
00479 //         Different wsave arrays are required for different values
00480 //         of n. The contents of wsave must not be changed between
00481 //         calls of sint.
00482 // </dl>
00483 // <group>
00484 static void sinti(Int n, Float* wsave);
00485 static void sinti(Int n, Double* wsave);
00486 // </group>
00487 
00488 // sint computes the discrete Fourier sine transform
00489 // of an odd sequence x(i). The transform is defined below at
00490 // output parameter x.
00491 // sint is the unnormalized inverse of itself since a call of sint
00492 // followed by another call of sint will multiply the input sequence
00493 // x by 2*(n+1).
00494 // The array wsave which is used by sint must be
00495 // initialized by calling <src>sinti(n,wsave)</src>.
00496 // 
00497 // Input parameters:
00498 // <dl compact>
00499 // <dt><b>n</b>
00500 // <dd>    The length of the sequence to be transformed.  The method
00501 //         is most efficient when n+1 is the product of small primes.
00502 // <dt><b>x</b>
00503 // <dd>    An array which contains the sequence to be transformed
00504 // <dt><b>wsave</b>
00505 // <dd>    A work array with dimension at least int(2.5*n+15)
00506 //         in the program that calls sint. The wsave array must be
00507 //         initialized by calling <src>sinti(n,wsave)</src> and a
00508 //         different wsave array must be used for each different
00509 //         value of n. This initialization does not have to be
00510 //         repeated so long as n remains unchanged thus subsequent
00511 //         transforms can be obtained faster than the first.
00512 // </dl>
00513 // Output parameters:
00514 // <dl compact>
00515 // <dt><b>x</b>
00516 // <dd>    for i=1,...,n<br>
00517 //              x(i) = the sum from k=1 to k=n<br>
00518 //                   2*x(k)*sin(k*i*pi/(n+1))<br>
00519 // 
00520 //              a call of sint followed by another call of
00521 //              sint will multiply the sequence x by 2*(n+1).
00522 //              Hence sint is the unnormalized inverse
00523 //              of itself.
00524 // 
00525 // <dt><b>wsave</b>
00526 // <dd>    Contains initialization calculations which must not be
00527 //         destroyed between calls of sint.
00528 // </dl>
00529 // <group>
00530 static void sint(Int n, Float* x, Float* wsave);
00531 static void sint(Int n, Double* x, Double* wsave);
00532 // </group>
00533 
00534 // costi initializes the array wsave which is used in
00535 // <src>cost</src>. The prime factorization of n together with a tabulation of
00536 // the trigonometric functions are computed and stored in wsave.
00537 // 
00538 // Input parameter:
00539 // <dl compact>
00540 // <dt><b>n</b>
00541 // <dd>    The length of the sequence to be transformed.  The method
00542 //         is most efficient when n-1 is a product of small primes.
00543 // </dl>
00544 // Output parameter:
00545 // <dl compact>
00546 // <dt><b>wsave</b>
00547 // <dd>    A work array which must be dimensioned at least 3*n+15.
00548 //         Different wsave arrays are required for different values
00549 //         of n. The contents of wsave must not be changed between
00550 //         calls of cost.
00551 // </dl>
00552 // <group>
00553 static void costi(Int n, Float* wsave);
00554 static void costi(Int n, Double* wsave);
00555 // </group>
00556 
00557 // cost computes the discrete Fourier cosine transform
00558 // of an even sequence x(i). The transform is defined below at output
00559 // parameter x.
00560 // cost is the unnormalized inverse of itself since a call of cost
00561 // followed by another call of cost will multiply the input sequence
00562 // x by 2*(n-1). The transform is defined below at output parameter x.
00563 // The array wsave which is used by <src>cost</src> must be
00564 // initialized by calling <src>costi(n,wsave)</src>.
00565 // 
00566 // Input parameters:
00567 // <dl compact>
00568 // <dt><b>n</b>
00569 // <dd>    The length of the sequence x. n must be greater than 1.
00570 //         The method is most efficient when n-1 is a product of
00571 //         small primes.
00572 // <dt><b>x</b>
00573 // <dd>    An array which contains the sequence to be transformed
00574 // <dt><b>wsave</b>
00575 // <dd>    A work array which must be dimensioned at least 3*n+15
00576 //         in the program that calls cost. The wsave array must be
00577 //         initialized by calling <src>costi(n,wsave)</src> and a
00578 //         different wsave array must be used for each different
00579 //         value of n. This initialization does not have to be
00580 //         repeated so long as n remains unchanged thus subsequent
00581 //         transforms can be obtained faster than the first.
00582 // </dl>
00583 // Output parameters:
00584 // <dl compact>
00585 // <dt><b>x</b>
00586 // <dd>    for i=1,...,n<br>
00587 //             x(i) = x(1)+(-1)**(i-1)*x(n)<br>
00588 //              + the sum from k=2 to k=n-1<br>
00589 //                  2*x(k)*cos((k-1)*(i-1)*pi/(n-1))<br>
00590 // 
00591 //              a call of cost followed by another call of
00592 //              cost will multiply the sequence x by 2*(n-1)
00593 //              hence cost is the unnormalized inverse
00594 //              of itself.
00595 // <dt><b>wsave</b>
00596 // <dd>    Contains initialization calculations which must not be
00597 //         destroyed between calls of cost.
00598 // </dl>
00599 // <group>
00600 static void cost(Int n, Float* x, Float* wsave);
00601 static void cost(Int n, Double* x, Double* wsave);
00602 // </group>
00603 
00604 // sinqi initializes the array wsave which is used in both <src>sinqf</src> and
00605 // <src>sinqb</src>. The prime factorization of n together with a tabulation of
00606 // the trigonometric functions are computed and stored in wsave.
00607 //
00608 // Input parameter:
00609 // <dl compact>
00610 // <dt><b>n</b>
00611 // <dd>    The length of the sequence to be transformed. The method
00612 //         is most efficient when n is a product of small primes.
00613 // </dl>
00614 // Output parameter:
00615 // <dl compact>
00616 // <dt><b>wsave</b>
00617 // <dd>    A work array which must be dimensioned at least 3*n+15.
00618 //         The same work array can be used for both sinqf and sinqb
00619 //         as long as n remains unchanged. Different wsave arrays
00620 //         are required for different values of n. The contents of
00621 //         wsave must not be changed between calls of sinqf or sinqb.
00622 // </dl>
00623 // <group>
00624 static void sinqi(Int n, Float* wsave);
00625 static void sinqi(Int n, Double* wsave);
00626 // </group>
00627 
00628 // sinqf computes the fast Fourier transform of quarter wave data. That is,
00629 // sinqf computes the coefficients in a sine series representation with only
00630 // odd wave numbers. The transform is defined below at output parameter x.
00631 // 
00632 // sinqb is the unnormalized inverse of sinqf since a call of sinqf followed by
00633 // a call of sinqb will multiply the input sequence x by 4*n.
00634 // 
00635 // The array wsave which is used by sinqf must be initialized by calling
00636 // <src>sinqi(n,wsave)</src>.
00637 // 
00638 // Input parameters:
00639 // <dl compact>
00640 // <dt><b>n</b>
00641 // <dd>    The length of the array x to be transformed.  The method
00642 //         is most efficient when n is a product of small primes.
00643 // <dt><b>x</b>
00644 // <dd>    An array which contains the sequence to be transformed
00645 // <dt><b>wsave</b>
00646 //         A work array which must be dimensioned at least 3*n+15.
00647 //         in the program that calls sinqf. The wsave array must be
00648 //         initialized by calling <src>sinqi(n,wsave)</src> and a
00649 //         different wsave array must be used for each different
00650 //         value of n. This initialization does not have to be
00651 //         repeated so long as n remains unchanged thus subsequent
00652 //         transforms can be obtained faster than the first.
00653 // </dl>
00654 // Output parameters:
00655 // <dl compact>
00656 // <dt><b>x</b>
00657 // <dd>    for i=1,...,n<br>
00658 //              x(i) = (-1)**(i-1)*x(n)<br>
00659 //                 + the sum from k=1 to k=n-1 of<br>
00660 //                 2*x(k)*sin((2*i-1)*k*pi/(2*n))<br>
00661 // 
00662 //              a call of sinqf followed by a call of
00663 //              sinqb will multiply the sequence x by 4*n.
00664 //              therefore sinqb is the unnormalized inverse
00665 //              of sinqf.
00666 // <dt><b>wsave </b>
00667 // <dd>    Contains initialization calculations which must not
00668 //         be destroyed between calls of sinqf or sinqb.
00669 // </dl>
00670 // <group>
00671 static void sinqf(Int n, Float* x, Float* wsave);
00672 static void sinqf(Int n, Double* x, Double* wsave);
00673 // </group>
00674 
00675 // sinqb computes the fast Fourier transform of quarter
00676 // wave data. that is, sinqb computes a sequence from its
00677 // representation in terms of a sine series with odd wave numbers.
00678 // the transform is defined below at output parameter x.
00679 // 
00680 // sinqf is the unnormalized inverse of sinqb since a call of sinqb
00681 // followed by a call of sinqf will multiply the input sequence x
00682 // by 4*n.
00683 // 
00684 // The array wsave which is used by <src>sinqb</src> must be
00685 // initialized by calling <src>sinqi(n,wsave)</src>.
00686 // 
00687 // Input parameters:
00688 // <dl compact>
00689 // <dt><b>n</b>
00690 // <dd>    The length of the array x to be transformed.  The method
00691 //         is most efficient when n is a product of small primes.
00692 // <dt><b>x</b>
00693 // <dd>    An array which contains the sequence to be transformed
00694 // <dt><b>wsave</b>
00695 //         A work array which must be dimensioned at least 3*n+15.
00696 //         in the program that calls sinqb. The wsave array must be
00697 //         initialized by calling <src>sinqi(n,wsave)</src> and a
00698 //         different wsave array must be used for each different
00699 //         value of n. This initialization does not have to be
00700 //         repeated so long as n remains unchanged thus subsequent
00701 //         transforms can be obtained faster than the first.
00702 // </dl>
00703 // Output parameters:
00704 // <dl compact>
00705 // <dt><b>x</b>
00706 // <dd>    for i=1,...,n<br>
00707 //              x(i)= the sum from k=1 to k=n of<br>
00708 //                4*x(k)*sin((2k-1)*i*pi/(2*n))<br>
00709 // 
00710 //              a call of sinqb followed by a call of
00711 //              sinqf will multiply the sequence x by 4*n.
00712 //              Therefore sinqf is the unnormalized inverse
00713 //              of sinqb.
00714 // <dt><b>wsave</b>
00715 // <dd>    Contains initialization calculations which must not
00716 //         be destroyed between calls of sinqb or sinqf.
00717 // </dl>
00718 // <group>
00719 static void sinqb(Int n, Float* x, Float* wsave);
00720 static void sinqb(Int n, Double* x, Double* wsave);
00721 // </group>
00722 
00723 // <group>
00724 static void cosqi(Int n, Float* wsave);
00725 static void cosqi(Int n, Double* wsave);
00726 // </group>
00727 // <group>
00728 static void cosqf(Int n, Float* x, Float* wsave);
00729 static void cosqf(Int n, Double* x, Double* wsave);
00730 // </group>
00731 // <group>
00732 static void cosqb(Int n, Float* x, Float* wsave);
00733 static void cosqb(Int n, Double* x, Double* wsave);
00734 // </group>
00735 };
00736 
00737 } //# NAMESPACE CASA - END
00738 
00739 #endif