Changeset 10489 for trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceLinearArd.cs
- Timestamp:
- 02/20/14 17:45:06 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceLinearArd.cs
r9456 r10489 37 37 get { return (IValueParameter<DoubleArray>)Parameters["InverseLength"]; } 38 38 } 39 private bool HasFixedInverseLengthParameter { 40 get { return InverseLengthParameter.Value != null; } 41 } 39 42 40 43 [StorableConstructor] … … 57 60 58 61 public int GetNumberOfParameters(int numberOfVariables) { 59 if (InverseLengthParameter.Value == null) 62 if (HasFixedInverseLengthParameter) 63 return 0; 64 else 60 65 return numberOfVariables; 61 else62 return 0;63 66 } 64 67 … … 71 74 private void GetParameterValues(double[] p, out double[] inverseLength) { 72 75 // gather parameter values 73 if ( InverseLengthParameter.Value != null) {76 if (HasFixedInverseLengthParameter) { 74 77 inverseLength = InverseLengthParameter.Value.ToArray(); 75 78 } else { … … 81 84 double[] inverseLength; 82 85 GetParameterValues(p, out inverseLength); 86 var fixedInverseLength = HasFixedInverseLengthParameter; 83 87 // create functions 84 88 var cov = new ParameterizedCovarianceFunction(); 85 89 cov.Covariance = (x, i, j) => Util.ScalarProd(x, i, j, inverseLength, columnIndices); 86 90 cov.CrossCovariance = (x, xt, i, j) => Util.ScalarProd(x, i, xt, j, inverseLength, columnIndices); 87 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, inverseLength, columnIndices); 91 if (fixedInverseLength) 92 cov.CovarianceGradient = (x, i, j) => Enumerable.Empty<double>(); 93 else 94 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, inverseLength, columnIndices); 88 95 return cov; 89 96 }
Note: See TracChangeset
for help on using the changeset viewer.