@Test public void elementMultConjB() { InterleavedF64 a = new InterleavedF64(width, height, 2); InterleavedF64 b = new InterleavedF64(width, height, 2); InterleavedF64 c = new InterleavedF64(width, height, 2); ImageMiscOps.fillUniform(a, rand, -10, 10); ImageMiscOps.fillUniform(b, rand, -10, 10); ImageMiscOps.fillUniform(c, rand, -10, 10); CirculantTracker.elementMultConjB(a, b, c); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { Complex64F aa = new Complex64F(a.getBand(x, y, 0), a.getBand(x, y, 1)); Complex64F bb = new Complex64F(b.getBand(x, y, 0), b.getBand(x, y, 1)); Complex64F cc = new Complex64F(); ComplexMath64F.conj(bb, bb); ComplexMath64F.mult(aa, bb, cc); double foundReal = c.getBand(x, y, 0); double foundImg = c.getBand(x, y, 1); assertEquals(cc.real, foundReal, 1e-4); assertEquals(cc.imaginary, foundImg, 1e-4); } } }
@Test public void computeAlphas() { InterleavedF64 yf = new InterleavedF64(width, height, 2); InterleavedF64 kf = new InterleavedF64(width, height, 2); InterleavedF64 alphaf = new InterleavedF64(width, height, 2); ImageMiscOps.fillUniform(yf, rand, -10, 10); ImageMiscOps.fillUniform(kf, rand, -10, 10); ImageMiscOps.fillUniform(alphaf, rand, -10, 10); float lambda = 0.01f; CirculantTracker.computeAlphas(yf, kf, lambda, alphaf); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { Complex64F a = new Complex64F(yf.getBand(x, y, 0), yf.getBand(x, y, 1)); Complex64F b = new Complex64F(kf.getBand(x, y, 0) + lambda, kf.getBand(x, y, 1)); Complex64F c = new Complex64F(); ComplexMath64F.div(a, b, c); double foundReal = alphaf.getBand(x, y, 0); double foundImg = alphaf.getBand(x, y, 1); assertEquals(c.real, foundReal, 1e-4); assertEquals(c.imaginary, foundImg, 1e-4); } } }