KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

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

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

54     public int getFilterType () {
55         return(cdf.filtretype);
56     }
57
58     public DualScaling2_4 (int N0, int K) {
59         setParameters(N0,K);
60     }
61   /********************************************
62   * Return a copy of this object
63   *********************************************/

64     public Object JavaDoc clone() {
65     DualScaling2_4 s = (DualScaling2_4)super.clone();
66     s.n0=n0;
67     s.k=k;
68     return(s);
69     }
70
71     public DualScaling2_4 () {
72     }
73   /**********************************************
74   * Set the parameters for this object
75   * @param N0 number of scaling function on the
76   * scale of this object
77   * @param K position or number of this object
78   * @exception IllegalScalingException if N0 is not
79   * large enough
80   ***********************************************/

81     public void setParameters(int N0, int K) {
82         if(N0<cdf.minlength) {
83             throw new IllegalScalingException(N0,cdf.minlength);
84         }
85         n0=N0;
86         k=K;
87     }
88     /************************************************
89   * Return as an array the sampled values
90   * of the function
91   * @param j number of iterations
92     *************************************************/

93     public double[] evaluate (int j) {
94         return(cdf.evalScaling (n0, k, j));
95     }
96
97   /****************************************************
98   * Starting with dimension() scaling functions and
99   * going jfin scales ahead (iterating jfin times),
100   * tells you how many scaling functions you'll have.
101   * @param jfin number of iterations
102   ******************************************************/

103     public int dimension(int jfin) {
104         return(Cascades.dimension(n0,jfin));
105     }
106
107   /****************************************************
108   * Number of scaling functions at scale where this
109   * scaling function belongs.
110   *****************************************************/

111     public int dimension() {
112         return(n0);
113     }
114
115   /****************************************
116   * Tells you what is the number of this
117   * scaling function. Scaling functions are
118   * numbered from left to right with the
119   * one at the left boundary being noted 0.
120   *****************************************/

121     public int position() {
122         return(k);
123     }
124 }
125
Popular Tags