00001
00037
00038 #include <assert.h>
00039 #include <stdio.h>
00040
00041 #include "packcontainer.h"
00042 #include "haar_classicFreq.h"
00043 #include "daub.h"
00044 #include "packfreq.h"
00045
00046
00050
00051
00052 double data[] = { 32.0, 10.0, 20.0, 38.0, 37.0, 28.0, 38.0, 34.0,
00053 18.0, 24.0, 18.0, 9.0, 23.0, 24.0, 28.0, 34.0 };
00054
00055
00056
00057
00058
00059
00060
00061
00067 void gen_freqMix( double *vecX, double *vecY, size_t N)
00068 {
00069 const double PI = 3.1415926535897932384626433832795;
00070 const double range = 2 * PI;
00071 const double incr = range / (double)N;
00072
00073 double point = 0.0;
00074 int i;
00075 for (i = 0; i < N; i++) {
00076 vecX[i] = point;
00077 vecY[i] = 4 * sin( 64 * point ) +
00078 2 * sin( 32 * point ) +
00079 1 * sin( 16 * point ) +
00080 0.5 * sin( 8 * point );
00081
00082 point = point + incr;
00083 }
00084 }
00085
00086
00087
00091 void gen_sinCombo( double *vecX, double *vecY, size_t N )
00092 {
00093 const double PI = 3.1415926535897932384626433832795;
00094 const double range = 8 * PI;
00095 const double incr = range / (double)N;
00096
00097 double point = 0.0;
00098
00099 int stepCnt = 0;
00100 int i;
00101 for (i = 0; i < N; i++) {
00102 vecX[i] = point;
00103
00104
00105 vecY[i] = sin( 4 * PI * point );
00106
00107
00108
00109
00110
00111 point = point + incr;
00112 }
00113 }
00114
00115
00119 void gen_steps( double *vecX, double *vecY, size_t N, size_t steps )
00120 {
00121 const double PI = 3.1415926535897932384626433832795;
00122 const double range = 32 * PI;
00123 const double incr = range / (double)N;
00124
00125 double point = 0.0;
00126
00127 double mult = 1;
00128 const size_t stepWidth = N / steps;
00129 int stepCnt = 0;
00130 int i;
00131 for (i = 0; i < N; i++) {
00132 vecX[i] = point;
00133 vecY[i] = sin( mult * point );
00134
00135
00136
00137
00138
00139 point = point + incr;
00140 stepCnt++;
00141 if (stepCnt == stepWidth) {
00142 mult = mult + (PI/2.0);
00143 stepCnt = 0;
00144 }
00145 }
00146 }
00147
00148
00152 void gen_chirp( double *vecX, double *vecY, size_t N )
00153 {
00154 const double PI = 3.1415926535897932384626433832795;
00155 const double range = 2;
00156
00157 const double incr = range / (double)N;
00158
00159 double point = 0.0;
00160
00161 int i;
00162 for (i = 0; i < N; i++) {
00163 vecX[i] = point;
00164 vecY[i] = sin( 128 * PI * point * point );
00165
00166
00167
00168 point = point + incr;
00169 }
00170 }
00171
00172
00173
00179 void prCoords( double *vecX, double *vecY, size_t len )
00180 {
00181 for (int i = 0; i < len; i++) {
00182 printf("%7.4f %7.4f\n", vecX[i], vecY[i] );
00183 }
00184 }
00185
00186
00190 void prVec( double *vec, size_t len )
00191 {
00192 for (int i = 0; i < len; i++) {
00193 printf("%4d %7.4f\n", i, vec[i] );
00194 }
00195 }
00196
00197
00206 int
00207 main()
00208 {
00209 const size_t N = 1024;
00210
00211 double vecX[N], vecY[N];
00212
00213
00214
00215 gen_freqMix( vecX, vecY, N );
00216
00217
00218
00219
00220
00221 haar_classicFreq<packcontainer> h;
00222
00223
00224
00225 packfreq tree( vecY, N, &h );
00226
00227
00228
00229
00230
00231 tree.getLevel( 5 );
00232
00233 tree.plotMat(N);
00234
00235
00236 block_pool mem_pool;
00237 mem_pool.free_pool();
00238
00239 return 0;
00240 }