KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > maths > wavelet > daubechies7 > Wavelet7


1
2 package JSci.maths.wavelet.daubechies7;
3
4 import JSci.maths.wavelet.*;
5
6 /******************************************
7 * Daubechies wavelets adapted to the
8 * interval by Meyer. Thanks to Pierre Vial
9 * for the filters.
10 * @author Daniel Lemire
11 *****************************************/

12 public final class Wavelet7 extends MultiscaleFunction implements Cloneable JavaDoc {
13     private int n0;
14     private int k;
15     private static final Daubechies7 cdf=new Daubechies7();
16
17     public Wavelet7 (int N0, int K) {
18         setParameters(N0,K);
19     }
20
21   /*******************************
22   * Return a String representation
23   * of the object
24   ********************************/

25   public String JavaDoc toString() {
26     String JavaDoc ans=new String JavaDoc("[n0=");
27     ans.concat(Integer.toString(n0));
28     ans.concat("][k=");
29     ans.concat(Integer.toString(k));
30     ans.concat("]");
31     return(ans);
32   }
33   /*****************************************
34   * Check if another object is equal to this
35   * Wavelet8 object
36   ******************************************/

37   public boolean equals(Object JavaDoc a) {
38     if((a!=null) && (a instanceof Wavelet7)) {
39       Wavelet7 iv=(Wavelet7)a;
40       return (this.dimension(0)==iv.dimension(0)) && (this.position()==iv.position());
41     }
42     return false;
43   }
44
45     public Wavelet7 () {
46     }
47     /****************************************
48   * This method is used to compute
49   * how the number of scaling functions
50   * changes from on scale to the other.
51   * Basically, if you have k scaling
52   * function and a filter of type t, you'll
53   * have 2*k+t scaling functions at the
54   * next scale (dyadic case).
55   * Notice that this method assumes
56   * that one is working with the dyadic
57   * grid while the method "previousDimension"
58   * define in the interface "filter" doesn't.
59     ******************************************/

60     public int getFilterType () {
61                 return(cdf.filtretype);
62     }
63   /**********************************************
64   * Set the parameters for this object
65   * @param N0 number of scaling function on the
66   * scale of this object
67   * @param K position or number of this object
68   * @exception IllegalScalingException if N0 is not
69   * large enough
70   ***********************************************/

71     public void setParameters(int N0, int K) {
72         if(N0<cdf.minlength) {
73             throw new IllegalScalingException(N0,cdf.minlength);
74         }
75         n0=N0;
76         k=K;
77     }
78   /********************************************
79   * Return a copy of this object
80   *********************************************/

81     public Object JavaDoc clone() {
82     Wavelet7 w=(Wavelet7) super.clone();
83     w.n0=n0;
84     w.k=k;
85     return(w);
86     }
87     /************************************************
88   * Return as an array the sampled values
89   * of the function
90   * @param j number of iterations
91     *************************************************/

92     public double[] evaluate ( int j) {
93         return(cdf.evalWavelet (n0, k, j));
94     }
95   /****************************************************
96   * Given that the wavelet is written in terms of
97   * a scale containing dimension() scaling functions and
98   * going jfin scales ahead (iterating jfin times),
99   * tells you how many scaling functions you'll need.
100   * @param jfin number of iterations
101   ******************************************************/

102     public int dimension(int jfin) {
103         return(Cascades.dimension(n0,jfin+1,cdf.filtretype));
104     }
105   /****************************************************
106   * Number of scaling functions at scale where this
107   * wavelet belongs.
108   *****************************************************/

109     public int dimension() {
110         return(dimension(0));
111     }
112   /****************************************
113   * Tells you what is the number of this
114   * wavelet. Wavelets are numbered from left
115   * to right with the one at the left
116   * boundary being noted 0.
117   *****************************************/

118     public int position() {
119         return(k);
120     }
121 }
122
123
Popular Tags