Changeset 13721 for trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSpectralMixture.cs
- Timestamp:
- 03/23/16 16:19:04 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSpectralMixture.cs
r12012 r13721 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using System.Linq.Expressions;26 25 using HeuristicLab.Common; 27 26 using HeuristicLab.Core; … … 131 130 } 132 131 133 public ParameterizedCovarianceFunction GetParameterizedCovarianceFunction(double[] p, IEnumerable<int>columnIndices) {132 public ParameterizedCovarianceFunction GetParameterizedCovarianceFunction(double[] p, int[] columnIndices) { 134 133 double[] weight, frequency, lengthScale; 135 134 GetParameterValues(p, out weight, out frequency, out lengthScale); … … 152 151 } 153 152 154 private static double GetCovariance(double[,] x, double[,] xt, int i, int j, int maxQ, double[] weight, double[] frequency, double[] lengthScale, IEnumerable<int>columnIndices) {153 private static double GetCovariance(double[,] x, double[,] xt, int i, int j, int maxQ, double[] weight, double[] frequency, double[] lengthScale, int[] columnIndices) { 155 154 // tau = x - x' (only for selected variables) 156 155 double[] tau = … … 164 163 int idx = 0; // helper index for tau 165 164 // for each selected variable 166 foreach (var c in columnIndices) { 167 kc *= f1(tau[idx], lengthScale[q * numberOfVariables + c]) * f2(tau[idx], frequency[q * numberOfVariables + c]); 165 for (int c = 0; c < columnIndices.Length; c++) { 166 var col = columnIndices[c]; 167 kc *= f1(tau[idx], lengthScale[q * numberOfVariables + col]) * f2(tau[idx], frequency[q * numberOfVariables + col]); 168 168 idx++; 169 169 } … … 181 181 182 182 // order of returned gradients must match the order in GetParameterValues! 183 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, int maxQ, double[] weight, double[] frequency, double[] lengthScale, IEnumerable<int>columnIndices,183 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, int maxQ, double[] weight, double[] frequency, double[] lengthScale, int[] columnIndices, 184 184 bool fixedWeight, bool fixedFrequency, bool fixedLengthScale) { 185 185 double[] tau = Util.GetRow(x, i, columnIndices).Zip(Util.GetRow(x, j, columnIndices), (xi, xj) => xi - xj).ToArray(); … … 193 193 int idx = 0; // helper index for tau 194 194 // for each selected variable 195 foreach (var c in columnIndices) { 196 k *= f1(tau[idx], lengthScale[q * numberOfVariables + c]) * f2(tau[idx], frequency[q * numberOfVariables + c]); 195 for (int c = 0; c < columnIndices.Length; c++) { 196 var col = columnIndices[c]; 197 k *= f1(tau[idx], lengthScale[q * numberOfVariables + col]) * f2(tau[idx], frequency[q * numberOfVariables + col]); 197 198 idx++; 198 199 }
Note: See TracChangeset
for help on using the changeset viewer.