KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > maths > wavelet > daubechies6 > Scaling6


1
2 package JSci.maths.wavelet.daubechies6;
3
4 import JSci.maths.wavelet.*;
5
6 /******************************************
7 * Daubechies wavelets adapted to the
8 * interval by Meyer. Thanks to Pierre Vial
9 * for the filters.
10 * @author Daniel Lemire
11 *****************************************/

12 public final class Scaling6 extends MultiscaleFunction implements Cloneable JavaDoc {
13     private int n0;
14     private int k;
15     private static final Daubechies6 cdf=new Daubechies6();
16
17     public Scaling6 (int N0, int K) {
18         setParameters(N0,K);
19     }
20   /*****************************************
21   * Check if another object is equal to this
22   * Scaling6 object
23   ******************************************/

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

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

58     public int getFilterType () {
59                 return(cdf.filtretype);
60     }
61   /**********************************************
62   * Set the parameters for this object
63   * @param N0 number of scaling function on the
64   * scale of this object
65   * @param K position or number of this object
66   * @exception IllegalScalingException if N0 is not
67   * large enough
68   ***********************************************/

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

79     public Object JavaDoc clone() {
80     Scaling6 s=(Scaling6) super.clone();
81     s.n0=n0;
82     s.k=k;
83     return(s);
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