KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > maths > wavelet > cdf2_4 > DualWavelet2_4


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

14 public final class DualWavelet2_4 extends MultiscaleFunction implements Cloneable JavaDoc {
15     private int n0;
16     private int k;
17     private static CDF2_4 cdf=new CDF2_4();
18    /*****************************************
19   * Check if another object is equal to this
20   * DualWavelet2_4 object
21   ******************************************/

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

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

55     public int getFilterType () {
56             return(cdf.filtretype);
57     }
58     public DualWavelet2_4 (int N0, int K) {
59         setParameters(N0,K);
60     }
61     public DualWavelet2_4 () {
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     DualWavelet2_4 s = (DualWavelet2_4)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));
104     }
105   /****************************************************
106   * Number of scaling functions at scale where this
107   * wavelet belongs.
108   *****************************************************/

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

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