public void TestBinCylinderSimilarity() { uint[][] cylinderValidities = { CylinderTestsHelper.ConvertArrayUintToBinary(GetValidities(CylinderTestsHelper.cylinderZerosValues)), CylinderTestsHelper.ConvertArrayUintToBinary(GetValidities(CylinderTestsHelper.cylinderOnesValues)), CylinderTestsHelper.ConvertArrayUintToBinary(GetValidities(CylinderTestsHelper.cylinderMixedValues)) }; // When var correlation0 = BinCylinderSimilarity.GetCylinderSimilarity( CylinderTestsHelper.linearizedCylinders[0], CylinderTestsHelper.linearizedCylinders[1], cylinderValidities[0], cylinderValidities[1], 0); var correlation1 = BinCylinderSimilarity.GetCylinderSimilarity( CylinderTestsHelper.linearizedCylinders[1], CylinderTestsHelper.linearizedCylinders[2], cylinderValidities[1], cylinderValidities[2], 0); var correlation2 = BinCylinderSimilarity.GetCylinderSimilarity( CylinderTestsHelper.linearizedCylinders[2], CylinderTestsHelper.linearizedCylinders[2], cylinderValidities[2], cylinderValidities[2], 0); var correlation3 = BinCylinderSimilarity.GetCylinderSimilarity( CylinderTestsHelper.linearizedCylinders[1], CylinderTestsHelper.linearizedCylinders[1], cylinderValidities[1], cylinderValidities[1], 0); // Then Assert.AreEqual(correlation0, 0.0); Assert.IsTrue(correlation1 > 0.5 && correlation1 < 1.0); // Around 0.65 is a correct value Assert.AreEqual(correlation2, 1.0); Assert.AreEqual(correlation3, 1.0); Console.WriteLine(correlation0 + "; " + correlation1 + "; " + correlation2 + "; " + correlation3); }
public static void ParseQuery(string path) { using (var file = new StreamReader(path)) { Cylinder[] queryCylinders = new Cylinder[Int32.Parse(file.ReadLine())]; file.ReadLine(); file.ReadLine(); for (int i = 0; i < queryCylinders.Length; i++) { Cylinder curCylinder = new Cylinder(); string curCylinderString = file.ReadLine(); uint[] curCylinderUInt = new uint[curCylinderString.Length]; for (int j = 0; j < curCylinderUInt.Length; j++) { curCylinderUInt[j] = UInt32.Parse(curCylinderString[j].ToString()); } curCylinder.Values = CylinderTestsHelper.ConvertArrayUintToBinary(curCylinderUInt); curCylinder.Angle = Double.Parse(file.ReadLine()); curCylinder.Norm = Double.Parse(file.ReadLine()); queryCylinders[i] = curCylinder; file.ReadLine(); } query = new Template(queryCylinders); } }
public static void ParseDb(string path) { using (var file = new StreamReader(path)) { string[] templateDbLengthsString = file.ReadLine().Split(new Char[] { ' ' }); templateDbLengths = new int[templateDbLengthsString.Length]; for (int i = 0; i < templateDbLengthsString.Length; i++) { templateDbLengths[i] = Int32.Parse(templateDbLengthsString[i]); } string[] templateIndicesString = file.ReadLine().Split(new Char[] { ' ' }); templateIndices = new uint[templateIndicesString.Length]; for (int i = 0; i < templateIndicesString.Length; i++) { templateIndices[i] = UInt32.Parse(templateIndicesString[i]); } file.ReadLine(); contiguousCylinders = new Cylinder[templateIndices.Length]; for (int i = 0; i < templateIndices.Length; i++) { Cylinder curCylinder = new Cylinder(); string curCylinderString = file.ReadLine(); uint[] curCylinderUInt = new uint[curCylinderString.Length]; for (int j = 0; j < curCylinderUInt.Length; j++) { curCylinderUInt[j] = UInt32.Parse(curCylinderString[j].ToString()); } curCylinder.Values = CylinderTestsHelper.ConvertArrayUintToBinary(curCylinderUInt); curCylinder.Angle = Double.Parse(file.ReadLine()); curCylinder.Norm = Double.Parse(file.ReadLine()); contiguousCylinders[i] = curCylinder; file.ReadLine(); } } }