KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > maths > wavelet > daubechies4 > Wavelet4


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

11 public final class Wavelet4 extends MultiscaleFunction implements Cloneable JavaDoc {
12     private int n0;
13     private int k;
14     private static final Daubechies4 cdf=new Daubechies4();
15     public Wavelet4 (int N0, int K) {
16         setParameters(N0,K);
17     }
18   /*****************************************
19   * Check if another object is equal to this
20   * Wavelet8 object
21   ******************************************/

22   public boolean equals(Object JavaDoc a) {
23     if((a!=null) && (a instanceof Wavelet4)) {
24       Wavelet4 iv=(Wavelet4)a;
25       return (this.dimension(0)==iv.dimension(0)) && (this.position()==iv.position());
26     }
27     return false;
28   }
29
30   /*******************************
31   * Return a String representation
32   * of the object
33   ********************************/

34   public String JavaDoc toString() {
35     String JavaDoc ans=new String JavaDoc("[n0=");
36     ans.concat(Integer.toString(n0));
37     ans.concat("][k=");
38     ans.concat(Integer.toString(k));
39     ans.concat("]");
40     return(ans);
41   }
42   
43     public Wavelet4 () {
44     }
45     /****************************************
46   * This method is used to compute
47   * how the number of scaling functions
48   * changes from on scale to the other.
49   * Basically, if you have k scaling
50   * function and a filter of type t, you'll
51   * have 2*k+t scaling functions at the
52   * next scale (dyadic case).
53   * Notice that this method assumes
54   * that one is working with the dyadic
55   * grid while the method "previousDimension"
56   * define in the interface "filter" doesn't.
57     ******************************************/

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

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

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

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

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

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

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