00001
00002
00003
00004
00005
00006
00007 #ifdef STORM_USEF
00008 #include "g1fwt_.h"
00009 #include "dg1fwt_.h"
00010 #include "g1fwtws_.h"
00011 #include "dg1fwtws_.h"
00012 #endif
00013
00014 #include "stormdef.h"
00015 #define H00 STORMDEF_MATHCONST_GHB1H00
00016 #define H10 STORMDEF_MATHCONST_GHB1H10
00017 #define H11 STORMDEF_MATHCONST_GHB1H11
00018
00019 int g1fwt(
00020 const int& Sizef,
00021 const int& ns,
00022 const int& size,
00023 const float* sdata,
00024 float* wdata
00025 ) {
00026
00027 #ifdef STORM_USEF
00028
00029 int iflag;
00030 g1fwt_( &Sizef, &ns, &size, sdata, wdata, &iflag );
00031 return iflag;
00032
00033 #else
00034
00035 int j,size2;
00036 int size1 = size;
00037
00038 #ifdef STORM_FWT_CCHECKUSAGE
00039 if ( size1 < ns ) return 1;
00040 #endif
00041
00042 for( int i = 0; i < 2*size; i++ ) {
00043 wdata[i] = sdata[i];
00044 }
00045 if ( size1 == ns ) return 0;
00046 float *xx = new float[2*Sizef];
00047 while ( size1 > ns ) {
00048 size2 = size1 / 2;
00049 for( int i = 0; i < size2; i++ ) {
00050 j = 2 * i;
00051 xx[2*i] = H00 * ( wdata[2*j] + wdata[2*j+2] );
00052 xx[2*i+1] = H10 * ( wdata[2*j] - wdata[2*j+2] )
00053 + H11 * ( wdata[2*j+1] + wdata[2*j+3] );
00054 xx[2*(size2+i)] = H11 * ( wdata[2*j] - wdata[2*j+2] )
00055 - H10 * ( wdata[2*j+1] + wdata[2*j+3] );
00056 xx[2*(size2+i)+1]= H00 * ( wdata[2*j+1] - wdata[2*j+3]);
00057 }
00058 for( int i = 0; i < 2*size1; i++ ) {
00059 wdata[i] = xx[i];
00060 }
00061 size1 = size2;
00062 }
00063 delete [] xx;
00064
00065 #ifdef STORM_FWT_CCHECKUSAGE
00066 if ( size1 < ns ) return 2;
00067 #endif
00068
00069 return 0;
00070
00071 #endif
00072
00073 }
00074
00075
00076
00077 int g1fwt(
00078 const int& Sizef,
00079 const int& ns,
00080 const int& size,
00081 const double* sdata,
00082 double* wdata
00083 ) {
00084
00085 #ifdef STORM_USEF
00086
00087 int iflag;
00088 dg1fwt_( &Sizef, &ns, &size, sdata, wdata, &iflag );
00089
00090 return iflag;
00091
00092 #else
00093
00094 int j,size2;
00095 int size1 = size;
00096
00097 #ifdef STORM_FWT_CCHECKUSAGE
00098 if ( size1 < ns ) return 1;
00099 #endif
00100
00101 for( int i = 0; i < 2*size; i++ ) {
00102 wdata[i] = sdata[i];
00103 }
00104 if ( size1 == ns ) return 0;
00105 double *xx = new double[Sizef*2];
00106 while ( size1 > ns ) {
00107 size2 = size1 / 2;
00108 for( int i = 0; i < size2; i++ ) {
00109 j = 2 * i;
00110 xx[2*i] = H00 * ( wdata[2*j] + wdata[2*j+2] );
00111 xx[2*i+1] = H10 * ( wdata[2*j] - wdata[2*j+2] )
00112 + H11 * ( wdata[2*j+1] + wdata[2*j+3] );
00113 xx[2*(size2+i)] = H11 * ( wdata[2*j] - wdata[2*j+2] )
00114 - H10 * ( wdata[2*j+1] + wdata[2*j+3] );
00115 xx[2*(size2+i)+1]= H00 * ( wdata[2*j+1] - wdata[2*j+3]);
00116 }
00117 for( int i = 0; i < 2*size1; i++ ) {
00118 wdata[i] = xx[i];
00119 }
00120 size1 = size2;
00121 }
00122 delete [] xx;
00123
00124 #ifdef STORM_FWT_CCHECKUSAGE
00125 if ( size1 < ns ) return 2;
00126 #endif
00127
00128 return 0;
00129
00130 #endif
00131
00132 }
00133
00134
00135
00136 int g1fwt(
00137 const int& Sizef,
00138 const int& ns,
00139 const int& size,
00140 const float* sdata,
00141 float* wdata,
00142 float* ws
00143 ) {
00144
00145 #ifdef STORM_USEF
00146
00147 int iflag;
00148 g1fwtws_( &Sizef, &ns, &size, sdata, wdata, ws, &iflag );
00149 return iflag;
00150
00151 #else
00152
00153 int j,size2;
00154 int size1 = size;
00155
00156 #ifdef STORM_FWT_CCHECKUSAGE
00157 if ( size1 < ns ) return 1;
00158 #endif
00159
00160 for( int i = 0; i < 2*size; i++ ) {
00161 wdata[i] = sdata[i];
00162 }
00163 if ( size1 == ns ) return 0;
00164 while ( size1 > ns ) {
00165 size2 = size1 / 2;
00166 for( int i = 0; i < size2; i++ ) {
00167 j = 2 * i;
00168 ws[2*i] = H00 * ( wdata[2*j] + wdata[2*j+2] );
00169 ws[2*i+1] = H10 * ( wdata[2*j] - wdata[2*j+2] )
00170 + H11 * ( wdata[2*j+1] + wdata[2*j+3] );
00171 ws[2*(size2+i)] = H11 * ( wdata[2*j] - wdata[2*j+2] )
00172 - H10 * ( wdata[2*j+1] + wdata[2*j+3] );
00173 ws[2*(size2+i)+1]= H00 * ( wdata[2*j+1] - wdata[2*j+3]);
00174 }
00175 for( int i = 0; i < 2*size1; i++ ) {
00176 wdata[i] = ws[i];
00177 }
00178 size1 = size2;
00179 }
00180
00181 #ifdef STORM_FWT_CCHECKUSAGE
00182 if ( size1 < ns ) return 2;
00183 #endif
00184
00185 return 0;
00186
00187 #endif
00188
00189 }
00190
00191
00192
00193 int g1fwt(
00194 const int& Sizef,
00195 const int& ns,
00196 const int& size,
00197 const double* sdata,
00198 double* wdata,
00199 double* ws
00200 ) {
00201
00202 #ifdef STORM_USEF
00203
00204 int iflag;
00205 dg1fwtws_( &Sizef, &ns, &size, sdata, wdata, ws, &iflag );
00206 return iflag;
00207
00208 #else
00209
00210 int j,size2;
00211 int size1 = size;
00212
00213 #ifdef STORM_FWT_CCHECKUSAGE
00214 if ( size1 < ns ) return 1;
00215 #endif
00216
00217 for( int i = 0; i < 2*size; i++ ) {
00218 wdata[i] = sdata[i];
00219 }
00220 if ( size1 == ns ) return 0;
00221 while ( size1 > ns ) {
00222 size2 = size1 / 2;
00223 for( int i = 0; i < size2; i++ ) {
00224 j = 2 * i;
00225 ws[2*i] = H00 * ( wdata[2*j] + wdata[2*j+2] );
00226 ws[2*i+1] = H10 * ( wdata[2*j] - wdata[2*j+2] )
00227 + H11 * ( wdata[2*j+1] + wdata[2*j+3] );
00228 ws[2*(size2+i)] = H11 * ( wdata[2*j] - wdata[2*j+2] )
00229 - H10 * ( wdata[2*j+1] + wdata[2*j+3] );
00230 ws[2*(size2+i)+1]= H00 * ( wdata[2*j+1] - wdata[2*j+3]);
00231 }
00232 for( int i = 0; i < 2*size1; i++ ) {
00233 wdata[i] = ws[i];
00234 }
00235 size1 = size2;
00236 }
00237
00238 #ifdef STORM_FWT_CCHECKUSAGE
00239 if ( size1 < ns ) return 2;
00240 #endif
00241
00242 return 0;
00243
00244 #endif
00245
00246 }
00247
00248
00249 #undef H00
00250 #undef H10
00251 #undef H11
00252