public void TestIsomorph() { ////IsoMorph byte[] matrixOrg = new byte[] { (byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e', (byte)'f', (byte)'g', (byte)'h', (byte)'i', (byte)'j', (byte)'k', (byte)'l', (byte)'m', (byte)'n', (byte)'o', (byte)'p', (byte)'q', (byte)'r', (byte)'s', (byte)'t', (byte)'u', (byte)'v', (byte)'w', (byte)'x', (byte)'y' }; //IsomorphMatrices im = new IsomorphMatrices(5,1,matrixOrg,matrixMod); uint[] substitution = new uint[] { 1, 0, 3, 4, 2 }; BasicMatrix bm = new BasicMatrix(5, 1, matrixOrg); Task t = bm.Transposition(substitution); t.Wait(); byte[] matrixMod = bm.GetMatrix(); IsomorphMatrices im = new IsomorphMatrices(5, 1, matrixOrg, matrixMod); uint[] substitution2 = new uint[] { 0, 1, 2, 3, 4 }; Task tt = im.SearchIsomorph(1, substitution2); tt.Wait(); uint count = im.GetSubstitutionsCount(); Assert.AreEqual(count, (uint)1); uint[] a = im.GetSubstitutions(0); Assert.IsTrue(a.SequenceEqual(new uint[] { 1, 0, 3, 4, 2 })); }
public void TestIsomophImg() { ////IsoMorph MainWindow mw = new MainWindow(); byte[] matrixOrg = mw.ImageSourceToByteArray(); uint mtxSize = (uint)Math.Sqrt(matrixOrg.Length / 4); //IsomorphMatrices im = new IsomorphMatrices(5,1,matrixOrg,matrixMod); uint[] substitution = new uint[mtxSize]; for (int i = 0; i < substitution.Length; ++i) { substitution[i] = (uint)((i + 1) % (substitution.Length)); } BasicMatrix bm = new BasicMatrix(mtxSize, 4, matrixOrg); Task t = bm.Transposition(substitution); t.Wait(); byte[] matrixMod = bm.GetMatrix(); IsomorphMatrices im = new IsomorphMatrices(mtxSize, 4, matrixOrg, matrixMod); uint[] substitution2 = new uint[mtxSize]; for (int i = 0; i < substitution2.Length; ++i) { substitution2[i] = (uint)i; } Task tt = im.SearchIsomorph(1, substitution2); tt.Wait(); uint count = im.GetSubstitutionsCount(); string s = ""; for (uint i = 0; i < count; i++) { uint[] a = im.GetSubstitutions(i); s += String.Join(",", a) + "\n";; } s = "IsomorphMatrices Test:\n" + s; MessageBox.Show(s); }