KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > maths > wavelet > daubechies2 > Scaling2


1
2 package JSci.maths.wavelet.daubechies2;
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 Scaling2 extends MultiscaleFunction implements Cloneable JavaDoc {
12     private int n0;
13     private int k;
14     private static final Daubechies2 cdf=new Daubechies2();
15   
16     public Scaling2 (int N0, int K) {
17         setParameters(N0,K);
18     }
19   /*******************************
20   * Return a String representation
21   * of the object
22   ********************************/

23   public String JavaDoc toString() {
24     String JavaDoc ans=new String JavaDoc("[n0=");
25     ans.concat(Integer.toString(n0));
26     ans.concat("][k=");
27     ans.concat(Integer.toString(k));
28     ans.concat("]");
29     return(ans);
30   }
31   /*****************************************
32   * Check if another object is equal to this
33   * Scaling2 object
34   ******************************************/

35   public boolean equals(Object JavaDoc a) {
36     if((a!=null) && (a instanceof Scaling2)) {
37       Scaling2 iv=(Scaling2)a;
38       return (this.dimension(0)==iv.dimension(0)) && (this.position()==iv.position());
39     }
40     return false;
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 Scaling2 () {
59     }
60   /**********************************************
61   * Set the parameters for this object
62   * @param N0 number of scaling function on the
63   * scale of this object
64   * @param K position or number of this object
65   * @exception IllegalScalingException if N0 is not
66   * large enough
67   ***********************************************/

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

78     public Object JavaDoc clone() {
79     Scaling2 s=(Scaling2) super.clone();
80     s.n0=n0;
81     s.k=k;
82     return(s);
83     }
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   * Starting with dimension() scaling functions and
95   * going jfin scales ahead (iterating jfin times),
96   * tells you how many scaling functions you'll have.
97   * @param jfin number of iterations
98   ******************************************************/

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

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

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