latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 00003 * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany 00004 * 00005 * This file is part of the LTI-Computer Vision Library (LTI-Lib) 00006 * 00007 * The LTI-Lib is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public License (LGPL) 00009 * as published by the Free Software Foundation; either version 2.1 of 00010 * the License, or (at your option) any later version. 00011 * 00012 * The LTI-Lib is distributed in the hope that it will be 00013 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 00014 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with the LTI-Lib; see the file LICENSE. If 00019 * not, write to the Free Software Foundation, Inc., 59 Temple Place - 00020 * Suite 330, Boston, MA 02111-1307, USA. 00021 */ 00022 00023 00024 /*---------------------------------------------------------------- 00025 * project ....: LTI Digital Image/Signal Processing Library 00026 * file .......: ltiFFTinit.h 00027 * authors ....: Stefan Syberichs, Takuyka Ooura 00028 * organization: LTI, RWTH Aachen 00029 * comment.....: inverse FFT routines based on modified code by Takuya Ooura 00030 * with kind permission ooura@kurims.kyoto-u.ac.jp or 00031 * ooura@mmm.t.u-tokyo.ac.jp) 00032 * creation ...: 28.01.2000 00033 * revisions ..: $Id: ltiFFTinit.h,v 1.3 2006/02/08 11:04:10 ltilib Exp $ 00034 */ 00035 00036 #ifndef _LTI_FFTINIT_H 00037 #define _LTI_FFTINIT_H 00038 00039 namespace lti{ 00040 00041 /** 00042 * Namespace with all FFT and inverse FFT routines based on code by 00043 * Takuya Ooura with kind permission ooura@kurims.kyoto-u.ac.jp or 00044 * ooura@mmm.t.u-tokyo.ac.jp). The code has been adapted to use C++ 00045 * and LTI-lib conventions. This functions will be used by the 00046 * functors lti::realFFT and lti::realInvFFT 00047 */ 00048 namespace fft { 00049 // prototypes for c-functions 00050 00051 /** 00052 * reserve memory for a n-dimensional vector of elements with type T 00053 * @param n1 dimension of the vector 00054 * @return pointer to the elements of the vector 00055 */ 00056 template<class T> 00057 T* alloc_1d(const int& n1); 00058 00059 /** 00060 * free memory of 1d array of elements with type T 00061 */ 00062 template<class T> 00063 void free_1d(T* i); 00064 00065 /** 00066 * reserve memory for a n1xn2-matrix of elementes of type T 00067 * @param n1 number of rows 00068 * @param n2 number of columns 00069 * @return pointer to the elements of the vector 00070 */ 00071 template<class T> 00072 T** alloc_2d(const int& n1, const int& n2); 00073 00074 /** 00075 * free memory of 2d array of elements with type T 00076 */ 00077 template<class T> 00078 void free_2d(T** ii); 00079 00080 /** 00081 * real discrete fourier transform for lti::vectors 00082 * @param n data length (must be power of 2) 00083 * @param isgn transform direction: +1 for transform and -1 for inverse. 00084 * @param a the input/output data. In the frecuency domain the real 00085 * parts will be stored in the even locations and the imaginary 00086 * parts in the odd locations. a[1] = real[n/2] 00087 * @param ip work area for bit reversal. ip[0] and ip[1] are pointers to 00088 * cos/sin table 00089 * @param w cos/sin table. 00090 *3 00091 * w[] and ip[] will be initialized if ip[0] == 0 00092 */ 00093 template<class T> 00094 void vrdft(int n, int isgn, vector<T>& a, int *ip, T *w); 00095 00096 template<class T> 00097 void rdft2d(int, int, int, matrix<T>&, T *, int *, T *); 00098 00099 template<class T> 00100 void makewt(int nw, int *ip, T *w); 00101 00102 template<class T> 00103 void makect(int nc, int *ip, T *c); 00104 00105 template<class T> 00106 void bitrv2(int n, int *ip, T *a); 00107 00108 template<class T> 00109 void cftfsub(int n, T *a, T *w); 00110 00111 template<class T> 00112 void cftbsub(int n, T *a, T *w); 00113 00114 template<class T> 00115 void rftfsub(int n, T *a, int nc, T *c); 00116 00117 template<class T> 00118 void rftbsub(int n, T *a, int nc, T *c); 00119 00120 /** 00121 * real discrete fourier transform 00122 * @param n data length (must be power of 2) 00123 * @param isgn transform direction: +1 for transform and -1 for inverse. 00124 * @param a the input/output data. In the frecuency domain the real 00125 * parts will be stored in the even locations and the imaginary 00126 * parts in the odd locations. a[1] = real[n/2] 00127 * @param ip work area for bit reversal. ip[0] and ip[1] are pointers to 00128 * cos/sin table 00129 * @param w cos/sin table. 00130 * 00131 * w[] and ip[] will be initialized if ip[0] == 0 00132 */ 00133 template<class T> 00134 void rdft(int n, int isgn, T *a, int *ip, T *w); 00135 00136 /** 00137 * complex direct fourier transform 00138 * @param n data length (must be power of 2) 00139 * @param isgn transform direction: +1 for transform and -1 for inverse. 00140 * @param a the input/output data. In the frecuency domain the real 00141 * parts will be stored in the even locations and the imaginary 00142 * parts in the odd locations. a[1] = real[n/2] 00143 * @param ip work area for bit reversal. ip[0] and ip[1] are pointers to 00144 * cos/sin table 00145 * @param w cos/sin table. 00146 * 00147 * w[] and ip[] will be initialized if ip[0] == 0 00148 */ 00149 template<class T> 00150 void cdft(int n, int isgn, T *a, int *ip, T *w); 00151 00152 template<class T> 00153 void cft1st(int n, T *a, T *w); 00154 00155 template<class T> 00156 void cftmdl(int n, int l, T *a, T *w); 00157 00158 template<class T> 00159 void bitrv2conj(int n, int *ip, T *a); 00160 } 00161 } 00162 00163 #endif