#include <assert.h>
#include <stdio.h>
#include "packcontainer.h"
#include "haar_classicFreq.h"
#include "daub.h"
#include "packfreq.h"
Go to the source code of this file.
Functions | |
void | gen_freqMix (double *vecX, double *vecY, size_t N) |
\function Generate a signal composed of a sum of sine waves. More... | |
void | gen_sinCombo (double *vecX, double *vecY, size_t N) |
\function Generate a signal composed of one or more sine waves. More... | |
void | gen_steps (double *vecX, double *vecY, size_t N, size_t steps) |
\function Generate a signal that increases in frequency by steps. More... | |
void | gen_chirp (double *vecX, double *vecY, size_t N) |
\function Generate a linear chirp signal. More... | |
void | prCoords (double *vecX, double *vecY, size_t len) |
\function. More... | |
void | prVec (double *vec, size_t len) |
\function Print a vector of doubles. More... | |
int | main () |
\function. More... | |
Variables | |
double | data [] |
Some small data sets. More... |
See http://www.bearcave.com/misl/misl_tech/wavelets/packfreq/index.html
The documentation in this file is formatted for doxygen (see www.doxygen.org).
You may use this source code without limitation and without fee as long as you include: This software was written and is copyrighted by Ian Kaplan, Bear Products International, www.bearcave.com, 2002.
This software is provided "as is", without any warranty or claim as to its usefulness. Anyone who uses this source code uses it at their own risk. Nor is any support provided by Ian Kaplan and Bear Products International.
Please send any bug fixes or suggested source changes to:
iank@bearcave.com
Definition in file freqtest.cpp.
|
\function Generate a linear chirp signal.
Definition at line 152 of file freqtest.cpp. 00153 { 00154 const double PI = 3.1415926535897932384626433832795; 00155 const double range = 2; 00156 // const double range = 16 * PI; 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 // printf("x[%2d] = %7.4g, y[%2d] = %7.4g\n", i, vecX[i], i, vecY[i] ); 00166 // printf("%7.4g, %7.4g\n", vecX[i], vecY[i] ); 00167 // printf("%d, %7.4g\n", i, vecY[i] ); 00168 point = point + incr; 00169 } 00170 } |
|
\function Generate a signal composed of a sum of sine waves. The sine waves summed are in decreasing magnitude and decreasing frequency. Definition at line 67 of file freqtest.cpp. Referenced by main().
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 // printf("%7.4g, %7.4g\n", vecX[i], vecY[i] ); 00082 point = point + incr; 00083 } 00084 } // gen_freqMix |
|
\function Generate a signal composed of one or more sine waves.
Definition at line 91 of file freqtest.cpp. 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 // vecY[i] = sin( 64 * point ) + sin( 32 * point ) + sin( 16 * point ); 00104 // vecY[i] = sin( 16 * PI * point ) + sin( 4 * PI * point ); 00105 vecY[i] = sin( 4 * PI * point ); 00106 00107 // printf("x[%2d] = %7.4g, y[%2d] = %7.4g\n", i, vecX[i], i, vecY[i] ); 00108 // printf("%7.4g, %7.4g\n", vecX[i], vecY[i] ); 00109 // printf("%d, %7.4g\n", i, vecY[i] ); 00110 00111 point = point + incr; 00112 } 00113 } |
|
\function Generate a signal that increases in frequency by steps.
Definition at line 119 of file freqtest.cpp. 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 // printf("x[%2d] = %7.4g, y[%2d] = %7.4g\n", i, vecX[i], i, vecY[i] ); 00136 // printf("%7.4g, %7.4g\n", vecX[i], vecY[i] ); 00137 // printf("%d, %7.4g\n", i, vecY[i] ); 00138 00139 point = point + incr; 00140 stepCnt++; 00141 if (stepCnt == stepWidth) { 00142 mult = mult + (PI/2.0); 00143 stepCnt = 0; 00144 } 00145 } 00146 } |
|
\function. The entry point for code to test the wavelet packet transform. The code in main provides a simple example of how to call the wavelet packet transform code. Definition at line 207 of file freqtest.cpp. 00208 { 00209 const size_t N = 1024; 00210 // const size_t N = sizeof( data ) / sizeof( double ); 00211 double vecX[N], vecY[N]; 00212 00213 // gen_chirp( vecX, vecY, N ); 00214 // gen_steps( vecX, vecY, N, 8 ); 00215 gen_freqMix( vecX, vecY, N ); 00216 // gen_sinCombo( vecX, vecY, N ); 00217 // prVec( vecY, N ); 00218 // prCoords( vecX, vecY, N ); 00219 00220 // The "Haar" classic transform 00221 haar_classicFreq<packcontainer> h; 00222 // Daubechies<packcontainer> h; 00223 00224 // calculate the wavelet packet tree, using the wavelet transform h 00225 packfreq tree( vecY, N, &h ); 00226 // packfreq tree( data, N, &h ); 00227 00228 // tree.pr(); 00229 // printf("\n"); 00230 00231 tree.getLevel( 5 ); 00232 00233 tree.plotMat(N); 00234 00235 // free the memory pool 00236 block_pool mem_pool; 00237 mem_pool.free_pool(); 00238 00239 return 0; 00240 } |
|
\function. Print a vector of doubles whose length is len. Definition at line 179 of file freqtest.cpp. 00180 { 00181 for (int i = 0; i < len; i++) { 00182 printf("%7.4f %7.4f\n", vecX[i], vecY[i] ); 00183 } 00184 } |
|
\function Print a vector of doubles. Print a vector of doubles whose length is len. Definition at line 190 of file freqtest.cpp. 00191 { 00192 for (int i = 0; i < len; i++) { 00193 printf("%4d %7.4f\n", i, vec[i] ); 00194 } 00195 } // prVec |
|
Initial value: { 32.0, 10.0, 20.0, 38.0, 37.0, 28.0, 38.0, 34.0, 18.0, 24.0, 18.0, 9.0, 23.0, 24.0, 28.0, 34.0 }
Definition at line 9 of file polytest.cpp. |