Changeset 14767 for branches/TSNE/HeuristicLab.Algorithms.DataAnalysis/3.4/TSNE/Distances/EuclidianDistance.cs
- Timestamp:
- 03/19/17 18:47:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/TSNE/HeuristicLab.Algorithms.DataAnalysis/3.4/TSNE/Distances/EuclidianDistance.cs
r14512 r14767 45 45 return Math.Sqrt(point1.Zip(point2, (a1, b1) => (a1 - b1) * (a1 - b1)).Sum()); 46 46 } 47 public static double GetDistance(IEnumerable<double> a, IEnumerable<double> b, double threshold) {48 double sum = 0;49 var it1 = a.GetEnumerator();50 var it2 = b.GetEnumerator();51 while (sum > threshold * threshold && it1.MoveNext() && it2.MoveNext()) {52 var d = it1.Current - it2.Current;53 sum += d * d;54 }55 it1.Dispose();56 it2.Dispose();57 return sum;58 }59 47 #endregion 60 48 … … 62 50 return GetDistance(a.ToArray(), b.ToArray()); 63 51 } 64 public override double Get(IEnumerable<double> a, IEnumerable<double> b, double threshold) {65 return GetDistance(a, b, threshold);66 }67 52 } 68 53 }
Note: See TracChangeset
for help on using the changeset viewer.