KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > maths > wavelet > daubechies8 > Scaling8


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

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

37   public boolean equals(Object JavaDoc a) {
38     if((a!=null) && (a instanceof Scaling8)) {
39       Scaling8 iv=(Scaling8)a;
40       return (this.dimension(0)==iv.dimension(0)) && (this.position()==iv.position());
41     }
42     return false;
43   }
44     public Scaling8 () {
45     }
46     /****************************************
47   * This method is used to compute
48   * how the number of scaling functions
49   * changes from on scale to the other.
50   * Basically, if you have k scaling
51   * function and a filter of type t, you'll
52   * have 2*k+t scaling functions at the
53   * next scale (dyadic case).
54   * Notice that this method assumes
55   * that one is working with the dyadic
56   * grid while the method "previousDimension"
57   * define in the interface "filter" doesn't.
58     ******************************************/

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

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

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