/** * Applies this filter. * @param x input array. * @return filtered array. */ public float[] apply(float[] x) { float[] y = new float[x.length]; apply(x,y); return y; }
/** * Applies this filter. * @param x input array. * @return filtered array. */ public float[][] apply(float[][] x) { float[][] y = new float[x.length][x[0].length]; apply(x,y); return y; }
/** * Applies this filter. * @param x input array. * @return filtered array. */ public float[][][] apply(float[][][] x) { float[][][] y = new float[x.length][x[0].length][x[0][0].length]; apply(x,y); return y; }
/** * Applies this filter. * Input and output arrays may be the same array. * @param x input array. * @param y output filtered array. */ public void apply(float[][][] x, float[][][] y) { updateFilter3(); _ff3.apply(x,y); }
/** * Applies this filter. * Input and output arrays may be the same array. * @param x input array. * @param y output filtered array. */ public void apply(float[][] x, float[][] y) { updateFilter2(); _ff2.apply(x,y); }
/** * Applies this filter. * Input and output arrays may be the same array. * @param x input array. * @param y output filtered array. */ public void apply(float[] x, float[] y) { updateFilter1(); _ff1.apply(x,y); }
float[][][] z = randfloat(nz1,nz2,nz3); FftFilter ff = new FftFilter(kh1,kh2,kh3,h); ff.apply(x,y); Conv.conv(nh1,nh2,nh3,-kh1,-kh2,-kh3,h, nx1,nx2,nx3,0,0,0,x,
public void test2Random() { int ntest = 1000; int nmin = 1; int nmax = 8; for (int itest=0; itest<ntest; ++itest) { int nh1 = nmin+_random.nextInt(1+nmax-nmin); int nh2 = nmin+_random.nextInt(1+nmax-nmin); int nx1 = nmin+_random.nextInt(1+nmax-nmin); int nx2 = nmin+_random.nextInt(1+nmax-nmin); int ny1 = nx1; int ny2 = nx2; int nz1 = nx1; int nz2 = nx2; int kh1 = _random.nextInt(nh1); int kh2 = _random.nextInt(nh2); float[][] h = randfloat(nh1,nh2); float[][] x = randfloat(nx1,nx2); float[][] y = randfloat(ny1,ny2); float[][] z = randfloat(nz1,nz2); FftFilter ff = new FftFilter(kh1,kh2,h); ff.apply(x,y); Conv.conv(nh1,nh2,-kh1,-kh2,h,nx1,nx2,0,0,x,nz1,nz2,0,0,z); assertEquals(z,y); } }
public void test1Random() { int ntest = 1000; int nmin = 1; int nmax = 8; for (int itest=0; itest<ntest; ++itest) { int nh = nmin+_random.nextInt(1+nmax-nmin); int nx = nmin+_random.nextInt(1+nmax-nmin); int ny = nx; int nz = nx; int kh = _random.nextInt(nh); float[] h = randfloat(nh); float[] x = randfloat(nx); float[] y = randfloat(ny); float[] z = randfloat(nz); FftFilter ff = new FftFilter(kh,h); ff.apply(x,y); Conv.conv(nh,-kh,h,nx,0,x,nz,0,z); assertEquals(z,y); } }