Changeset 7460 for branches/HeuristicLab.TimeSeries/HeuristicLab.Analysis/3.3/MultidimensionalScaling
- Timestamp:
- 02/06/12 17:50:17 (13 years ago)
- Location:
- branches/HeuristicLab.TimeSeries
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.TimeSeries
- Property svn:ignore
-
old new 3 3 *.resharper 4 4 *.suo 5 *.user 5 6 *.vsp 6 7 Doxygen 8 FxCopResults.txt 7 9 Google.ProtocolBuffers-0.9.1.dll 8 10 HeuristicLab 3.3.5.1.ReSharper.user
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/HeuristicLab.TimeSeries/HeuristicLab.Analysis
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Analysis merged: 7294,7297,7351,7416
- Property svn:mergeinfo changed
-
branches/HeuristicLab.TimeSeries/HeuristicLab.Analysis/3.3/MultidimensionalScaling/MultidimensionalScaling.cs
r7268 r7460 103 103 private static void StressFitness(double[] x, double[] fi, object obj) { 104 104 Info info = (obj as Info); 105 int idx = 0; 105 106 for (int i = 0; i < info.Coordinates.Rows; i++) { 106 double f = Stress(x, info.Dissimilarities[info.Row, i], info.Coordinates[i, 0], info.Coordinates[i, 1]); 107 if (i < info.Row) fi[i] = f; 108 else if (i > info.Row) fi[i - 1] = f; 107 if (i == info.Row) continue; 108 if (!double.IsNaN(info.Dissimilarities[info.Row, i])) 109 fi[idx++] = Stress(x, info.Dissimilarities[info.Row, i], info.Coordinates[i, 0], info.Coordinates[i, 1]); 110 else fi[idx++] = 0.0; 109 111 } 110 112 } … … 114 116 int idx = 0; 115 117 for (int i = 0; i < info.Coordinates.Rows; i++) { 116 if (i != info.Row) {117 118 119 120 double f = Stress(x, c, a, b);121 fi[idx] = f;118 if (i == info.Row) continue; 119 double c = info.Dissimilarities[info.Row, i]; 120 double a = info.Coordinates[i, 0]; 121 double b = info.Coordinates[i, 1]; 122 if (!double.IsNaN(c)) { 123 fi[idx] = Stress(x, c, a, b); ; 122 124 jac[idx, 0] = 2 * (x[0] - a) * (Math.Sqrt((a - x[0]) * (a - x[0]) + (b - x[1]) * (b - x[1])) - c) / Math.Sqrt((a - x[0]) * (a - x[0]) + (b - x[1]) * (b - x[1])); 123 125 jac[idx, 1] = 2 * (x[1] - b) * (Math.Sqrt((a - x[0]) * (a - x[0]) + (b - x[1]) * (b - x[1])) - c) / Math.Sqrt((a - x[0]) * (a - x[0]) + (b - x[1]) * (b - x[1])); 124 idx++; 126 } else { 127 fi[idx] = jac[idx, 0] = jac[idx, 1] = 0; 125 128 } 129 idx++; 126 130 } 127 131 } … … 153 157 for (int i = 0; i < dimension - 1; i++) { 154 158 for (int j = i + 1; j < dimension; j++) { 155 if (dissimilarities[i, j] != dissimilarities[j, i]) throw new ArgumentException("Dissimilarities is not a symmetric matrix.", "dissimilarities"); 156 if (dissimilarities[i, j] != 0) { 159 if (dissimilarities[i, j] != dissimilarities[j, i] && !(double.IsNaN(dissimilarities[i, j]) && double.IsNaN(dissimilarities[j, i]))) 160 throw new ArgumentException("Dissimilarities is not a symmetric matrix.", "dissimilarities"); 161 if (!double.IsNaN(dissimilarities[i, j])) { 157 162 stress += Stress(coordinates[i, 0], coordinates[i, 1], dissimilarities[i, j], coordinates[j, 0], coordinates[j, 1]); 158 163 normalization += (dissimilarities[i, j] * dissimilarities[i, j]);
Note: See TracChangeset
for help on using the changeset viewer.