KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > maths > wavelet > daubechies3 > Wavelet3


1
2 package JSci.maths.wavelet.daubechies3;
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 Wavelet3 extends MultiscaleFunction implements Cloneable JavaDoc {
12     private int n0;
13     private int k;
14     private static final Daubechies3 cdf=new Daubechies3();
15     public Wavelet3 (int N0, int K) {
16         setParameters(N0,K);
17     }
18     public Wavelet3 () {
19     }
20   /*****************************************
21   * Check if another object is equal to this
22   * Wavelet8 object
23   ******************************************/

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

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

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

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

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

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

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

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

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