Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Biorthogonal.cc
Go to the documentation of this file.
1 // Wavelet Analysis Tool
2 //--------------------------------------------------------------------
3 // Implementation of
4 // Bi-othogonal wavelet transforms using lifting scheme
5 // References:
6 // A.Cohen, I.Daubechies, J.Feauveau Bases of compactly supported wavelets
7 // Comm. Pure. Appl. Math. 45, 485-560, 1992
8 // W. Sweldens - Building your own wavelets at home
9 //--------------------------------------------------------------------
10 //$Id: Biorthogonal.hh,v 0.2 2001/08/06 19:37:00 klimenko Exp $
11 
12 #define BIORTHOGONAL_CC
13 
14 #include "Biorthogonal.hh"
15 
16 //namespace datacondAPI {
17 //namespace wat {
18 
19 ClassImp(Biorthogonal<double>)
20 
21 // constructors
22 
23 template<class DataType_t> Biorthogonal<DataType_t>::
25 WaveDWT<DataType_t>(w)
26 {
27  setFilter();
28 }
29 
30 template<class DataType_t> Biorthogonal<DataType_t>::
32 WaveDWT<DataType_t>(w)
33 {
34  setFilter();
35 }
36 
37 template<class DataType_t> Biorthogonal<DataType_t>::
38 Biorthogonal(int m, int tree, enum BORDER border) :
39 WaveDWT<DataType_t>(m,m,tree,border)
40 {
41  setFilter();
42 }
43 
44 // destructor
45 template<class DataType_t>
47 {
48  if(PForward) delete [] PForward;
49  if(PInverse) delete [] PInverse;
50  if(UForward) delete [] UForward;
51  if(UInverse) delete [] UInverse;
52 }
53 
54 // clone
55 template<class DataType_t>
57 {
58  return new Biorthogonal<DataType_t>(*this);
59 }
60 
61 // set filter and wavelet type
62 template<class DataType_t>
64 {
65  int n = this->m_H;
66 
67  n = (n>>1)<<1;
68  if(n < 2) n=4;
69 // if(n > 30) n=30; // limit is due to the unrolled code length
70 
71  PForward=new double[n];
72  PInverse=new double[n];
73  UForward=new double[n];
74  UInverse=new double[n];
75 
76  for(int i=0; i<n; i++)
77  {
78  PForward[i] = Lagrange(n,i,0.);
79  UForward[i] = 0.5*PForward[i];
80  PInverse[i] = -PForward[i];
81  UInverse[i] = -UForward[i];
82 // printf("%8.3e ",PForward[i]);
83  }
84  this->m_H = n;
85  this->m_L = n;
86  this->m_WaveType = BIORTHOGONAL;
87 }
88 
89 // forward function does one step of forward transformation.
90 // <level> input parameter is the level to be transformed
91 // <layer> input parameter is the layer to be transformed.
92 template<class DataType_t>
93 void Biorthogonal<DataType_t>::forward(int level,int layer)
94 {
95  int i;
96  int step = 1<<level;
97  this->predict(level, layer, PForward);
98  this->update(level, layer, UForward);
99  const int nS = this->nWWS>>level; // number of samples in the layer
100  DataType_t *pData = this->pWWS+this->getOffset(level,layer); // pointer to the first sample in the layer
101  if(this->m_Heterodine){
102  for(i=1; i<nS; i+=4) {pData[i*step] *= -1;} // heterodine detailes coefficients
103  }
104 }
105 
106 // inverse function does one step of inverse transformation.
107 // <level> input parameter is the level to be reconstructed
108 // <layer> input parameter is the layer to be reconstructed.
109 template<class DataType_t>
110 void Biorthogonal<DataType_t>::inverse(int level,int layer)
111 {
112  int i;
113  int step = 1<<level;
114  const int nS = this->nWWS>>level; // number of samples in the layer
115  DataType_t *pData = this->pWWS+this->getOffset(level,layer); // pointer to the first sample in the layer
116 
117  if(this->m_Heterodine){
118  for(i=1; i<nS; i+=4) {pData[i*step] *= -1;} // heterodine detailes coefficients
119  }
120 
121  this->update(level, layer, UInverse);
122  this->predict(level, layer, PInverse);
123 }
124 
125 
126 // instantiations
127 
128 #define CLASS_INSTANTIATION(class_) template class Biorthogonal< class_ >;
129 
130 CLASS_INSTANTIATION(float)
131 CLASS_INSTANTIATION(double)
132 //CLASS_INSTANTIATION(std::complex<float>)
133 //CLASS_INSTANTIATION(std::complex<double>)
134 
135 #undef CLASS_INSTANTIATION
136 
137 //template Biorthogonal<float>::
138 //Biorthogonal(const Biorthogonal<float> &);
139 //template Biorthogonal<double>::
140 //Biorthogonal(const Biorthogonal<double> &);
141 
142 //} // end namespace wat
143 //} // end namespace datacondAPI
144 
145 
146 
147 
148 
149 
150 
151 
152 
TTree * tree
Definition: TimeSortTree.C:20
#define CLASS_INSTANTIATION(class_)
void setFilter()
Definition: Biorthogonal.cc:63
int n
Definition: cwb_net.C:10
BORDER
Definition: Wavelet.hh:18
virtual Biorthogonal * Clone() const
return: Wavelet* - duplicate of *this, allocated on heap
Definition: Biorthogonal.cc:56
int m
Definition: cwb_net.C:10
i drho i
void inverse(int level, int layer)
wavearray< double > w
Definition: Test1.C:27
void forward(int level, int layer)
Definition: Biorthogonal.cc:93
r setFilter(10)
double Lagrange(const int n, const int i, const double x)
Definition: watfun.hh:20
virtual ~Biorthogonal()
Definition: Biorthogonal.cc:46
Biorthogonal(const Wavelet &)
Definition: Biorthogonal.cc:24