KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

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

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

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

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

78     public void setParameters(int N0, int K) {
79         if(N0<cdf.minlength) {
80             throw new IllegalScalingException(N0,cdf.minlength);
81         }
82         n0=N0;
83         k=K;
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.evalScaling (n0, k, j));
92     }
93
94   /****************************************************
95   * Starting with dimension() scaling functions and
96   * going jfin scales ahead (iterating jfin times),
97   * tells you how many scaling functions you'll have.
98   * @param jfin number of iterations
99   ******************************************************/

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

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

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