1 package JSci.tests; 2 3 import JSci.maths.WaveletMath; 4 5 9 public class WaveletTest extends junit.framework.TestCase { 10 public static void main(String arg[]) { 11 junit.textui.TestRunner.run(WaveletTest.class); 12 } 13 public WaveletTest(String name) { 14 super(name); 15 } 16 protected void setUp() { 17 JSci.GlobalSettings.ZERO_TOL=1.0e-6; 18 } 19 25 public void testReconstruction() { 26 double[] data={0,0,0,1,0,0,0,0}; 27 double[] filter={0.48296291314,0.8365163037,0.224143868,-0.12940952255126}; 28 double[] lowpass=WaveletMath.downsample(filter,data); 29 double[] filterh={-0.12940952255126,-0.224143868,0.8365163037,-0.48296291314}; 30 double[] highpass=WaveletMath.downsample(filterh,data); 31 double[] reconstlow=WaveletMath.upsample(filter,lowpass); 32 double[] reconsthigh=WaveletMath.upsample(filterh,highpass); 33 double[] reconst=new double[data.length]; 34 for(int i=0;i<data.length;i++) { 35 reconst[i]=reconstlow[i]+reconsthigh[i]; 36 assertEquals(data[i], reconst[i], JSci.GlobalSettings.ZERO_TOL); 37 } 38 } 39 43 public void testLagrange() { 44 double[] data={0,0,1,0,0}; 45 double[] filter={-0.0625,0,0.5625,0,1,0,0.5625,0,-0.0625}; 46 double[] interpol=WaveletMath.upsample(filter,data); 47 for(int i=0;i<data.length;i++) 48 assertEquals(filter[i], interpol[i], JSci.GlobalSettings.ZERO_TOL); 49 } 50 } 51 52 | Popular Tags |