00001
00002
00003
00004
00005
00006
00007 #ifdef STORM_USEF
00008 #include "hfwt_.h"
00009 #include "dhfwt_.h"
00010 #include "ihfwt_.h"
00011 #include "hfwtws_.h"
00012 #include "dhfwtws_.h"
00013 #include "ihfwtws_.h"
00014 #endif
00015
00016 #include "stormdef.h"
00017 #define INVSQRT2 STORMDEF_MATHCONST_INVSQRT2
00018
00019 int hfwt(
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 hfwt_( &Sizef, &ns, &size, sdata, wdata, &iflag );
00031 return iflag;
00032
00033 #else
00034
00035 int j,size2;
00036 int size1 = size;
00037 float *xx = new float[Sizef];
00038
00039 #ifdef STORM_FWT_CCHECKUSAGE
00040 if ( size1 < ns ) return 1;
00041 #endif
00042
00043 for( int i = 0; i < size1; i++ ) { wdata[i] = sdata[i]; }
00044 if ( size1 == ns ) return 0;
00045 while ( size1 > ns ) {
00046 size2 = size1 / 2;
00047 for( int i = 0; i < size2; i++ ) {
00048 j = 2 * i;
00049 xx[i] = ( wdata[j] + wdata[j+1] ) * INVSQRT2;
00050 xx[size2+i] = ( wdata[j] - wdata[j+1] ) * INVSQRT2;
00051 }
00052 for( int i = 0; i < size1; i++ ) { wdata[i] = xx[i]; }
00053 size1 = size2;
00054 }
00055 delete [] xx;
00056
00057 #ifdef STORM_FWT_CCHECKUSAGE
00058 if ( size1 != ns ) return 2;
00059 #endif
00060
00061 return 0;
00062
00063 #endif
00064
00065 }
00066
00067
00068 int hfwt(
00069 const int& Sizef,
00070 const int& ns,
00071 const int& size,
00072 const double* sdata,
00073 double* wdata
00074 ) {
00075
00076 #ifdef STORM_USEF
00077
00078 int iflag;
00079 dhfwt_( &Sizef, &ns, &size, sdata, wdata, &iflag );
00080 return iflag;
00081
00082 #else
00083
00084 int j,size2;
00085 int size1 = size;
00086 double *xx = new double[Sizef];
00087
00088 #ifdef STORM_FWT_CCHECKUSAGE
00089 if ( size1 < ns ) return 1;
00090 #endif
00091
00092 for( int i = 0; i < size1; i++ ) { wdata[i] = sdata[i]; }
00093 if ( size1 == ns ) return 0;
00094 while ( size1 > ns ) {
00095 size2 = size1 / 2;
00096 for( int i = 0; i < size2; i++ ) {
00097 j = 2 * i;
00098 xx[i] = ( wdata[j] + wdata[j+1] ) * INVSQRT2;
00099 xx[size2+i] = ( wdata[j] - wdata[j+1] ) * INVSQRT2;
00100 }
00101 for( int i = 0; i < size1; i++ ) { wdata[i] = xx[i]; }
00102 size1 = size2;
00103 }
00104 delete [] xx;
00105
00106 #ifdef STORM_FWT_CCHECKUSAGE
00107 if ( size1 != ns ) return 2;
00108 #endif
00109
00110 return 0;
00111
00112 #endif
00113
00114 }
00115
00116
00117 int hfwt(
00118 const int& Sizef,
00119 const int& ns,
00120 const int& size,
00121 const int* sdata,
00122 int* wdata
00123 ) {
00124
00125 #ifdef STORM_USEF
00126
00127 int iflag;
00128 ihfwt_( &Sizef, &ns, &size, sdata, wdata, &iflag );
00129 return iflag;
00130
00131 #else
00132
00133 int j,size2;
00134 int size1 = size;
00135 int *xx = new int[Sizef];
00136
00137 #ifdef STORM_FWT_CCHECKUSAGE
00138 if ( size1 < ns ) return 1;
00139 #endif
00140
00141 for( int i = 0; i < size1; i++ ) { wdata[i] = sdata[i]; }
00142 if ( size1 == ns ) return 0;
00143 while ( size1 > ns ) {
00144 size2 = size1 / 2;
00145 for( int i = 0; i < size2; i++ ) {
00146 j = 2 * i;
00147 xx[i] = ( wdata[j] + wdata[j+1] ) / 2;
00148 xx[size2+i] = wdata[j] - wdata[j+1];
00149 }
00150 for( int i = 0; i < size1; i++ ) { wdata[i] = xx[i]; }
00151 size1 = size2;
00152 }
00153 delete [] xx;
00154
00155 #ifdef STORM_FWT_CCHECKUSAGE
00156 if ( size1 != ns ) return 2;
00157 #endif
00158
00159 return 0;
00160
00161 #endif
00162
00163 }
00164
00165
00166 int hfwt(
00167 const int& Sizef,
00168 const int& ns,
00169 const int& size,
00170 const float* sdata,
00171 float* wdata,
00172 float* ws
00173 ) {
00174
00175 #ifdef STORM_USEF
00176
00177 int iflag;
00178 hfwtws_( &Sizef, &ns, &size, sdata, wdata, ws, &iflag );
00179 return iflag;
00180
00181 #else
00182
00183 int j,size2;
00184 int size1 = size;
00185 if ( size1 < ns ) return 1;
00186 for( int i = 0; i < size1; i++ ) { wdata[i] = sdata[i]; }
00187
00188 #ifdef STORM_FWT_CCHECKUSAGE
00189 if ( size1 == ns ) return 0;
00190 #endif
00191
00192 while ( size1 > ns ) {
00193 size2 = size1 / 2;
00194 for( int i = 0; i < size2; i++ ) {
00195 j = 2 * i;
00196 ws[i] = ( wdata[j] + wdata[j+1] ) * INVSQRT2;
00197 ws[size2+i] = ( wdata[j] - wdata[j+1] ) * INVSQRT2;
00198 }
00199 for( int i = 0; i < size1; i++ ) { wdata[i] = ws[i]; }
00200 size1 = size2;
00201 }
00202
00203 #ifdef STORM_FWT_CCHECKUSAGE
00204 if ( size1 != ns ) return 2;
00205 #endif
00206
00207 return 0;
00208
00209 #endif
00210
00211 }
00212
00213
00214 int hfwt(
00215 const int& Sizef,
00216 const int& ns,
00217 const int& size,
00218 const double* sdata,
00219 double* wdata,
00220 double* ws
00221 ) {
00222
00223 #ifdef STORM_USEF
00224
00225 int iflag;
00226 dhfwtws_( &Sizef, &ns, &size, sdata, wdata, ws, &iflag );
00227 return iflag;
00228
00229 #else
00230
00231 int j,size2;
00232 int size1 = size;
00233
00234 #ifdef STORM_FWT_CCHECKUSAGE
00235 if ( size1 < ns ) return 1;
00236 #endif
00237
00238 for( int i = 0; i < size1; i++ ) { wdata[i] = sdata[i]; }
00239 if ( size1 == ns ) return 0;
00240 while ( size1 > ns ) {
00241 size2 = size1 / 2;
00242 for( int i = 0; i < size2; i++ ) {
00243 j = 2 * i;
00244 ws[i] = ( wdata[j] + wdata[j+1] ) * INVSQRT2;
00245 ws[size2+i] = ( wdata[j] - wdata[j+1] ) * INVSQRT2;
00246 }
00247 for( int i = 0; i < size1; i++ ) { wdata[i] = ws[i]; }
00248 size1 = size2;
00249 }
00250
00251 #ifdef STORM_FWT_CCHECKUSAGE
00252 if ( size1 != ns ) return 2;
00253 #endif
00254
00255 return 0;
00256
00257 #endif
00258
00259 }
00260
00261
00262 int hfwt(
00263 const int& Sizef,
00264 const int& ns,
00265 const int& size,
00266 const int* sdata,
00267 int* wdata,
00268 int* ws
00269 ) {
00270
00271 #ifdef STORM_USEF
00272
00273 int iflag;
00274 ihfwtws_( &Sizef, &ns, &size, sdata, wdata, ws, &iflag );
00275 return iflag;
00276
00277 #else
00278
00279 int j,size2;
00280 int size1 = size;
00281
00282 #ifdef STORM_FWT_CCHECKUSAGE
00283 if ( size1 < ns ) return 1;
00284 #endif
00285
00286 for( int i = 0; i < size1; i++ ) { wdata[i] = sdata[i]; }
00287 if ( size1 == ns ) return 0;
00288 while ( size1 > ns ) {
00289 size2 = size1 / 2;
00290 for( int i = 0; i < size2; i++ ) {
00291 j = 2 * i;
00292 ws[i] = ( wdata[j] + wdata[j+1] ) / 2;
00293 ws[size2+i] = wdata[j] - wdata[j+1];
00294 }
00295 for( int i = 0; i < size1; i++ ) { wdata[i] = ws[i]; }
00296 size1 = size2;
00297 }
00298
00299 #ifdef STORM_FWT_CCHECKUSAGE
00300 if ( size1 != ns ) return 2;
00301 #endif
00302
00303 return 0;
00304
00305 #endif
00306
00307 }
00308
00309 #undef INVSQRT2
00310