1 2 package JSci.maths.wavelet.splines; 3 4 import JSci.maths.wavelet.*; 5 import JSci.maths.*; 6 7 14 public class QuadraticSpline extends Spline implements Filter, Cloneable { 15 protected final static int filtretype=2; 16 private double[] vecteur; 17 static final double[] vg={1/4d,3/4d,3/4d,1/4d}; 18 static final double[] v0={3/4d,1/4d}; 19 20 24 public String toString() { 25 return(ArrayMath.toString(vecteur)); 26 } 27 40 public int getFilterType () { 41 return(filtretype); 42 } 43 44 48 public boolean equals(Object a) { 49 if(a!=null && (a instanceof QuadraticSpline) && vecteur.length==((QuadraticSpline)a).dimension()) { 50 QuadraticSpline iv=(QuadraticSpline)a; 51 for(int i=0;i<vecteur.length;i++) { 52 if(vecteur[i]!=iv.getValue(i)) 53 return false; 54 } 55 return true; 56 } else 57 return false; 58 } 59 60 70 public int previousDimension (int k) { 71 return(Cascades.previousDimension(filtretype,k)); 72 } 73 74 81 public double[] lowpass (double[] v, double[] param) { 82 return(lowpass(v)); 83 } 84 85 86 94 public double[] highpass (double[] v, double[] param) { 95 return(highpass(v)); 96 } 97 98 99 106 public double[] lowpass (double[] gete) { 107 if(gete.length<3) { 108 throw new IllegalArgumentException ("The array is not long enough : "+gete.length+" < 3"); 109 } 110 double[] sortie=new double[2*gete.length-2]; 111 for(int k=1;k<gete.length-1;k++) { 112 sortie[2*k-2]+=gete[k]*vg[0]; 113 sortie[2*k-1]+=gete[k]*vg[1]; 114 sortie[2*k]+=gete[k]*vg[2]; 115 sortie[2*k+1]+=gete[k]*vg[3]; 116 } 117 sortie[0]+=v0[0]*gete[0]; 118 sortie[1]+=v0[1]*gete[0]; 119 sortie[sortie.length-1]+=v0[0]*gete[gete.length-1]; 120 sortie[sortie.length-2]+=v0[1]*gete[gete.length-1]; 121 return(sortie); 122 } 123 124 132 public double[] highpass (double[] gete) { 133 return(lowpass(gete)); 134 } 135 136 138 public QuadraticSpline(double[] v) { 139 vecteur=v; 140 } 141 142 143 145 public QuadraticSpline() { 146 } 147 150 public Object clone() { 151 QuadraticSpline sod=(QuadraticSpline) super.clone(); 152 if(vecteur!=null) 153 sod.vecteur=ArrayMath.copy(this.vecteur); 154 return(sod); 155 } 156 157 163 public double getValue(int i) { 164 if ((i<0) || (i>vecteur.length-1)) { 165 throw new IllegalArgumentException ("Parameter incorrect : "+i+", "+vecteur.length); 166 } 167 return(vecteur[i]); 168 } 169 170 176 public void setValue(int i, double d) { 177 if (i<0) { 178 throw new IllegalArgumentException ("The parameter must be positive : "+i); 179 } 180 vecteur[i]=d; 181 } 182 183 187 public void setValues(double[] v) { 188 vecteur=v; 189 } 190 191 195 public LinearSpline derive() { 196 return(this.derive(0,1)); 197 } 198 199 205 public LinearSpline derive(double a, double b) { 206 double[] v=new double[vecteur.length-1]; 207 for(int i=0;i<vecteur.length-1;i++) { 208 v[i]=2*(vecteur[i+1]-vecteur[i])*vecteur.length/Math.abs(b-a); 209 } 210 return(new LinearSpline(v)); 211 } 212 213 216 public int dimension () { 217 return(vecteur.length); 218 } 219 220 224 public int dimension(int j) { 225 return(Cascades.dimension(vecteur.length,j,filtretype)); 226 } 227 228 238 public double[] interpolate(int j) { 239 if (j<0) { 240 throw new IllegalArgumentException ("This parameter must be postive : "+j); 241 } 242 return(Cascades.evaluation(this,j,vecteur)); 243 } 244 245 250 public double[] evaluate (int j) { 251 return(interpolate(j)); 252 } 253 254 255 } 256 | Popular Tags |