public void test3Random() { java.util.Random r = new java.util.Random(); int ntest = 1000; for (int itest = 0; itest < ntest; ++itest) { SymmetricTridiagonalFilter stf = makeRandomFilter(); boolean inplace = r.nextBoolean(); // apply in-place? int n1 = 2 + r.nextInt(11); int n2 = 2 + r.nextInt(12); int n3 = 2 + r.nextInt(13); float[][][] t = randfloat(r, n1, n2, n3); float[][][] x = copy(t); float[][][] y = inplace ? x : zerofloat(n1, n2, n3); float[][][] z = inplace ? x : zerofloat(n1, n2, n3); stf.apply1(x, y); stf.applyInverse1(y, z); assertEqual(t, x); assertEqual(t, z); stf.apply2(x, y); stf.applyInverse2(y, z); assertEqual(t, x); assertEqual(t, z); stf.apply3(x, y); stf.applyInverse3(y, z); assertEqual(t, x); assertEqual(t, z); } }
public void test2Simple() { int n1 = 5; int n2 = 4; double af, ai, al, b; // af = al = 0.50; // zero-value af = al = 0.75; // zero-slope ai = 0.50; b = 0.25; SymmetricTridiagonalFilter f = new SymmetricTridiagonalFilter(af, ai, al, b); float[][] x = zerofloat(n1, n2); float[][] y = zerofloat(n1, n2); float[][] z = zerofloat(n1, n2); fill(1.0f, x); // x[n2/2][n1/2] = 1.0f; f.apply1(x, y); f.apply2(y, y); f.applyInverse1(y, z); f.applyInverse2(z, z); // dump(x); dump(y); dump(z); assertEqual(x, z); }