Changeset 8585 for branches/HeuristicLab.Mono/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceSum.cs
- Timestamp:
- 09/06/12 09:52:52 (12 years ago)
- Location:
- branches/HeuristicLab.Mono
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Mono
-
branches/HeuristicLab.Mono/HeuristicLab.Algorithms.DataAnalysis
-
branches/HeuristicLab.Mono/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceSum.cs
r8451 r8585 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 22 24 using System.Linq; 23 25 using HeuristicLab.Common; … … 65 67 66 68 public void SetParameter(double[] hyp) { 69 if (terms.Count == 0) throw new ArgumentException("At least one term is needed for sum covariance function."); 67 70 int offset = 0; 68 71 foreach (var t in terms) { … … 72 75 } 73 76 } 74 public void SetData(double[,] x) { 75 SetData(x, x); 77 78 public double GetCovariance(double[,] x, int i, int j) { 79 return terms.Select(t => t.GetCovariance(x, i, j)).Sum(); 76 80 } 77 81 78 public void SetData(double[,] x, double[,] xt) { 79 foreach (var t in terms) { 80 t.SetData(x, xt); 81 } 82 public IEnumerable<double> GetGradient(double[,] x, int i, int j) { 83 return terms.Select(t => t.GetGradient(x, i, j)).Aggregate(Enumerable.Concat); 82 84 } 83 85 84 public double GetCovariance(int i, int j) { 85 return terms.Select(t => t.GetCovariance(i, j)).Sum(); 86 } 87 88 public double[] GetGradient(int i, int j) { 89 return terms.Select(t => t.GetGradient(i, j)).SelectMany(seq => seq).ToArray(); 86 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j) { 87 return terms.Select(t => t.GetCrossCovariance(x, xt, i, j)).Sum(); 90 88 } 91 89 }
Note: See TracChangeset
for help on using the changeset viewer.