/** * Constructs a local smoothing filter with specified iteration parameters. * Uses a default 2x2 stencil for the derivatives in the operator G. * @param small stop when norm of residuals is less than this factor * times the norm of the input array. * @param niter stop when number of iterations exceeds this limit. */ public LocalSmoothingFilter(double small, int niter) { _small = (float)small; _niter = niter; _ldk = new LocalDiffusionKernel(LocalDiffusionKernel.Stencil.D22); }
public void apply(float[][][] x, float[][][] y) { scopy(x,y); _ldk.apply(_d,_c,_s,x,y); } private LocalDiffusionKernel _ldk;
private void apply( int i3, Tensors3 d, float c, float[][][] s, float[][][] x, float[][][] y) { if (_stencil==Stencil.D21) { apply21(i3,c,s,x,y); } else if (_stencil==Stencil.D22) { apply22(i3,d,c,s,x,y); } else if (_stencil==Stencil.D24) { //apply24(i3,d,c,s,x,y); throw new UnsupportedOperationException( "Stencil.D24 not supported for 3D arrays"); } else if (_stencil==Stencil.D33) { apply33(i3,d,c,s,x,y); } else if (_stencil==Stencil.D71) { apply71(i3,d,c,s,x,y); } else if (_stencil==Stencil.D91) { //apply91(i3,d,c,s,x,y); throw new UnsupportedOperationException( "Stencil.D91 not supported for 3D arrays"); } }
d = IDENTITY_TENSORS2; if (_stencil==Stencil.D21) { apply21(c,s,x,y); } else if (_stencil==Stencil.D22) { apply22(d,c,s,x,y); } else if (_stencil==Stencil.D24) { apply24(d,c,s,x,y); } else if (_stencil==Stencil.D33) { apply33(d,c,s,x,y); } else if (_stencil==Stencil.D71) { apply71(d,c,s,x,y); } else if (_stencil==Stencil.D91) { apply91(d,c,s,x,y);
for (int i=0; i<stencils.length; ++i) { System.out.println(stencilNames[i]); LocalDiffusionKernel ldf = new LocalDiffusionKernel(stencils[i]); int niter; double maxtime = 5.0; sw.restart(); for (niter=0; sw.time()<maxtime; ++niter) ldf.apply(d,0.5f,s,x,y); sw.stop(); float sum = sum(y);
applyParallel(i3start,i3step,i3stop,d,c,s,x,y); } else { applySerial(i3start,1,i3stop,d,c,s,x,y);
for (int i=0; i<stencils.length; ++i) { System.out.println(stencilNames[i]); LocalDiffusionKernel ldf = new LocalDiffusionKernel(stencils[i]); int niter; double maxtime = 5.0; sw.restart(); for (niter=0; sw.time()<maxtime; ++niter) ldf.apply(d,0.5f,s,x,y); sw.stop(); float sum = sum(y);
/** * Applies this filter for specified tensor coefficients and scale factor. * @param d tensor coefficients. * @param c constant scale factor for tensor coefficients. * @param x input array. * @param y output array. */ public void apply(Tensors2 d, float c, float[][] x, float[][] y) { apply(d,c,null,x,y); }
public void testD22() { LocalDiffusionKernel ldk = new LocalDiffusionKernel(LocalDiffusionKernel.Stencil.D22); testSpd2(ldk); testSpd3(ldk); testSpd2RandomTensors(ldk); }
/** * Applies this filter for specified scale factors. * Uses a constant isotropic identity tensor. * @param c constant scale factor for tensor coefficients. * @param s array of scale factors for tensor coefficients. * @param x input array. * @param y output array. */ public void apply(float c, float[][][] s, float[][][] x, float[][][] y) { apply(null,c,s,x,y); }
public void testD21() { LocalDiffusionKernel ldk = new LocalDiffusionKernel(LocalDiffusionKernel.Stencil.D21); testSpd2(ldk); testSpd3(ldk); /* float[][] s = fillfloat(1.0f,5,5); float[][] x = zerofloat(5,5); float[][] y = zerofloat(5,5); //s[1][1] = 2.0f; s[1][2] = 2.0f; s[1][3] = 2.0f; //s[2][1] = 2.0f; s[2][2] = 2.0f; s[2][3] = 2.0f; //s[3][1] = 2.0f; s[3][2] = 2.0f; s[3][3] = 2.0f; s[2][2] = 2.0f; x[0][0] = 1.0f; x[0][4] = 1.0f; x[4][0] = 1.0f; x[4][4] = 1.0f; x[2][2] = 1.0f; ldk.apply(1.0f,s,x,y); dump(x); dump(y); */ } public void testD22() {
/** * Applies this filter for constant isotropic identity tensor. * @param x input array. * @param y output array. */ public void apply(float[][] x, float[][] y) { apply(null,1.0f,x,y); }
/** * Applies this filter for specified tensor coefficients and scale factor. * @param d tensor coefficients. * @param c constant scale factor for tensor coefficients. * @param x input array. * @param y output array. */ public void apply(Tensors3 d, float c, float[][][] x, float[][][] y) { apply(d,c,null,x,y); }
public void apply(float[][] x, float[][] y) { scopy(x,y); _ldk.apply(_d,_c,_s,x,y); } private LocalDiffusionKernel _ldk;
/** * Applies this filter for specified tensor coefficients. * @param d tensor coefficients. * @param x input array. * @param y output array. */ public void apply(Tensors2 d, float[][] x, float[][] y) { apply(d,1.0f,x,y); }
/** * Applies this filter for specified scale factor. * Uses a constant isotropic identity tensor. * @param c constant scale factor for tensor coefficients. * @param x input array. * @param y output array. */ public void apply(float c, float[][] x, float[][] y) { apply(null,c,null,x,y); }
/** * Applies this filter for specified scale factor. * Uses a constant isotropic identity tensor. * @param c constant scale factor for tensor coefficients. * @param x input array. * @param y output array. */ public void apply(float c, float[][][] x, float[][][] y) { apply(null,c,null,x,y); }
/** * Applies this filter for specified scale factors. * Uses a constant isotropic identity tensor. * @param c constant scale factor for tensor coefficients. * @param s array of scale factors for tensor coefficients. * @param x input array. * @param y output array. */ public void apply(float c, float[][] s, float[][] x, float[][] y) { apply(null,c,s,x,y); }
/** * Applies this filter for a constant isotropic identity tensor. * @param x input array. * @param y output array. */ public void apply(float[][][] x, float[][][] y) { apply(null,1.0f,x,y); }
/** * Applies this filter for specified tensor coefficients. * @param d tensor coefficients. * @param x input array. * @param y output array. */ public void apply(Tensors3 d, float[][][] x, float[][][] y) { apply(d,1.0f,x,y); }