Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/02/16 14:38:40 (8 years ago)
Author:
gkronber
Message:

#2591: merged r13438 (#2541), r13721, r13724, r13784, r13891 from trunk to stable

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Algorithms.DataAnalysis

  • stable/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSquaredExponentialArd.cs

    r12009 r13981  
    9999    }
    100100
    101     public ParameterizedCovarianceFunction GetParameterizedCovarianceFunction(double[] p, IEnumerable<int> columnIndices) {
     101    public ParameterizedCovarianceFunction GetParameterizedCovarianceFunction(double[] p, int[] columnIndices) {
    102102      double scale;
    103103      double[] inverseLength;
     
    122122
    123123    // order of returned gradients must match the order in GetParameterValues!
    124     private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double[] inverseLength,
     124    private static IList<double> GetGradient(double[,] x, int i, int j, int[] columnIndices, double scale, double[] inverseLength,
    125125      bool fixedInverseLength, bool fixedScale) {
    126126      double d = i == j
     
    129129
    130130      int k = 0;
     131      var g = new List<double>((!fixedInverseLength ? columnIndices.Length : 0) + (!fixedScale ? 1 : 0));
    131132      if (!fixedInverseLength) {
    132         foreach (var columnIndex in columnIndices) {
     133        for (int c = 0; c < columnIndices.Length; c++) {
     134          var columnIndex = columnIndices[c];
    133135          double sqrDist = Util.SqrDist(x[i, columnIndex] * inverseLength[k], x[j, columnIndex] * inverseLength[k]);
    134           yield return scale * Math.Exp(-d / 2.0) * sqrDist;
     136          g.Add(scale * Math.Exp(-d / 2.0) * sqrDist);
    135137          k++;
    136138        }
    137139      }
    138       if (!fixedScale) yield return 2.0 * scale * Math.Exp(-d / 2.0);
     140      if (!fixedScale) g.Add(2.0 * scale * Math.Exp(-d / 2.0));
     141      return g;
    139142    }
    140143  }
Note: See TracChangeset for help on using the changeset viewer.