private static void smoothS(float[][] x, float[][] y) { int n1 = x[0].length; int n2 = x.length; int n1m = n1-1; int n2m = n2-1; float[][] t = new float[3][n1]; scopy(x[0],t[0]); scopy(x[0],t[1]); for (int i2=0; i2<n2; ++i2) { int i2m = (i2>0)?i2-1:0; int i2p = (i2<n2m)?i2+1:n2m; int j2m = i2m%3; int j2 = i2%3; int j2p = i2p%3; scopy(x[i2p],t[j2p]); float[] x2m = t[j2m]; float[] x2p = t[j2p]; float[] x20 = t[j2]; float[] y2 = y[i2]; for (int i1=0; i1<n1; ++i1) { int i1m = (i1>0)?i1-1:0; int i1p = (i1<n1m)?i1+1:n1m; y2[i1] = 0.2500f*(x20[i1 ]) + 0.1250f*(x20[i1m]+x20[i1p]+x2m[i1 ]+x2p[i1 ]) + 0.0625f*(x2m[i1m]+x2m[i1p]+x2p[i1m]+x2p[i1p]); } } }
/** * Applies this filter for specified tensors and scale factors. * @param d tensors. * @param c constant scale factor for tensors. * @param s array of scale factors for tensors. * @param x input array. * @param y output array. */ public void apply( Tensors3 d, float c, float[][][] s, float[][][] x, float[][][] y) { Operator3 a = new A3(_ldk,d,c,s); scopy(x,y); if (_pc) { Operator3 m = new M3(d,c,s,x); solve(a,m,x,y); } else { solve(a,x,y); } }
/** * Applies this filter for specified tensors and scale factors. * @param d tensors. * @param c constant scale factor for tensors. * @param s array of scale factors for tensors. * @param x input array. * @param y output array. */ public void apply( Tensors2 d, float c, float[][] s, float[][] x, float[][] y) { Operator2 a = new A2(_ldk,d,c,s); scopy(x,y); if (_pc) { Operator2 m = new M2(d,c,s,x); solve(a,m,x,y); } else { solve(a,x,y); } }
float[][][] r = new float[n3][n2][n1]; float[][][] s = new float[n3][n2][n1]; scopy(b,r); a.apply(x,q); saxpy(-1.0f,q,r); // r = b-Ax float bnorm = sqrt(sdot(b,b)); float rnorm = sqrt(sdot(r,r)); float rnormSmall = bnorm*_small; scopy(s,d); // d = s float delta = sdot(r,s); // r's = r'Mr int iter; scopy(b,r); a.apply(x,q); saxpy(-1.0f,q,r); // r = b-Ax