/** * Applies this filter for specified constant scale factor. * Local smoothing for 1D arrays is a special case that requires no tensors. * All tensors are implicitly scalar values equal to one, so that filtering * is determined entirely by the specified constant scale factor. * @param c constant scale factor. * @param x input array. * @param y output array. */ public void apply(float c, float[] x, float[] y) { apply(c,null,x,y); }
public void apply( Direction2 d, EigenTensors2 t, float[][] f, float[][] g) { if (_scale==0.0f) { copy(f,g); } else { int n1 = f[0].length; int n2 = f.length; float[][] au = new float[n2][n1]; float[][] av = new float[n2][n1]; float[][] sf = new float[n2][n1]; t.getEigenvalues(au,av); setEigenvalues(d,t); _lsf.applySmoothL(_kmax,f,sf); //_lsf.applySmoothS(f,sf); _lsf.apply(t,_scale,sf,g); t.setEigenvalues(au,av); } } public void apply(
lsf.apply(_tensors,_c,s,r,q); add(q,pavg,q);
/** * Applies this filter for specified tensors. * @param d tensors. * @param x input array. * @param y output array. */ public void apply(Tensors2 d, float[][] x, float[][] y) { apply(d,1.0f,null,x,y); }
public void apply( Direction3 d, EigenTensors3 t, float[][][] f, float[][][] g) { if (_scale==0.0f) { copy(f,g); } else { int n1 = f[0][0].length; int n2 = f[0].length; int n3 = f.length; float[][][] au = new float[n3][n2][n1]; float[][][] av = new float[n3][n2][n1]; float[][][] aw = new float[n3][n2][n1]; float[][][] sf = new float[n3][n2][n1]; t.getEigenvalues(au,av,aw); setEigenvalues(d,t); _lsf.applySmoothL(_kmax,f,sf); //_lsf.applySmoothS(f,sf); _lsf.apply(t,_scale,sf,g); t.setEigenvalues(au,av,aw); } } private float _scale;
lsf.apply(_tensors,_c,s,r,q); add(q,pavg,q);
/** * Applies this filter for identity tensors and specified scale factors. * @param c constant scale factor. * @param s array of scale factors. * @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 specified tensors and scale factor. * @param d tensors. * @param c constant scale factor for tensors. * @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); }
/** * Applies this filter for identity tensors. * @param x input array. * @param y output array. */ public void apply(float[][][] x, float[][][] y) { apply(null,1.0f,null,x,y); }
/** * Applies this filter for identity tensors and specified scale factor. * @param c constant scale factor. * @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 identity tensors. * @param x input array. * @param y output array. */ public void apply(float[][] x, float[][] y) { apply(null,1.0f,null,x,y); }
/** * Applies this filter for identity tensors and specified scale factor. * @param c constant scale factor. * @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 tensors. * @param d tensors. * @param x input array. * @param y output array. */ public void apply(Tensors3 d, float[][][] x, float[][][] y) { apply(d,1.0f,null,x,y); }
/** * Applies this filter for identity tensors and specified scale factors. * @param c constant scale factor. * @param s array of scale factors. * @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 specified tensors and scale factor. * @param d tensors. * @param c constant scale factor for tensors. * @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 apply(float[] f, float[] g) { if (_scale==0.0f) { copy(f,g); } else { _lsf.apply(_scale,f,g); } } public void apply(
public void testSpd2() { int n1 = 5; int n2 = 6; LocalSmoothingFilter lsf = new LocalSmoothingFilter(1.0e-6,1000); lsf.setPreconditioner(true); for (int iter=0; iter<10; ++iter) { float[][] s = randfloat(n1,n2); float[][] x = sub(randfloat(n1,n2),0.5f); float[][] y = sub(randfloat(n1,n2),0.5f); float[][] dx = zerofloat(n1,n2); float[][] dy = zerofloat(n1,n2); Tensors2 d = new RandomTensors2(n1,n2); float c = 10.0f*s[n2/2][n1/2]; lsf.apply(d,c,s,x,dx); lsf.apply(d,c,s,y,dy); float xdx = dot(x,dx); float ydy = dot(y,dy); float ydx = dot(y,dx); float xdy = dot(x,dy); assertTrue(xdx>=0.0f); assertTrue(ydy>=0.0f); assertEquals(xdy,ydx,0.0001); } }