Changeset 14029 for branches/crossvalidation-2434/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceLinearArd.cs
- Timestamp:
- 07/08/16 14:40:02 (8 years ago)
- Location:
- branches/crossvalidation-2434
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/crossvalidation-2434
- Property svn:mergeinfo changed
-
branches/crossvalidation-2434/HeuristicLab.Algorithms.DataAnalysis
- Property svn:mergeinfo changed
-
branches/crossvalidation-2434/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceLinearArd.cs
r12012 r14029 81 81 } 82 82 83 public ParameterizedCovarianceFunction GetParameterizedCovarianceFunction(double[] p, IEnumerable<int>columnIndices) {83 public ParameterizedCovarianceFunction GetParameterizedCovarianceFunction(double[] p, int[] columnIndices) { 84 84 double[] inverseLength; 85 85 GetParameterValues(p, out inverseLength); … … 90 90 cov.CrossCovariance = (x, xt, i, j) => Util.ScalarProd(x, i, xt, j, inverseLength, columnIndices); 91 91 if (fixedInverseLength) 92 cov.CovarianceGradient = (x, i, j) => Enumerable.Empty<double>();92 cov.CovarianceGradient = (x, i, j) => new double[0]; 93 93 else 94 94 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, inverseLength, columnIndices); … … 96 96 } 97 97 98 private static I Enumerable<double> GetGradient(double[,] x, int i, int j, double[] inverseLength, IEnumerable<int>columnIndices) {98 private static IList<double> GetGradient(double[,] x, int i, int j, double[] inverseLength, int[] columnIndices) { 99 99 int k = 0; 100 foreach (int columnIndex in columnIndices) { 101 yield return -2.0 * x[i, columnIndex] * x[j, columnIndex] * inverseLength[k] * inverseLength[k]; 100 var g = new List<double>(columnIndices.Length); 101 for (int c = 0; c < columnIndices.Length; c++) { 102 var columnIndex = columnIndices[c]; 103 g.Add(-2.0 * x[i, columnIndex] * x[j, columnIndex] * inverseLength[k] * inverseLength[k]); 102 104 k++; 103 105 } 106 return g; 104 107 } 105 108 }
Note: See TracChangeset
for help on using the changeset viewer.