KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > maths > wavelet > daubechies3 > Scaling3


1
2 package JSci.maths.wavelet.daubechies3;
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 Scaling3 extends MultiscaleFunction implements Cloneable JavaDoc {
12     private int n0;
13     private int k;
14     private static final Daubechies3 cdf=new Daubechies3();
15     public Scaling3 (int N0, int K) {
16         setParameters(N0,K);
17     }
18   /*****************************************
19   * Check if another object is equal to this
20   * Scaling3 object
21   ******************************************/

22   public boolean equals(Object JavaDoc a) {
23     if((a!=null) && (a instanceof Scaling3)) {
24       Scaling3 iv=(Scaling3)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   public Scaling3 () {
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   * 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     Scaling3 s=(Scaling3) super.clone();
80     s.n0=n0;
81     s.k=k;
82     return(s);
83     }
84
85
86     /************************************************
87   * Return as an array the sampled values
88   * of the function
89   * @param j number of iterations
90     *************************************************/

91     public double[] evaluate ( int j) {
92         return(cdf.evalScaling (n0, k, j));
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