KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > maths > wavelet > cdf3_5 > DualWavelet3_5


1
2 package JSci.maths.wavelet.cdf3_5;
3
4 import JSci.maths.wavelet.*;
5
6 /******************************************
7 * Cohen-Daubechies-Feauveau
8 * with N=3 and
9 * Ntilde=5 adapted to the interval
10 * by Deslauriers-Dubuc-Lemire
11 * @author Daniel Lemire
12 *****************************************/

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

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

36   public String JavaDoc toString() {
37     String JavaDoc ans=new String JavaDoc("[n0=");
38     ans.concat(Integer.toString(n0));
39     ans.concat("][k=");
40     ans.concat(Integer.toString(k));
41     ans.concat("]");
42     return(ans);
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     public DualWavelet3_5 () {
62     }
63   /**********************************************
64   * Set the parameters for this object
65   * @param N0 number of scaling function on the
66   * scale of this object
67   * @param K position or number of this object
68   * @exception IllegalScalingException if N0 is not
69   * large enough
70   ***********************************************/

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

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

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

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

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

119     public int position() {
120         return(k);
121     }
122 }
123
Popular Tags