1 package JSci.maths; 2 3 9 public final class WaveletMath extends AbstractMath { 10 private WaveletMath() {} 11 12 20 public static Complex[] downsample(Complex filter[], Complex data[]) { 21 int loc=filter.length; 22 int demiloc=Math.round(loc/2f-0.5f); 23 int Nombre=data.length; 24 int DemiNombre=Math.round(Nombre/2f-0.5f); 25 Complex answer[]=new Complex[DemiNombre]; 26 for(int i=0;i<DemiNombre;i++) { 27 answer[i]=Complex.ZERO; 28 for(int j=Math.max(0,2*i-demiloc+1);j<Math.min(Nombre,2*i+loc-demiloc+1);j++) 29 answer[i]=answer[i].add(data[j].multiply(filter[j-2*i+demiloc-1])); 30 } 31 return answer; 32 } 33 41 public static double[] downsample(double filter[], double data[]) { 42 int loc=filter.length; 43 int demiloc=Math.round(loc/2f-0.5f); 44 int Nombre=data.length; 45 int DemiNombre=Math.round(Nombre/2f-0.5f); 46 double answer[]=new double[DemiNombre]; 47 for(int i=0;i<DemiNombre;i++) { 48 answer[i]=0.0; 49 for(int j=Math.max(0,2*i-demiloc+1);j<Math.min(Nombre,2*i+loc-demiloc+1);j++) 50 answer[i]+=data[j]*filter[j-2*i+demiloc-1]; 51 } 52 return answer; 53 } 54 58 public static Complex[] upsample(Complex data[]) { 59 int Nombre=data.length; 60 Complex answer[]=new Complex[2*Nombre]; 61 for(int i=0;i<Nombre;i++) { 62 answer[2*i]=data[i]; 63 answer[2*i+1]=Complex.ZERO; 64 } 65 return answer; 66 } 67 71 public static double[] upsample(double data[]) { 72 int Nombre=data.length; 73 double answer[]=new double[2*Nombre]; 74 for(int i=0;i<Nombre;i++) { 75 answer[2*i]=data[i]; 76 answer[2*i+1]=0.0; 77 } 78 return answer; 79 } 80 87 public static Complex[] upsample(Complex filter[], Complex data[]) { 88 int loc=filter.length; 89 int demiloc=Math.round(loc/2f-0.5f); 90 int Nombre=data.length; 91 Complex answer[]=new Complex[2*Nombre]; 92 Complex tmp[]=new Complex[2*Nombre]; 93 tmp=upsample(data); 94 for(int i=0;i<2*Nombre;i++) { 95 answer[i]=Complex.ZERO; 96 for(int j=Math.max(0,i-demiloc);j<Math.min(2*Nombre,i+loc-demiloc);j++) 97 answer[i]=answer[i].add(tmp[j].multiply(filter[i+loc-demiloc-j-1])); 98 } 99 return answer; 100 } 101 108 public static double[] upsample(double filter[], double data[]) { 109 int loc=filter.length; 110 int demiloc=Math.round(loc/2f-0.5f); 111 int Nombre=data.length; 112 double answer[]=new double[2*Nombre]; 113 double tmp[]=new double[2*Nombre]; 114 tmp=upsample(data); 115 for(int i=0;i<2*Nombre;i++) { 116 answer[i]=0.0; 117 for(int j=Math.max(0,i-demiloc);j<Math.min(2*Nombre,i+loc-demiloc);j++) 118 answer[i]+=tmp[j]*filter[i+loc-demiloc-j-1]; 119 } 120 return answer; 121 } 122 126 public static double[] lowToHigh(double v[]) { 127 double ans[]=ArrayMath.invert(v); 128 int b=1; 129 for(int k=0;k<ans.length;k++) { 130 ans[k]=b*ans[k]; 131 b=-b; 132 } 133 return ans; 134 } 135 } 136 137 | Popular Tags |