1 /*****************************************************************************
5 ** Purpose: Header for Fourier transform functions
6 ** Programmer: Kevin Rosenberg
7 ** Date Started: Dec 2000
9 ** This is part of the CTSim program
10 ** Copyright (c) 1983-2001 Kevin Rosenberg
14 ** This program is free software; you can redistribute it and/or modify
15 ** it under the terms of the GNU General Public License (version 2) as
16 ** published by the Free Software Foundation.
18 ** This program is distributed in the hope that it will be useful,
19 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ** GNU General Public License for more details.
23 ** You should have received a copy of the GNU General Public License
24 ** along with this program; if not, write to the Free Software
25 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 ******************************************************************************/
37 static void shuffleFourierToNaturalOrder (ImageFile& im);
38 static void shuffleNaturalToFourierOrder (ImageFile& im);
41 static void shuffleFourierToNaturalOrder (fftw_complex* pc, const int n);
42 static void shuffleNaturalToFourierOrder (fftw_complex* pc, const int n);
45 // Odd Number of Points
46 // Natural Frequency Order: -(n-1)/2...-1,0,1...(n-1)/2
47 // Fourier Frequency Order: 0, 1..(n-1)/2,-(n-1)/2...-1
48 // Even Number of Points
49 // Natural Frequency Order: -n/2...-1,0,1...((n/2)-1)
50 // Fourier Frequency Order: 0,1...((n/2)-1),-n/2...-1
52 static void shuffleNaturalToFourierOrder (T* pVector, const int n)
56 if (isOdd(n)) { // Odd
57 int iHalfN = (n - 1) / 2;
59 pTemp[0] = pVector[iHalfN];
60 for (i = 0; i < iHalfN; i++)
61 pTemp[i + 1] = pVector[i + 1 + iHalfN];
62 for (i = 0; i < iHalfN; i++)
63 pTemp[i + iHalfN + 1] = pVector[i];
66 pTemp[0] = pVector[iHalfN];
67 for (i = 0; i < iHalfN - 1; i++)
68 pTemp[i + 1] = pVector[i + iHalfN + 1];
69 for (i = 0; i < iHalfN; i++)
70 pTemp[i + iHalfN] = pVector[i];
73 for (i = 0; i < n; i++)
74 pVector[i] = pTemp[i];
79 static void shuffleFourierToNaturalOrder (T* pVector, const int n)
83 if (isOdd(n)) { // Odd
84 int iHalfN = (n - 1) / 2;
86 pTemp[iHalfN] = pVector[0];
87 for (i = 0; i < iHalfN; i++)
88 pTemp[i + 1 + iHalfN] = pVector[i + 1];
89 for (i = 0; i < iHalfN; i++)
90 pTemp[i] = pVector[i + iHalfN + 1];
93 pTemp[iHalfN] = pVector[0];
94 for (i = 0; i < iHalfN; i++)
95 pTemp[i] = pVector[i + iHalfN];
96 for (i = 0; i < iHalfN - 1; i++)
97 pTemp[i + iHalfN + 1] = pVector[i+1];
100 for (i = 0; i < n; i++)
101 pVector[i] = pTemp[i];
105 static void shuffleNaturalToFourierOrder (float* pdVector, const int n);
106 static void shuffleNaturalToFourierOrder (double* pdVector, const int n);
107 static void shuffleNaturalToFourierOrder (std::complex<double>* pdVector, const int n);
108 static void shuffleFourierToNaturalOrder (float* pdVector, const int n);
109 static void shuffleFourierToNaturalOrder (double* pdVector, const int n);
110 static void shuffleFourierToNaturalOrder (std::complex<double>* pdVector, const int n);