001: package JSci.maths.wavelet.daubechies8;
002:
003: import JSci.maths.wavelet.*;
004:
005: /******************************************
006: * Daubechies wavelets adapted to the
007: * interval by Meyer. Thanks to Pierre Vial
008: * for the filters.
009: * @author Daniel Lemire
010: *****************************************/
011: public final class Wavelet8 extends MultiscaleFunction implements
012: Cloneable {
013: private int n0;
014: private int k;
015: private final static Daubechies8 cdf = new Daubechies8();
016:
017: /*******************************
018: * Return a String representation
019: * of the object
020: ********************************/
021: public String toString() {
022: String ans = new String("[n0=");
023: ans.concat(Integer.toString(n0));
024: ans.concat("][k=");
025: ans.concat(Integer.toString(k));
026: ans.concat("]");
027: return (ans);
028: }
029:
030: /*****************************************
031: * Check if another object is equal to this
032: * Wavelet8 object
033: ******************************************/
034: public boolean equals(Object a) {
035: if ((a != null) && (a instanceof Wavelet8)) {
036: Wavelet8 iv = (Wavelet8) a;
037: return (this .dimension(0) == iv.dimension(0))
038: && (this .position() == iv.position());
039: }
040: return false;
041: }
042:
043: public Wavelet8(int N0, int K) {
044: setParameters(N0, K);
045: }
046:
047: public Wavelet8() {
048: }
049:
050: /****************************************
051: * This method is used to compute
052: * how the number of scaling functions
053: * changes from on scale to the other.
054: * Basically, if you have k scaling
055: * function and a filter of type t, you'll
056: * have 2*k+t scaling functions at the
057: * next scale (dyadic case).
058: * Notice that this method assumes
059: * that one is working with the dyadic
060: * grid while the method "previousDimension"
061: * define in the interface "filter" doesn't.
062: ******************************************/
063: public int getFilterType() {
064: return (cdf.filtretype);
065: }
066:
067: /**********************************************
068: * Set the parameters for this object
069: * @param N0 number of scaling function on the
070: * scale of this object
071: * @param K position or number of this object
072: * @exception IllegalScalingException if N0 is not
073: * large enough
074: ***********************************************/
075: public void setParameters(int N0, int K) {
076: if (N0 < cdf.minlength) {
077: throw new IllegalScalingException(N0, cdf.minlength);
078: }
079: n0 = N0;
080: k = K;
081: }
082:
083: /********************************************
084: * Return a copy of this object
085: *********************************************/
086: public Object clone() {
087: Wavelet8 w = (Wavelet8) super .clone();
088: w.n0 = n0;
089: w.k = k;
090: return (w);
091: }
092:
093: /************************************************
094: * Return as an array the sampled values
095: * of the function
096: * @param j number of iterations
097: *************************************************/
098: public double[] evaluate(int j) {
099: return (cdf.evalWavelet(n0, k, j));
100: }
101:
102: /****************************************************
103: * Given that the wavelet is written in terms of
104: * a scale containing dimension() scaling functions and
105: * going jfin scales ahead (iterating jfin times),
106: * tells you how many scaling functions you'll need.
107: * @param jfin number of iterations
108: ******************************************************/
109: public int dimension(int jfin) {
110: return (Cascades.dimension(n0, jfin + 1, cdf.filtretype));
111: }
112:
113: /****************************************************
114: * Number of scaling functions at scale where this
115: * wavelet belongs.
116: *****************************************************/
117: public int dimension() {
118: return (dimension(0));
119: }
120:
121: /****************************************
122: * Tells you what is the number of this
123: * wavelet. Wavelets are numbered from left
124: * to right with the one at the left
125: * boundary being noted 0.
126: *****************************************/
127: public int position() {
128: return (k);
129: }
130: }
|