Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/09/12 09:33:23 (12 years ago)
Author:
gkronber
Message:

#1902 changed calculation of gradients for covariance functions to reduce allocations of arrays

File:
1 edited

Legend:

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

    r8416 r8455  
    101101    }
    102102
    103     public double[] GetGradient(int i, int j) {
    104       var res = new double[2];
    105       res[0] = sf2 * Math.Exp(-sd[i, j] / 2.0) * sd[i, j];
    106       res[1] = 2.0 * sf2 * Math.Exp(-sd[i, j] / 2.0);
    107       return res;
     103    public double GetGradient(int i, int j, int k) {
     104      switch (k) {
     105        case 0: return sf2 * Math.Exp(-sd[i, j] / 2.0) * sd[i, j];
     106        case 1: return 2.0 * sf2 * Math.Exp(-sd[i, j] / 2.0);
     107        default: throw new ArgumentException("CovarianceSEiso has two hyperparameters", "k");
     108      }
    108109    }
    109110
Note: See TracChangeset for help on using the changeset viewer.