You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

wavelib.h 5.7KB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. #pragma once
  2. #ifdef __cplusplus
  3. extern "C" {
  4. #endif
  5. #if defined(_MSC_VER)
  6. #pragma warning(disable : 4200)
  7. #pragma warning(disable : 4996)
  8. #endif
  9. #ifndef fft_type
  10. #define fft_type double
  11. #endif
  12. #ifndef cplx_type
  13. #define cplx_type double
  14. #endif
  15. typedef struct cplx_t
  16. {
  17. cplx_type re;
  18. cplx_type im;
  19. } cplx_data;
  20. typedef struct wave_set* wave_object;
  21. wave_object wave_init(char* wname);
  22. struct wave_set
  23. {
  24. char wname[50];
  25. int filtlength;// When all filters are of the same length. [Matlab uses zero-padding to make all filters of the same length]
  26. int lpd_len;// Default filtlength = lpd_len = lpr_len = hpd_len = hpr_len
  27. int hpd_len;
  28. int lpr_len;
  29. int hpr_len;
  30. double* lpd;
  31. double* hpd;
  32. double* lpr;
  33. double* hpr;
  34. double params[0];
  35. };
  36. typedef struct fft_t
  37. {
  38. fft_type re;
  39. fft_type im;
  40. } fft_data;
  41. typedef struct fft_set* fft_object;
  42. fft_object fft_init(int N, int sgn);
  43. struct fft_set
  44. {
  45. int N;
  46. int sgn;
  47. int factors[64];
  48. int lf;
  49. int lt;
  50. fft_data twiddle[1];
  51. };
  52. typedef struct fft_real_set* fft_real_object;
  53. fft_real_object fft_real_init(int N, int sgn);
  54. struct fft_real_set
  55. {
  56. fft_object cobj;
  57. fft_data twiddle2[1];
  58. };
  59. typedef struct conv_set* conv_object;
  60. conv_object conv_init(int N, int L);
  61. struct conv_set
  62. {
  63. fft_real_object fobj;
  64. fft_real_object iobj;
  65. int ilen1;
  66. int ilen2;
  67. int clen;
  68. };
  69. typedef struct wt_set* wt_object;
  70. wt_object wt_init(wave_object wave, char* method, int siglength, int J);
  71. struct wt_set
  72. {
  73. wave_object wave;
  74. conv_object cobj;
  75. char method[10];
  76. int siglength;// Length of the original signal.
  77. int outlength;// Length of the output DWT vector
  78. int lenlength;// Length of the Output Dimension Vector "length"
  79. int J; // Number of decomposition Levels
  80. int MaxIter;// Maximum Iterations J <= MaxIter
  81. int even;// even = 1 if signal is of even length. even = 0 otherwise
  82. char ext[10];// Type of Extension used - "per" or "sym"
  83. char cmethod[10]; // Convolution Method - "direct" or "FFT"
  84. int N; //
  85. int cfftset;
  86. int zpad;
  87. int length[102];
  88. double* output;
  89. double params[0];
  90. };
  91. typedef struct wtree_set* wtree_object;
  92. wtree_object wtree_init(wave_object wave, int siglength, int J);
  93. struct wtree_set
  94. {
  95. wave_object wave;
  96. conv_object cobj;
  97. char method[10];
  98. int siglength;// Length of the original signal.
  99. int outlength;// Length of the output DWT vector
  100. int lenlength;// Length of the Output Dimension Vector "length"
  101. int J; // Number of decomposition Levels
  102. int MaxIter;// Maximum Iterations J <= MaxIter
  103. int even;// even = 1 if signal is of even length. even = 0 otherwise
  104. char ext[10];// Type of Extension used - "per" or "sym"
  105. int N; //
  106. int nodes;
  107. int cfftset;
  108. int zpad;
  109. int length[102];
  110. double* output;
  111. int* nodelength;
  112. int* coeflength;
  113. double params[0];
  114. };
  115. typedef struct wpt_set* wpt_object;
  116. wpt_object wpt_init(wave_object wave, int siglength, int J);
  117. struct wpt_set
  118. {
  119. wave_object wave;
  120. conv_object cobj;
  121. int siglength;// Length of the original signal.
  122. int outlength;// Length of the output DWT vector
  123. int lenlength;// Length of the Output Dimension Vector "length"
  124. int J; // Number of decomposition Levels
  125. int MaxIter;// Maximum Iterations J <= MaxIter
  126. int even;// even = 1 if signal is of even length. even = 0 otherwise
  127. char ext[10];// Type of Extension used - "per" or "sym"
  128. char entropy[20];
  129. double eparam;
  130. int N; //
  131. int nodes;
  132. int length[102];
  133. double* output;
  134. double* costvalues;
  135. double* basisvector;
  136. int* nodeindex;
  137. int* numnodeslevel;
  138. int* coeflength;
  139. double params[0];
  140. };
  141. typedef struct cwt_set* cwt_object;
  142. cwt_object cwt_init(char* wave, double param, int siglength, double dt, int J);
  143. struct cwt_set
  144. {
  145. char wave[10];// Wavelet - morl/morlet,paul,dog/dgauss
  146. int siglength;// Length of Input Data
  147. int J;// Total Number of Scales
  148. double s0;// Smallest scale. It depends on the sampling rate. s0 <= 2 * dt for most wavelets
  149. double dt;// Sampling Rate
  150. double dj;// Separation between scales. eg., scale = s0 * 2 ^ ( [0:N-1] *dj ) or scale = s0 *[0:N-1] * dj
  151. char type[10];// Scale Type - Power or Linear
  152. int pow;// Base of Power in case type = pow. Typical value is pow = 2
  153. int sflag;
  154. int pflag;
  155. int npad;
  156. int mother;
  157. double m;// Wavelet parameter param
  158. double smean;// Input Signal mean
  159. cplx_data* output;
  160. double* scale;
  161. double* period;
  162. double* coi;
  163. double params[0];
  164. };
  165. void dwt(wt_object wt, double* inp);
  166. void idwt(wt_object wt, double* dwtop);
  167. void wtree(wtree_object wt, double* inp);
  168. void dwpt(wpt_object wt, double* inp);
  169. void idwpt(wpt_object wt, double* dwtop);
  170. void swt(wt_object wt, double* inp);
  171. void iswt(wt_object wt, double* swtop);
  172. void modwt(wt_object wt, double* inp);
  173. void imodwt(wt_object wt, double* dwtop);
  174. void setDWTExtension(wt_object wt, char* extension);
  175. void setWTREEExtension(wtree_object wt, char* extension);
  176. void setDWPTExtension(wpt_object wt, char* extension);
  177. void setDWPTEntropy(wpt_object wt, char* entropy, double eparam);
  178. void setWTConv(wt_object wt, char* cmethod);
  179. int getWTREENodelength(wtree_object wt, int X);
  180. void getWTREECoeffs(wtree_object wt, int X, int Y, double* coeffs, int N);
  181. int getDWPTNodelength(wpt_object wt, int X);
  182. void getDWPTCoeffs(wpt_object wt, int X, int Y, double* coeffs, int N);
  183. int setCWTScales(cwt_object wt, double s0, double dj, char* type, int power);
  184. void setCWTScaleVector(cwt_object wt, double* scale, int J, double s0, double dj);
  185. void setCWTPadding(cwt_object wt, int pad);
  186. int cwt(cwt_object wt, double* inp);
  187. void icwt(cwt_object wt, double* cwtop);
  188. int getCWTScaleLength(int N);
  189. void wave_summary(wave_object obj);
  190. void wt_summary(wt_object wt);
  191. void wtree_summary(wtree_object wt);
  192. void wpt_summary(wpt_object wt);
  193. void cwt_summary(cwt_object wt);
  194. void wave_free(wave_object object);
  195. void wt_free(wt_object object);
  196. void wtree_free(wtree_object object);
  197. void wpt_free(wpt_object object);
  198. void cwt_free(cwt_object object);
  199. #ifdef __cplusplus
  200. }
  201. #endif