00001 #ifndef Impala_Core_Array_MakeGaborIIR1d_h
00002 #define Impala_Core_Array_MakeGaborIIR1d_h
00003
00004 #include "Util/Math.h"
00005 #include "Core/Array/Arrays.h"
00006
00007 namespace Impala
00008 {
00009 namespace Core
00010 {
00011 namespace Array
00012 {
00013
00014
00039 inline Array2dComplex64*
00040 MakeGaborIIR1d(double sigma, double omega0,
00041 Complex64 &borderIn, Complex64 &borderOut)
00042 {
00043 int size = 7;
00044 double _re[7];
00045 double _im[7];
00046
00047
00048
00049
00050 double m0 = 1.16680, m1 = 1.10783, m2 = 1.40586 ;
00051 double m1sq = m1*m1, m2sq = m2*m2 ;
00052
00053
00054 double q ;
00055 if(sigma < 3.556)
00056 q = -0.2568 + 0.5784 * sigma + 0.0561 * sigma * sigma ;
00057 else
00058 q = 2.5091 + 0.9804 * (sigma - 3.556) ;
00059
00060 double qsq = q*q ;
00061
00062
00063 double scale = (m0 + q) * (m1sq + m2sq + 2*m1*q + qsq) ;
00064 double b0 = 1 ;
00065 double b1 = -q * (2*m0*m1 + m1sq + m2sq + (2*m0 + 4*m1) * q + 3*qsq) / scale ;
00066 double b2 = qsq * (m0 + 2*m1 + 3*q) / scale ;
00067 double b3 = - qsq * q / scale ;
00068
00069
00070
00071 double B = (m0 * (m1sq + m2sq))/scale ;
00072
00073
00074
00075
00076 _re[0] = -b3 * cos(3*omega0) ; _im[0] = -b3 * sin(3*omega0) ;
00077 _re[1] = -b2 * cos(2*omega0) ; _im[1] = -b2 * sin(2*omega0) ;
00078 _re[2] = -b1 * cos(omega0) ; _im[2] = -b1 * sin(omega0) ;
00079 _re[3] = B ; _im[3] = 0 ;
00080 _re[4] = _re[2] ; _im[4] = -_im[2] ;
00081 _re[5] = _re[1] ; _im[5] = -_im[1] ;
00082 _re[6] = _re[0] ; _im[6] = -_im[0] ;
00083
00084
00085
00086 double leftReal = 1.0 - _re[2] - _re[1] - _re[0] ;
00087 double leftImaginary = - _im[2] - _im[1] - _im[0] ;
00088
00089 double rightReal = 1.0 - _re[4] - _re[5] - _re[6] ;
00090 double rightImaginary = - _im[4] - _im[5] - _im[6] ;
00091
00092 borderIn = Complex64(leftReal,leftImaginary) ;
00093 borderOut = Complex64(rightReal,rightImaginary) ;
00094
00095 Complex64 complexB(B,0);
00096 Complex64 one(1.0,0.0) ;
00097
00098
00099 borderIn = complexB / borderIn ;
00100 borderOut = complexB / borderOut ;
00101
00102
00103 Array2dComplex64* result = ArrayCreate<Array2dComplex64>(7, 1);
00104 Real64* ptr = result->CPB(0, 0);
00105 for (int i=0 ; i<7 ; i++)
00106 {
00107
00108 *ptr++ = _re[i];
00109 *ptr++ = _im[i];
00110 }
00111 return result;
00112 }
00113
00114 }
00115 }
00116 }
00117
00118 #endif