Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10078


Ignore:
Timestamp:
10/22/13 00:05:02 (11 years ago)
Author:
ascheibe
Message:

#1886 another bugfix in the point calculation from distance matrices

Location:
branches/HeuristicLab.Analysis.AlgorithmBehavior
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/AlgorithmBehaviorUnitTests/DistanceMatrixToPointsTest.cs

    r10060 r10078  
    2929    [TestMethod]
    3030    public void TestDistanceMatrixConversion() {
    31       int nrOfPoints = 5;
     31      int nrOfPoints = 4;
    3232      int dim = 2;
    3333      double[][] orgPoints = new double[nrOfPoints][];
     
    4444
    4545      newPoints = DistanceMatrixToPoints.ConvertDistanceMatrixToPoints(orgDm);
     46
    4647      CalculateDistanceMatrix(newDm, newPoints);
    4748      //TODO
     
    6869
    6970    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);
    7176    }
    7277
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/DistanceMatrixToPoints.cs

    r10077 r10078  
    5454      if (!res) throw new Exception("Eigenvalue computation did not converge!");
    5555
    56       int zeroCnt = q.Count(x => x.IsAlmost(0));
     56      int zeroCnt = q.Count(x => x.IsAlmost(0) || x < 0.0);
    5757      for (int i = 0; i < dm.Length; i++) {
    5858        points[i] = new double[dm.Length - zeroCnt];
     
    6161      int pi = 0;
    6262      for (int i = 0; i < dm.Length; i++) {
    63         if (q[i].IsAlmost(0)) {
     63        if (!q[i].IsAlmost(0) && q[i] > 0.0) {
    6464          for (int j = 0; j < dm.Length; j++) {
    6565            points[j][pi] = Math.Sqrt(q[i]) * v[j, i];
Note: See TracChangeset for help on using the changeset viewer.