KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > maths > wavelet > daubechies8 > Wavelet8


1 package JSci.maths.wavelet.daubechies8;
2
3 import JSci.maths.wavelet.*;
4
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 Wavelet8 extends MultiscaleFunction implements Cloneable JavaDoc {
12     private int n0;
13     private int k;
14     private final static Daubechies8 cdf=new Daubechies8();
15
16   /*******************************
17   * Return a String representation
18   * of the object
19   ********************************/

20   public String JavaDoc toString() {
21     String JavaDoc ans=new String JavaDoc("[n0=");
22     ans.concat(Integer.toString(n0));
23     ans.concat("][k=");
24     ans.concat(Integer.toString(k));
25     ans.concat("]");
26     return(ans);
27   }
28   /*****************************************
29   * Check if another object is equal to this
30   * Wavelet8 object
31   ******************************************/

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

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

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

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

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

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

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

115     public int position() {
116         return(k);
117     }
118 }
119
Popular Tags