lsf.setPreconditioner(true); float pavg = sum(p)/n1/n2; float[][] r = sub(p,pavg);
lsf.setPreconditioner(true); float pavg = sum(p)/n1/n2/n3; float[][][] r = sub(p,pavg);
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); } }