Changeset 14872 for branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/KernelBase.cs
- Timestamp:
- 04/14/17 17:53:30 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/KernelBase.cs
r14386 r14872 31 31 namespace HeuristicLab.Algorithms.DataAnalysis { 32 32 [StorableClass] 33 public abstract class KernelBase <T> : ParameterizedNamedItem, IKernelFunction<T>{33 public abstract class KernelBase : ParameterizedNamedItem, ICovarianceFunction { 34 34 35 35 #region Parameternames … … 38 38 #endregion 39 39 #region Parameterproperties 40 public ValueParameter<IDistance<T>> DistanceParameter 41 { 42 get { return Parameters[DistanceParameterName] as ValueParameter<IDistance<T>>; } 40 public ValueParameter<IDistance> DistanceParameter { 41 get { return Parameters[DistanceParameterName] as ValueParameter<IDistance>; } 43 42 } 44 43 45 public IFixedValueParameter<DoubleValue> BetaParameter 46 { 44 public IFixedValueParameter<DoubleValue> BetaParameter { 47 45 get { return Parameters[BetaParameterName] as FixedValueParameter<DoubleValue>; } 48 46 } … … 50 48 #endregion 51 49 #region Properties 52 public IDistance<T> Distance 53 { 50 public IDistance Distance { 54 51 get { return DistanceParameter.Value; } 55 52 } 56 53 57 public double Beta 58 { 54 public double Beta { 59 55 get { return BetaParameter.Value.Value; } 60 56 } … … 62 58 #endregion 63 59 64 #region HLConstructors & Boilerplate65 60 [StorableConstructor] 66 61 protected KernelBase(bool deserializing) : base(deserializing) { } … … 68 63 private void AfterDeserialization() { } 69 64 70 protected KernelBase(KernelBase <T>original, Cloner cloner)65 protected KernelBase(KernelBase original, Cloner cloner) 71 66 : base(original, cloner) { } 72 67 73 68 protected KernelBase() { 74 Parameters.Add(new ValueParameter<IDistance <T>>(DistanceParameterName, "The distance function used for kernel calculation"));75 DistanceParameter.Value = new Euclid ianDistance() as IDistance<T>;69 Parameters.Add(new ValueParameter<IDistance>(DistanceParameterName, "The distance function used for kernel calculation")); 70 DistanceParameter.Value = new EuclideanDistance(); 76 71 } 77 #endregion78 72 79 public double Get( T a, Tb) {73 public double Get(object a, object b) { 80 74 return Get(Distance.Get(a, b)); 81 75 } … … 93 87 public ParameterizedCovarianceFunction GetParameterizedCovarianceFunction(double[] p, int[] columnIndices) { 94 88 if (p == null || p.Length != 1) throw new ArgumentException("Illegal parametrization"); 95 var myClone = (KernelBase <T>)Clone(new Cloner());89 var myClone = (KernelBase)Clone(new Cloner()); 96 90 myClone.BetaParameter.Value.Value = p[0]; 97 91 var cov = new ParameterizedCovarianceFunction { … … 107 101 protected double GetNorm(double[,] x, double[,] xt, int i, int j, int[] columnIndices) { 108 102 var dist = Distance as IDistance<IEnumerable<double>>; 109 if (dist == null) throw new ArgumentException("The Distance needs to apply to double-Vectors");103 if (dist == null) throw new ArgumentException("The distance needs to apply to double vectors"); 110 104 var r1 = new IndexedEnumerable(x, i, columnIndices); 111 105 var r2 = new IndexedEnumerable(xt, j, columnIndices); … … 142 136 } 143 137 144 public double Current 145 { 138 public double Current { 146 139 get { return data[row, column.Current]; } 147 140 } 148 141 149 object IEnumerator.Current 150 { 151 get 152 { 142 object IEnumerator.Current { 143 get { 153 144 return data[row, column.Current]; 154 145 }
Note: See TracChangeset
for help on using the changeset viewer.