KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > maths > wavelet > daubechies2 > Wavelet2


1
2 package JSci.maths.wavelet.daubechies2;
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 Wavelet2 extends MultiscaleFunction implements Cloneable JavaDoc {
12     private int n0;
13     private int k;
14     private static final Daubechies2 cdf=new Daubechies2();
15   
16     public Wavelet2 (int N0, int K) {
17         setParameters(N0,K);
18     }
19     public Wavelet2 () {
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 Wavelet2)) {
39       Wavelet2 iv=(Wavelet2)a;
40       return (this.dimension(0)==iv.dimension(0)) && (this.position()==iv.position());
41     }
42     return false;
43   }
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     Wavelet2 w=(Wavelet2) 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