Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/22/16 13:47:35 (8 years ago)
Author:
pfleck
Message:

#2591 Made the creation of a GaussianProcessModel faster by avoiding additional iterators during calculation of the hyperparameter gradients.
The gradients of the hyperparameters are now calculated in one sweep and returned as IList, instead of returning an iterator (with yield return).
This avoids a large amount of Move-calls of the iterator, especially for covariance functions with a lot of hyperparameters.
Besides, the signature of the CovarianceGradientFunctionDelegate is changed, to return an IList instead of an IEnumerable to avoid unnececary ToList or ToArray calls.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceMaternIso.cs

    r13721 r13784  
    155155    }
    156156
    157 
    158     private static IEnumerable<double> GetGradient(double[,] x, int i, int j, int d, double scale, double inverseLength, int[] columnIndices,
     157    private static IList<double> GetGradient(double[,] x, int i, int j, int d, double scale, double inverseLength, int[] columnIndices,
    159158      bool fixedInverseLength, bool fixedScale) {
    160159      double dist = i == j
     
    162161                   : Math.Sqrt(Util.SqrDist(x, i, j, columnIndices, Math.Sqrt(d) * inverseLength));
    163162
    164       if (!fixedInverseLength) yield return scale * dm(d, dist);
    165       if (!fixedScale) yield return 2 * scale * m(d, dist);
     163      var g = new List<double>(2);
     164      if (!fixedInverseLength) g.Add(scale * dm(d, dist));
     165      if (!fixedScale) g.Add(2 * scale * m(d, dist));
     166      return g;
    166167    }
    167168  }
Note: See TracChangeset for help on using the changeset viewer.