public void apply(float[][][] x, float[][][] y) { scopy(x,y); _ldk.apply(_d,_c,_s,x,y); } private LocalDiffusionKernel _ldk;
/** * 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 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); }
/** * 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 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); }
private void applySerial( int i3start, int i3step, int i3stop, Tensors3 d, float c, float[][][] s, float[][][] x, float[][][] y) { for (int i3=i3start; i3<i3stop; i3+=i3step) apply(i3,d,c,s,x,y); }
public void apply(float[][] x, float[][] y) { int n1 = x[0].length; int n2 = x.length; // z = Mx for (int i2=0; i2<n2; ++i2) for (int i1=0; i1<n1; ++i1) _z[i2][i1] = _m[i2][i1]?x[i2][i1]:0.0f; // y = G'DGz szero(y); _ldk.apply(_d,_z,y); // z = (G'DG+tI)y mul(_t,y,_z); _ldk.apply(_d,y,_z); // y = (I-M)x + Mz for (int i2=0; i2<n2; ++i2) for (int i1=0; i1<n1; ++i1) y[i2][i1] = _m[i2][i1]?_z[i2][i1]:x[i2][i1]; } public void applyRhs(float[][] x, float[][] y) {
public void applyRhs(float[][] x, float[][] y) { int n1 = x[0].length; int n2 = x.length; // z = (I-M)x for (int i2=0; i2<n2; ++i2) for (int i1=0; i1<n1; ++i1) _z[i2][i1] = _m[i2][i1]?0.0f:x[i2][i1]; // y = G'DGz szero(y); _ldk.apply(_d,_z,y); // z = (G'DG+tI)y mul(_t,y,_z); _ldk.apply(_d,y,_z); // y = (I-M)x - Mz for (int i2=0; i2<n2; ++i2) for (int i1=0; i1<n1; ++i1) y[i2][i1] = _m[i2][i1]?-_z[i2][i1]:x[i2][i1]; } private LocalDiffusionKernel _ldk;
public void applyRhs(float[][] x, float[][] y) { int n1 = x[0].length; int n2 = x.length; // z = (I-M)x for (int i2=0; i2<n2; ++i2) for (int i1=0; i1<n1; ++i1) _z[i2][i1] = _m[i2][i1]?0.0f:x[i2][i1]; // y = G'DGz szero(y); _ldk.apply(_d,_z,y); // z = (G'DG+tI)y mul(_t,y,_z); _ldk.apply(_d,y,_z); // y = (I-M)x-Mz for (int i2=0; i2<n2; ++i2) for (int i1=0; i1<n1; ++i1) y[i2][i1] = _m[i2][i1]?-_z[i2][i1]:x[i2][i1]; // y = S'y smoothS(y,y); } private LocalDiffusionKernel _ldk;
public void apply(float[][] x, float[][] y) { int n1 = x[0].length; int n2 = x.length; // w = Sx smoothS(x,_w); // z = Mw for (int i2=0; i2<n2; ++i2) for (int i1=0; i1<n1; ++i1) _z[i2][i1] = _m[i2][i1]?_w[i2][i1]:0.0f; // y = G'DGz szero(y); _ldk.apply(_d,_z,y); // z = (G'DG+tI)y mul(_t,y,_z); _ldk.apply(_d,y,_z); // y = (I-M)w + Mz for (int i2=0; i2<n2; ++i2) for (int i1=0; i1<n1; ++i1) y[i2][i1] = _m[i2][i1]?_z[i2][i1]:_w[i2][i1]; // y = S'y smoothS(y,y); } public void applyRhs(float[][] x, float[][] y) {
private static void testSpd2(LocalDiffusionKernel ldk) { int n1 = 5; int n2 = 6; 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); ldk.apply(1.0f,s,x,dx); ldk.apply(1.0f,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); } } private static void testSpd2RandomTensors(LocalDiffusionKernel ldk) {
private static void testSpd3(LocalDiffusionKernel ldk) { int n1 = 5; int n2 = 6; int n3 = 7; for (int iter=0; iter<10; ++iter) { float[][][] s = randfloat(n1,n2,n3); float[][][] x = sub(randfloat(n1,n2,n3),0.5f); float[][][] y = sub(randfloat(n1,n2,n3),0.5f); float[][][] dx = zerofloat(n1,n2,n3); float[][][] dy = zerofloat(n1,n2,n3); ldk.apply(null,1.0f,s,x,dx); ldk.apply(null,1.0f,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); } } private static float dot(float[][] x, float[][] y) {
private static void testSpd2RandomTensors(LocalDiffusionKernel ldk) { int n1 = 5; int n2 = 6; 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 t = new RandomTensors2(n1,n2); ldk.apply(t,1.0f,s,x,dx); ldk.apply(t,1.0f,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); } } private static void testSpd3(LocalDiffusionKernel ldk) {