Changeset 8489 for trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceSum.cs
 Timestamp:
 08/14/12 15:24:30 (12 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceSum.cs
r8484 r8489 50 50 this.terms = cloner.Clone(original.terms); 51 51 this.numberOfVariables = original.numberOfVariables; 52 AttachEventHandlers();53 52 } 54 53 … … 56 55 : base() { 57 56 this.terms = new ItemList<ICovarianceFunction>(); 58 AttachEventHandlers();59 }60 61 private void AttachEventHandlers() {62 this.terms.CollectionReset += (sender, args) => ClearCache();63 this.terms.ItemsAdded += (sender, args) => ClearCache();64 this.terms.ItemsRemoved += (sender, args) => ClearCache();65 this.terms.ItemsReplaced += (sender, args) => ClearCache();66 this.terms.ItemsMoved += (sender, args) => ClearCache();67 57 } 68 58 … … 90 80 } 91 81 92 private Dictionary<int, Tuple<int, int>> cachedParameterMap;93 82 public IEnumerable<double> GetGradient(double[,] x, int i, int j) { 94 //if (cachedParameterMap == null) {95 // CalculateParameterMap();96 //}97 //int ti = cachedParameterMap[k].Item1;98 //k = cachedParameterMap[k].Item2;99 //return terms[ti].GetGradient(x, i, j, k);100 83 return terms.Select(t => t.GetGradient(x, i, j)).Aggregate(Enumerable.Concat); 101 84 } … … 104 87 return terms.Select(t => t.GetCrossCovariance(x, xt, i, j)).Sum(); 105 88 } 106 107 private void ClearCache() {108 cachedParameterMap = null;109 }110 111 //private void CalculateParameterMap() {112 // cachedParameterMap = new Dictionary<int, Tuple<int, int>>();113 // int k = 0;114 // for (int ti = 0; ti < terms.Count; ti++) {115 // for (int ti_k = 0; ti_k < terms[ti].GetNumberOfParameters(numberOfVariables); ti_k++) {116 // cachedParameterMap[k++] = Tuple.Create(ti, ti_k);117 // }118 // }119 //}120 89 } 121 90 }
Note: See TracChangeset
for help on using the changeset viewer.