Changeset 10078
- Timestamp:
- 10/22/13 00:05:02 (11 years ago)
- Location:
- branches/HeuristicLab.Analysis.AlgorithmBehavior
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Analysis.AlgorithmBehavior/AlgorithmBehaviorUnitTests/DistanceMatrixToPointsTest.cs
r10060 r10078 29 29 [TestMethod] 30 30 public void TestDistanceMatrixConversion() { 31 int nrOfPoints = 5;31 int nrOfPoints = 4; 32 32 int dim = 2; 33 33 double[][] orgPoints = new double[nrOfPoints][]; … … 44 44 45 45 newPoints = DistanceMatrixToPoints.ConvertDistanceMatrixToPoints(orgDm); 46 46 47 CalculateDistanceMatrix(newDm, newPoints); 47 48 //TODO … … 68 69 69 70 private static double CalcEuclideanDistance(double[] p1, double[] p2) { 70 return Math.Sqrt(Math.Pow(p1[0] - p2[0], 2) + Math.Pow(p1[1] - p2[1], 2)); 71 double result = 0.0; 72 for (int i = 0; i < p1.Length; i++) { 73 result += Math.Pow(p1[i] - p2[i], 2); 74 } 75 return Math.Sqrt(result); 71 76 } 72 77 -
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/DistanceMatrixToPoints.cs
r10077 r10078 54 54 if (!res) throw new Exception("Eigenvalue computation did not converge!"); 55 55 56 int zeroCnt = q.Count(x => x.IsAlmost(0) );56 int zeroCnt = q.Count(x => x.IsAlmost(0) || x < 0.0); 57 57 for (int i = 0; i < dm.Length; i++) { 58 58 points[i] = new double[dm.Length - zeroCnt]; … … 61 61 int pi = 0; 62 62 for (int i = 0; i < dm.Length; i++) { 63 if ( q[i].IsAlmost(0)) {63 if (!q[i].IsAlmost(0) && q[i] > 0.0) { 64 64 for (int j = 0; j < dm.Length; j++) { 65 65 points[j][pi] = Math.Sqrt(q[i]) * v[j, i];
Note: See TracChangeset
for help on using the changeset viewer.