float[][][] y = randfloat(ny1,ny2,ny3); 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,
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); } }
private void updateFilter1() { if (_ff1==null) { KaiserWindow kw = KaiserWindow.fromErrorAndWidth(_aerror,_kwidth); int nh = ((int)kw.getLength()+1)/2*2+1; int nh1 = nh; int kh1 = (nh1-1)/2; _h1 = new float[nh1]; double kus = 2.0*_kupper; double kls = 2.0*_klower; for (int i1=0; i1<nh1; ++i1) { double x1 = i1-kh1; double w1 = kw.evaluate(x1); double r = x1; double kur = 2.0*_kupper*r; double klr = 2.0*_klower*r; _h1[i1] = (float)(w1*(kus*h1(kur)-kls*h1(klr))); } _ff1 = new FftFilter(_h1); _ff1.setExtrapolation(ffExtrap(_extrapolation)); _ff1.setFilterCaching(_filterCaching); } }
private void updateFilter2() { if (_ff2==null) { KaiserWindow kw = KaiserWindow.fromErrorAndWidth(_aerror,_kwidth); int nh = ((int)kw.getLength()+1)/2*2+1; int nh1 = nh; int nh2 = nh; int kh1 = (nh1-1)/2; int kh2 = (nh2-1)/2; _h2 = new float[nh2][nh1]; double kus = 4.0*_kupper*_kupper; double kls = 4.0*_klower*_klower; for (int i2=0; i2<nh2; ++i2) { double x2 = i2-kh2; double w2 = kw.evaluate(x2); for (int i1=0; i1<nh1; ++i1) { double x1 = i1-kh1; double w1 = kw.evaluate(x1); double r = sqrt(x1*x1+x2*x2); double kur = 2.0*_kupper*r; double klr = 2.0*_klower*r; _h2[i2][i1] = (float)(w1*w2*(kus*h2(kur)-kls*h2(klr))); } } _ff2 = new FftFilter(_h2); _ff2.setExtrapolation(ffExtrap(_extrapolation)); _ff2.setFilterCaching(_filterCaching); } }
_ff3 = new FftFilter(_h3); _ff3.setExtrapolation(ffExtrap(_extrapolation)); _ff3.setFilterCaching(_filterCaching);