KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > maths > wavelet > daubechies6 > Wavelet6


1
2 package JSci.maths.wavelet.daubechies6;
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 Wavelet6 extends MultiscaleFunction implements Cloneable JavaDoc {
13     private int n0;
14     private int k;
15     private static final Daubechies6 cdf=new Daubechies6();
16   
17     public Wavelet6 (int N0, int K) {
18         setParameters(N0,K);
19     }
20     public Wavelet6 () {
21     }
22   /*******************************
23   * Return a String representation
24   * of the object
25   ********************************/

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

38   public boolean equals(Object JavaDoc a) {
39     if((a!=null) && (a instanceof Wavelet6)) {
40       Wavelet6 iv=(Wavelet6)a;
41       return (this.dimension(0)==iv.dimension(0)) && (this.position()==iv.position());
42     }
43     return false;
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     Wavelet6 w=(Wavelet6) 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   * Tells you what is the number of this
112   * wavelet. Wavelets are numbered from left
113   * to right with the one at the left
114   * boundary being noted 0.
115   *****************************************/

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