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
12 ** $Id: fourier.h,v 1.7 2001/03/21 21:45:31 kevin Exp $
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 ******************************************************************************/
34 static void shuffleFourierToNaturalOrder (ImageFile& im);
35 static void shuffleNaturalToFourierOrder (ImageFile& im);
37 // Odd Number of Points
38 // Natural Frequency Order: -(n-1)/2...-1,0,1...(n-1)/2
39 // Fourier Frequency Order: 0, 1..(n-1)/2,-(n-1)/2...-1
40 // Even Number of Points
41 // Natural Frequency Order: -n/2...-1,0,1...((n/2)-1)
42 // Fourier Frequency Order: 0,1...((n/2)-1),-n/2...-1
44 static void shuffleNaturalToFourierOrder (T* pVector, const int n)
48 if (isOdd(n)) { // Odd
49 int iHalfN = (n - 1) / 2;
51 pTemp[0] = pVector[iHalfN];
52 for (i = 0; i < iHalfN; i++)
53 pTemp[i + 1] = pVector[i + 1 + iHalfN];
54 for (i = 0; i < iHalfN; i++)
55 pTemp[i + iHalfN + 1] = pVector[i];
58 pTemp[0] = pVector[iHalfN];
59 for (i = 0; i < iHalfN - 1; i++)
60 pTemp[i + 1] = pVector[i + iHalfN + 1];
61 for (i = 0; i < iHalfN; i++)
62 pTemp[i + iHalfN] = pVector[i];
65 for (i = 0; i < n; i++)
66 pVector[i] = pTemp[i];
71 static void shuffleFourierToNaturalOrder (T* pVector, const int n)
75 if (isOdd(n)) { // Odd
76 int iHalfN = (n - 1) / 2;
78 pTemp[iHalfN] = pVector[0];
79 for (i = 0; i < iHalfN; i++)
80 pTemp[i + 1 + iHalfN] = pVector[i + 1];
81 for (i = 0; i < iHalfN; i++)
82 pTemp[i] = pVector[i + iHalfN + 1];
85 pTemp[iHalfN] = pVector[0];
86 for (i = 0; i < iHalfN; i++)
87 pTemp[i] = pVector[i + iHalfN];
88 for (i = 0; i < iHalfN - 1; i++)
89 pTemp[i + iHalfN + 1] = pVector[i+1];
92 for (i = 0; i < n; i++)
93 pVector[i] = pTemp[i];
97 static void shuffleNaturalToFourierOrder (float* pdVector, const int n);
98 static void shuffleNaturalToFourierOrder (double* pdVector, const int n);
99 static void shuffleNaturalToFourierOrder (std::complex<double>* pdVector, const int n);
100 static void shuffleFourierToNaturalOrder (float* pdVector, const int n);
101 static void shuffleFourierToNaturalOrder (double* pdVector, const int n);
102 static void shuffleFourierToNaturalOrder (std::complex<double>* pdVector, const int n);