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 Scaling8 extends MultiscaleFunction implements
012: Cloneable {
013: private int n0;
014: private int k;
015: private final static Daubechies8 cdf = new Daubechies8();
016:
017: public Scaling8(int N0, int K) {
018: setParameters(N0, K);
019: }
020:
021: /*******************************
022: * Return a String representation
023: * of the object
024: ********************************/
025: public String toString() {
026: String ans = new String("[n0=");
027: ans.concat(Integer.toString(n0));
028: ans.concat("][k=");
029: ans.concat(Integer.toString(k));
030: ans.concat("]");
031: return (ans);
032: }
033:
034: /*****************************************
035: * Check if another object is equal to this
036: * Scaling8 object
037: ******************************************/
038: public boolean equals(Object a) {
039: if ((a != null) && (a instanceof Scaling8)) {
040: Scaling8 iv = (Scaling8) a;
041: return (this .dimension(0) == iv.dimension(0))
042: && (this .position() == iv.position());
043: }
044: return false;
045: }
046:
047: public Scaling8() {
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: Scaling8 s = (Scaling8) super .clone();
088: s.n0 = n0;
089: s.k = k;
090: return (s);
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.evalScaling(n0, k, j));
100: }
101:
102: /****************************************************
103: * Starting with dimension() scaling functions and
104: * going jfin scales ahead (iterating jfin times),
105: * tells you how many scaling functions you'll have.
106: * @param jfin number of iterations
107: ******************************************************/
108: public int dimension(int jfin) {
109: return (Cascades.dimension(n0, jfin, cdf.filtretype));
110: }
111:
112: /****************************************************
113: * Number of scaling functions at scale where this
114: * scaling function belongs.
115: *****************************************************/
116: public int dimension() {
117: return (dimension(0));
118: }
119:
120: /****************************************
121: * Tells you what is the number of this
122: * scaling function. Scaling functions are
123: * numbered from left to right with the
124: * one at the left boundary being noted 0.
125: *****************************************/
126: public int position() {
127: return (k);
128: }
129: }
|