Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals

sigfft.c

Go to the documentation of this file.
00001 /************************************************************************* 00002 * $Id: sigfft.c,v 1.1 2005/09/09 08:22:53 bellet Exp $ 00003 ************************************************************************** 00004 This software is governed by the CeCILL license under French law and 00005 abiding by the rules of distribution of free software. You can use, 00006 modify and/ or redistribute the software under the terms of the CeCILL 00007 license as circulated by CEA, CNRS and INRIA at the following URL 00008 "http://www.cecill.info". 00009 00010 As a counterpart to the access to the source code and rights to copy, 00011 modify and redistribute granted by the license, users are provided only 00012 with a limited warranty and the software's author, the holder of the 00013 economic rights, and the successive licensors have only limited 00014 liability. 00015 00016 In this respect, the user's attention is drawn to the risks associated 00017 with loading, using, modifying and/or developing or reproducing the 00018 software by the user in light of its specific status of free software, 00019 that may mean that it is complicated to manipulate, and that also 00020 therefore means that it is reserved for developers and experienced 00021 professionals having in-depth computer knowledge. Users are therefore 00022 encouraged to load and test the software's suitability as regards their 00023 requirements in conditions enabling the security of their systems and/or 00024 data to be ensured and, more generally, to use and operate it in the 00025 same conditions as regards security. 00026 00027 The fact that you are presently reading this means that you have had 00028 knowledge of the CeCILL license and that you accept its terms. 00029 00030 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de 00031 l'Image). All rights reserved. See License.txt for details. 00032 00033 Version 1.0 05/09/2005 00034 *************************************************************************/ 00035 00036 /* 00037 * transfomation de fourier rapide (FFT) des signaux 00038 * monodimensionnels complexes 00039 */ 00040 #include <math.h> 00041 #include "idsig.h" 00042 #include "idprint.h" 00043 00044 #define SWAP(a,b) tempr=(a);(a)=(b);(b)=tempr 00045 #define REAL double 00046 00047 00055 void 00056 IdSigFFT(PSIGNAL_COMPLEX sig, int isign) 00057 { 00058 int n, nn, mmax, m, j, istep, i; 00059 REAL wtemp, wr, wpr, wpi, wi, theta; 00060 REAL tempr, tempi; 00061 00062 if (!sig) { 00063 IdErrPrintf("IdSigFFT: Parametrer is NULL\n"); 00064 return; 00065 } 00066 00067 if (IdLibidoType(sig) != SIG) { 00068 IdErrPrintf("IdSigFFT: Parametrer is NOT a SIGNAL\n"); 00069 return; 00070 } 00071 if ((IdLibidoDataType(sig) != TY_COMPLEX) && 00072 (IdLibidoDataType(sig) != TY_COMPLEX_DOUBLE)) 00073 { 00074 IdErrPrintf 00075 ("IdSigFFT: Parametrer is NOT a PSIGNAL_COMPLEX_DOUBLE\n"); 00076 return; 00077 } 00078 00079 nn = IdSigDimX(sig); 00080 n = nn; 00081 j = 1; 00082 for (i = 1; i < n; i++) { 00083 if (j > i) { 00084 SWAP(sig[j - 1].re, sig[i - 1].re); 00085 SWAP(sig[j - 1].im, sig[i - 1].im); 00086 } 00087 m = n >> 1; 00088 while (m >= 2 && j > m) { 00089 j -= m; 00090 m >>= 1; 00091 } 00092 j += m; 00093 } 00094 mmax = 1; 00095 while (n > mmax) { 00096 istep = 2 * mmax; 00097 theta = 6.28318530717959 / (-isign * mmax * 2); 00098 /* 00099 * recipes in C 00100 * +isign 00101 */ 00102 wtemp = sin(0.5 * theta); 00103 wpr = -2.0 * wtemp * wtemp; 00104 wpi = sin(theta); 00105 wr = 1.0; 00106 wi = 0.0; 00107 for (m = 0; m < mmax; m++) { 00108 for (i = m; i < n; i += istep) { 00109 j = i + mmax; 00110 tempr = wr * sig[j].re - wi * sig[j].im; 00111 tempi = wr * sig[j].im + wi * sig[j].re; 00112 sig[j].re = sig[i].re - tempr; 00113 sig[j].im = sig[i].im - tempi; 00114 sig[i].re += tempr; 00115 sig[i].im += tempi; 00116 } 00117 wtemp = wr; 00118 wr = (wtemp) * wpr - wi * wpi + wr; 00119 wi = wi * wpr + wtemp * wpi + wi; 00120 } 00121 mmax = istep; 00122 } 00123 if (isign == -1) 00124 for (i = 0; i < n; i++) { 00125 sig[i].re /= nn; 00126 sig[i].im /= nn; 00127 } 00128 }

Generated on Wed Oct 19 09:28:34 2005 for SIMRI3D by doxygen 1.3.7