Changeset 2038 for trunk/sources/HeuristicLab.DataAnalysis
- Timestamp:
- 06/10/09 10:46:56 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.DataAnalysis/3.2/Dataset.cs
r2012 r2038 39 39 private double[] scalingFactor; 40 40 private double[] scalingOffset; 41 private bool cachedValuesInvalidated = true; 42 43 private bool fireChangeEvents = true; 44 public bool FireChangeEvents { 45 get { return fireChangeEvents; } 46 set { fireChangeEvents = value; } 47 } 41 48 42 49 public string Name { … … 74 81 if (v != samples[columns * i + j]) { 75 82 samples[columns * i + j] = v; 76 CreateDictionaries();77 FireChanged();83 cachedValuesInvalidated = true; 84 if (fireChangeEvents) FireChanged(); 78 85 } 79 86 } … … 89 96 } 90 97 samples = value; 91 CreateDictionaries();92 FireChanged();98 cachedValuesInvalidated = true; 99 if (fireChangeEvents) FireChanged(); 93 100 } 94 101 } … … 104 111 scalingOffset = new double[] { 0.0 }; 105 112 scalingFactor = new double[] { 1.0 }; 106 } 107 108 private void CreateDictionaries() { 109 // keep a means and ranges dictionary for each column (possible target variable) of the dataset. 110 cachedMeans = new Dictionary<int, Dictionary<int, double>>[columns]; 111 cachedRanges = new Dictionary<int, Dictionary<int, double>>[columns]; 112 for (int i = 0; i < columns; i++) { 113 cachedMeans[i] = new Dictionary<int, Dictionary<int, double>>(); 114 cachedRanges[i] = new Dictionary<int, Dictionary<int, double>>(); 115 } 113 cachedValuesInvalidated = true; 114 fireChangeEvents = true; 116 115 } 117 116 … … 206 205 } 207 206 } 208 CreateDictionaries();209 207 } 210 208 … … 270 268 271 269 public double GetMean(int column, int from, int to) { 270 if (cachedValuesInvalidated) CreateDictionaries(); 272 271 if (!cachedMeans[column].ContainsKey(from) || !cachedMeans[column][from].ContainsKey(to)) { 273 272 double[] values = new double[to - from]; … … 289 288 290 289 public double GetRange(int column, int from, int to) { 290 if (cachedValuesInvalidated) CreateDictionaries(); 291 291 if (!cachedRanges[column].ContainsKey(from) || !cachedRanges[column][from].ContainsKey(to)) { 292 292 double[] values = new double[to - from]; … … 329 329 else ScaleVariable(column, 1.0 / range, -min); 330 330 } 331 CreateDictionaries();332 FireChanged();331 cachedValuesInvalidated = true; 332 if (fireChangeEvents) FireChanged(); 333 333 } 334 334 … … 340 340 samples[i * columns + column] = (origValue + offset) * factor; 341 341 } 342 CreateDictionaries();343 FireChanged();342 cachedValuesInvalidated = true; 343 if (fireChangeEvents) FireChanged(); 344 344 } 345 345 … … 353 353 scalingOffset[column] = 0.0; 354 354 } 355 cachedValuesInvalidated = true; 356 if (fireChangeEvents) FireChanged(); 357 } 358 359 private void CreateDictionaries() { 360 // keep a means and ranges dictionary for each column (possible target variable) of the dataset. 361 cachedMeans = new Dictionary<int, Dictionary<int, double>>[columns]; 362 cachedRanges = new Dictionary<int, Dictionary<int, double>>[columns]; 363 for (int i = 0; i < columns; i++) { 364 cachedMeans[i] = new Dictionary<int, Dictionary<int, double>>(); 365 cachedRanges[i] = new Dictionary<int, Dictionary<int, double>>(); 366 } 355 367 } 356 368 }
Note: See TracChangeset
for help on using the changeset viewer.