Index: /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj
===================================================================
--- /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj	(revision 14871)
+++ /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj	(revision 14872)
@@ -369,13 +369,7 @@
     <Compile Include="Plugin.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="RadialBasisFunctions\Distances\AngularDistance.cs" />
-    <Compile Include="RadialBasisFunctions\Distances\DistanceBase.cs" />
-    <Compile Include="RadialBasisFunctions\Distances\EuclidianDistance.cs" />
-    <Compile Include="RadialBasisFunctions\Distances\ManhattanDistance.cs" />
-    <Compile Include="RadialBasisFunctions\Interfaces\IDistance.cs" />
-    <Compile Include="RadialBasisFunctions\Interfaces\IKernelFunction.cs" />
     <Compile Include="RadialBasisFunctions\KernelFunctions\CicularKernel.cs" />
     <Compile Include="RadialBasisFunctions\KernelFunctions\GaussianKernel.cs" />
-    <Compile Include="RadialBasisFunctions\KernelFunctions\InverseMultiquadraticKernel .cs" />
+    <Compile Include="RadialBasisFunctions\KernelFunctions\InverseMultiquadraticKernel.cs" />
     <Compile Include="RadialBasisFunctions\KernelFunctions\KernelBase.cs" />
     <Compile Include="RadialBasisFunctions\KernelFunctions\LaplacianKernel.cs" />
@@ -383,7 +377,5 @@
     <Compile Include="RadialBasisFunctions\KernelFunctions\PolysplineKernel.cs" />
     <Compile Include="RadialBasisFunctions\KernelFunctions\ThinPlatePolysplineKernel.cs" />
-    <Compile Include="RadialBasisFunctions\MatrixUtilities.cs" />
     <Compile Include="RadialBasisFunctions\RadialBasisFunctionModel.cs" />
-    <Compile Include="RadialBasisFunctions\RadialBasisFunctionRegressionSolution.cs" />
     <Compile Include="RadialBasisFunctions\RadialBasisRegression.cs" />
     <Compile Include="RandomForest\RandomForestClassificationSolution.cs" />
@@ -442,4 +434,8 @@
     </BootstrapperPackage>
   </ItemGroup>
+  <ItemGroup>
+    <Folder Include="RadialBasisFunctions\Distances\" />
+    <Folder Include="RadialBasisFunctions\Interfaces\" />
+  </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
Index: anches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Distances/AngularDistance.cs
===================================================================
--- /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Distances/AngularDistance.cs	(revision 14871)
+++ 	(revision )
@@ -1,68 +1,0 @@
-﻿#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-
-namespace HeuristicLab.Algorithms.DataAnalysis {
-  [StorableClass]
-  [Item("AngularDistance", "The Angluar Distance as defined as a normalized distance measure dependent on the angle between two vectors.\nIt is designed for vectors with all positive coordinates")]
-  public class AngularDistance : DistanceBase<IEnumerable<double>> {
-
-    #region HLConstructors & Boilerplate
-    [StorableConstructor]
-    protected AngularDistance(bool deserializing) : base(deserializing) { }
-    [StorableHook(HookType.AfterDeserialization)]
-    private void AfterDeserialization() { }
-    protected AngularDistance(AngularDistance original, Cloner cloner)
-      : base(original, cloner) { }
-    public AngularDistance() { }
-    public override IDeepCloneable Clone(Cloner cloner) {
-      return new AngularDistance(this, cloner);
-    }
-    #endregion
-
-    #region statics
-    public static double GetDistance(double[] point1, double[] point2) {
-      if (point1.Length != point2.Length) throw new ArgumentException("Angluar distance not defined on vectors of different length");
-      var innerProduct = point1.Zip(point2, (x, y) => x * y).Sum();
-      return Math.Acos(innerProduct / (Norm(point1) * Norm(point2))) / Math.PI;
-    }
-    public static double GetDistance(IEnumerable<double> a, IEnumerable<double> b, double threshold) {
-      return GetDistance(a.ToArray(), b.ToArray());     //no shortcut evaluation for Angular Distance
-    }
-    #endregion
-    public override double Get(IEnumerable<double> a, IEnumerable<double> b) {
-      return GetDistance(a.ToArray(), b.ToArray());
-    }
-    public override double Get(IEnumerable<double> a, IEnumerable<double> b, double threshold) {
-      return GetDistance(a, b, threshold);
-    }
-
-    private static double Norm(IEnumerable<double> point) {
-      return Math.Sqrt(point.Sum(d => d * d));
-    }
-  }
-}
Index: anches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Distances/DistanceBase.cs
===================================================================
--- /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Distances/DistanceBase.cs	(revision 14871)
+++ 	(revision )
@@ -1,62 +1,0 @@
-﻿#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System.Collections.Generic;
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-
-namespace HeuristicLab.Algorithms.DataAnalysis {
-  [StorableClass]
-  public abstract class DistanceBase<T> : Item, IDistance<T> {
-
-    #region HLConstructors & Boilerplate
-    [StorableConstructor]
-    protected DistanceBase(bool deserializing) : base(deserializing) { }
-    [StorableHook(HookType.AfterDeserialization)]
-    private void AfterDeserialization() { }
-    protected DistanceBase(DistanceBase<T> original, Cloner cloner)
-      : base(original, cloner) { }
-    protected DistanceBase() { }
-    #endregion
-
-    public abstract double Get(T a, T b);
-    public abstract double Get(T a, T b, double threshold);
-
-    public IComparer<T> GetDistanceComparer(T item) {
-      return new DistanceComparer(item, this);
-    }
-
-    private class DistanceComparer : IComparer<T> {
-      private readonly T item;
-      private readonly IDistance<T> dist;
-
-      public DistanceComparer(T item, IDistance<T> dist) {
-        this.dist = dist;
-        this.item = item;
-      }
-
-      public int Compare(T x, T y) {
-        return dist.Get(x, item).CompareTo(dist.Get(y, item));
-      }
-    }
-  }
-}
Index: anches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Distances/EuclidianDistance.cs
===================================================================
--- /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Distances/EuclidianDistance.cs	(revision 14871)
+++ 	(revision )
@@ -1,73 +1,0 @@
-﻿#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-
-namespace HeuristicLab.Algorithms.DataAnalysis {
-  [StorableClass]
-  [Item("EuclidianNorm", "A norm function that uses Euclidean distance")]
-  public class EuclidianDistance : DistanceBase<IEnumerable<double>> {
-
-    #region HLConstructors & Boilerplate
-    [StorableConstructor]
-    protected EuclidianDistance(bool deserializing) : base(deserializing) { }
-    [StorableHook(HookType.AfterDeserialization)]
-    private void AfterDeserialization() { }
-    protected EuclidianDistance(EuclidianDistance original, Cloner cloner)
-      : base(original, cloner) { }
-    public EuclidianDistance() { }
-    public override IDeepCloneable Clone(Cloner cloner) {
-      return new EuclidianDistance(this, cloner);
-    }
-    #endregion
-
-    #region statics
-    public static double GetDistance(double[] point1, double[] point2) {
-      if (point1.Length != point2.Length) throw new ArgumentException("Euclidean distance not defined on vectors of different length");
-      return Math.Sqrt(point1.Zip(point2, (a1, b1) => (a1 - b1) * (a1 - b1)).Sum());
-    }
-    public static double GetDistance(IEnumerable<double> a, IEnumerable<double> b, double threshold) {
-      double sum = 0;
-      var it1 = a.GetEnumerator();
-      var it2 = b.GetEnumerator();
-      while (sum > threshold * threshold && it1.MoveNext() && it2.MoveNext()) {
-        var d = it1.Current - it2.Current;
-        sum += d * d;
-      }
-      it1.Dispose();
-      it2.Dispose();
-      return sum;
-    }
-    #endregion
-
-    public override double Get(IEnumerable<double> a, IEnumerable<double> b) {
-      return GetDistance(a.ToArray(), b.ToArray());
-    }
-    public override double Get(IEnumerable<double> a, IEnumerable<double> b, double threshold) {
-      return GetDistance(a, b, threshold);
-    }
-  }
-}
Index: anches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Interfaces/IDistance.cs
===================================================================
--- /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Interfaces/IDistance.cs	(revision 14871)
+++ 	(revision )
@@ -1,49 +1,0 @@
-﻿#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System.Collections.Generic;
-using HeuristicLab.Core;
-
-namespace HeuristicLab.Algorithms.DataAnalysis {
-  public interface IDistance<in T> : IItem {
-    /// <summary>
-    /// Calculates a distance measure between two aribitrary Vectors. The distance value d is 
-    /// 1.) positive  d(x,y)>0
-    /// 2.) symmetric d(x,y) = d(y,x)
-    /// 3.) zero-reflexive d(x,x) =0;
-    /// </summary>
-    /// <param name="a">an array representing point x</param>
-    /// <param name="b">>an array representing point y</param>
-    /// <returns>d(x,y)</returns>
-    double Get(T a, T b);
-    /// <summary>
-    /// Calculates the correct kernel measure if it is smaller than threshold, but any value greater then threshold if the correct distance is greater.
-    /// This is for performace only
-    /// </summary>
-    /// <param name="a"></param>
-    /// <param name="b"></param>
-    /// <param name="threshold"></param>
-    /// <returns></returns>
-    double Get(T a, T b, double threshold);
-
-    IComparer<T> GetDistanceComparer(T item);
-  }
-}
Index: anches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Interfaces/IKernelFunction.cs
===================================================================
--- /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/Interfaces/IKernelFunction.cs	(revision 14871)
+++ 	(revision )
@@ -1,41 +1,0 @@
-﻿#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-
-namespace HeuristicLab.Algorithms.DataAnalysis {
-  public interface IKernelFunction<in T> : ICovarianceFunction {
-    /// <summary>
-    /// Calculates a kernel measure between two aribitrary Vectors. The distance value d is 
-    /// 1.) positive  d(x,y)>0
-    /// 2.) symmetric d(x,y) = d(y,x)
-    /// 3.) only dependent on the norm ||x-y|| (Radial Basis criterium)
-    /// </summary>
-    /// <param name="a">an array representing point x</param>
-    /// <param name="b">>an array representing point y</param>
-    /// <returns>d(x,y)</returns>
-    double Get(T a, T b);
-
-
-    IFixedValueParameter<DoubleValue> BetaParameter { get; }
-  }
-}
Index: /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/CicularKernel.cs
===================================================================
--- /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/CicularKernel.cs	(revision 14871)
+++ /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/CicularKernel.cs	(revision 14872)
@@ -30,5 +30,5 @@
   [StorableClass]
   [Item("CircularKernel", "A circular kernel function")]
-  public class CircularKernel<T> : KernelBase<T> {
+  public class CircularKernel : KernelBase {
 
     #region HLConstructors & Boilerplate
@@ -37,10 +37,10 @@
     [StorableHook(HookType.AfterDeserialization)]
     private void AfterDeserialization() { }
-    protected CircularKernel(CircularKernel<T> original, Cloner cloner) : base(original, cloner) { }
+    protected CircularKernel(CircularKernel original, Cloner cloner) : base(original, cloner) { }
     public CircularKernel() {
-      Parameters.Add(new FixedValueParameter<DoubleValue>(BetaParameterName, "The beta in the kernelfunction 2*pi*(acos(-d)-d*(1-n²)^(0.5)) where n = ||x-c|| and d = n/beta", new DoubleValue(2)));
+      Parameters.Add(new FixedValueParameter<DoubleValue>(BetaParameterName, "The beta in the kernel function 2*pi*(acos(-d)-d*(1-n²)^(0.5)) where n = ||x-c|| and d = n/beta", new DoubleValue(2)));
     }
     public override IDeepCloneable Clone(Cloner cloner) {
-      return new CircularKernel<T>(this, cloner);
+      return new CircularKernel(this, cloner);
     }
     #endregion
Index: /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/GaussianKernel.cs
===================================================================
--- /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/GaussianKernel.cs	(revision 14871)
+++ /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/GaussianKernel.cs	(revision 14872)
@@ -30,5 +30,5 @@
   [StorableClass]
   [Item("GaussianKernel", "A kernel function that uses Gaussian function")]
-  public class GaussianKernel<T> : KernelBase<T> {
+  public class GaussianKernel : KernelBase {
 
     #region HLConstructors & Boilerplate
@@ -37,10 +37,10 @@
     [StorableHook(HookType.AfterDeserialization)]
     private void AfterDeserialization() { }
-    protected GaussianKernel(GaussianKernel<T> original, Cloner cloner) : base(original, cloner) { }
+    protected GaussianKernel(GaussianKernel original, Cloner cloner) : base(original, cloner) { }
     public GaussianKernel() {
       Parameters.Add(new FixedValueParameter<DoubleValue>(BetaParameterName, "The beta in the kernelfunction exp(-||x-c||/beta²)", new DoubleValue(2)));
     }
     public override IDeepCloneable Clone(Cloner cloner) {
-      return new GaussianKernel<T>(this, cloner);
+      return new GaussianKernel(this, cloner);
     }
     #endregion
Index: anches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/InverseMultiquadraticKernel .cs
===================================================================
--- /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/InverseMultiquadraticKernel .cs	(revision 14871)
+++ 	(revision )
@@ -1,58 +1,0 @@
-﻿#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-using HeuristicLab.Parameters;
-using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-
-namespace HeuristicLab.Algorithms.DataAnalysis {
-  [StorableClass]
-  [Item("InverseMultiquadraticKernel", "A kernel function that uses the inverse multiquadratic function")]
-  public class InverseMultiquadraticKernel<T> : KernelBase<T> {
-    #region HLConstructors & Boilerplate
-    [StorableConstructor]
-    protected InverseMultiquadraticKernel(bool deserializing) : base(deserializing) { }
-    [StorableHook(HookType.AfterDeserialization)]
-    private void AfterDeserialization() { }
-    protected InverseMultiquadraticKernel(InverseMultiquadraticKernel<T> original, Cloner cloner) : base(original, cloner) { }
-    public InverseMultiquadraticKernel() {
-      Parameters.Add(new FixedValueParameter<DoubleValue>(BetaParameterName, "The beta in the kernelfunction sqrt(1+||x-c||^2/beta)", new DoubleValue(2)));
-    }
-    public override IDeepCloneable Clone(Cloner cloner) {
-      return new InverseMultiquadraticKernel<T>(this, cloner);
-    }
-    #endregion
-
-    protected override double Get(double norm) {
-      if (Math.Abs(Beta) < double.Epsilon) return 0;
-      return 1 / Math.Sqrt(1 + norm * norm / Beta);
-    }
-
-    protected override double GetGradient(double norm) {
-      if (Math.Abs(Beta) < double.Epsilon) return double.NaN;
-      norm *= norm;
-      return norm / (2 * Beta * Beta * Math.Pow((norm + Beta) / Beta, 1.5));
-    }
-  }
-}
Index: /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/InverseMultiquadraticKernel.cs
===================================================================
--- /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/InverseMultiquadraticKernel.cs	(revision 14872)
+++ /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/InverseMultiquadraticKernel.cs	(revision 14872)
@@ -0,0 +1,58 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Algorithms.DataAnalysis {
+  [StorableClass]
+  [Item("InverseMultiquadraticKernel", "A kernel function that uses the inverse multiquadratic function")]
+  public class InverseMultiquadraticKernel : KernelBase {
+    #region HLConstructors & Boilerplate
+    [StorableConstructor]
+    protected InverseMultiquadraticKernel(bool deserializing) : base(deserializing) { }
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() { }
+    protected InverseMultiquadraticKernel(InverseMultiquadraticKernel original, Cloner cloner) : base(original, cloner) { }
+    public InverseMultiquadraticKernel() {
+      Parameters.Add(new FixedValueParameter<DoubleValue>(BetaParameterName, "The beta in the kernel function 1 / sqrt(1+||x-c||^2/beta)", new DoubleValue(2)));
+    }
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new InverseMultiquadraticKernel(this, cloner);
+    }
+    #endregion
+
+    protected override double Get(double norm) {
+      if (Math.Abs(Beta) < double.Epsilon) return 0;
+      return 1 / Math.Sqrt(1 + norm * norm / Beta);
+    }
+
+    protected override double GetGradient(double norm) {
+      if (Math.Abs(Beta) < double.Epsilon) return double.NaN;
+      norm *= norm;
+      return norm / (2 * Beta * Beta * Math.Pow((norm + Beta) / Beta, 1.5));
+    }
+  }
+}
Index: /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/KernelBase.cs
===================================================================
--- /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/KernelBase.cs	(revision 14871)
+++ /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/KernelBase.cs	(revision 14872)
@@ -31,5 +31,5 @@
 namespace HeuristicLab.Algorithms.DataAnalysis {
   [StorableClass]
-  public abstract class KernelBase<T> : ParameterizedNamedItem, IKernelFunction<T> {
+  public abstract class KernelBase : ParameterizedNamedItem, ICovarianceFunction {
 
     #region Parameternames
@@ -38,11 +38,9 @@
     #endregion
     #region Parameterproperties
-    public ValueParameter<IDistance<T>> DistanceParameter
-    {
-      get { return Parameters[DistanceParameterName] as ValueParameter<IDistance<T>>; }
+    public ValueParameter<IDistance> DistanceParameter {
+      get { return Parameters[DistanceParameterName] as ValueParameter<IDistance>; }
     }
 
-    public IFixedValueParameter<DoubleValue> BetaParameter
-    {
+    public IFixedValueParameter<DoubleValue> BetaParameter {
       get { return Parameters[BetaParameterName] as FixedValueParameter<DoubleValue>; }
     }
@@ -50,11 +48,9 @@
     #endregion
     #region Properties
-    public IDistance<T> Distance
-    {
+    public IDistance Distance {
       get { return DistanceParameter.Value; }
     }
 
-    public double Beta
-    {
+    public double Beta {
       get { return BetaParameter.Value.Value; }
     }
@@ -62,5 +58,4 @@
     #endregion
 
-    #region HLConstructors & Boilerplate
     [StorableConstructor]
     protected KernelBase(bool deserializing) : base(deserializing) { }
@@ -68,14 +63,13 @@
     private void AfterDeserialization() { }
 
-    protected KernelBase(KernelBase<T> original, Cloner cloner)
+    protected KernelBase(KernelBase original, Cloner cloner)
       : base(original, cloner) { }
 
     protected KernelBase() {
-      Parameters.Add(new ValueParameter<IDistance<T>>(DistanceParameterName, "The distance function used for kernel calculation"));
-      DistanceParameter.Value = new EuclidianDistance() as IDistance<T>;
+      Parameters.Add(new ValueParameter<IDistance>(DistanceParameterName, "The distance function used for kernel calculation"));
+      DistanceParameter.Value = new EuclideanDistance();
     }
-    #endregion
 
-    public double Get(T a, T b) {
+    public double Get(object a, object b) {
       return Get(Distance.Get(a, b));
     }
@@ -93,5 +87,5 @@
     public ParameterizedCovarianceFunction GetParameterizedCovarianceFunction(double[] p, int[] columnIndices) {
       if (p == null || p.Length != 1) throw new ArgumentException("Illegal parametrization");
-      var myClone = (KernelBase<T>)Clone(new Cloner());
+      var myClone = (KernelBase)Clone(new Cloner());
       myClone.BetaParameter.Value.Value = p[0];
       var cov = new ParameterizedCovarianceFunction {
@@ -107,5 +101,5 @@
     protected double GetNorm(double[,] x, double[,] xt, int i, int j, int[] columnIndices) {
       var dist = Distance as IDistance<IEnumerable<double>>;
-      if (dist == null) throw new ArgumentException("The Distance needs to apply to double-Vectors");
+      if (dist == null) throw new ArgumentException("The distance needs to apply to double vectors");
       var r1 = new IndexedEnumerable(x, i, columnIndices);
       var r2 = new IndexedEnumerable(xt, j, columnIndices);
@@ -142,13 +136,10 @@
       }
 
-      public double Current
-      {
+      public double Current {
         get { return data[row, column.Current]; }
       }
 
-      object IEnumerator.Current
-      {
-        get
-        {
+      object IEnumerator.Current {
+        get {
           return data[row, column.Current];
         }
Index: /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/LaplacianKernel.cs
===================================================================
--- /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/LaplacianKernel.cs	(revision 14871)
+++ /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/LaplacianKernel.cs	(revision 14872)
@@ -29,20 +29,17 @@
 namespace HeuristicLab.Algorithms.DataAnalysis {
   [StorableClass]
-  [Item("LaplacianKernel", "A kernel function that uses an exponential function.\nIt is equvalent to the Gaussiankernel but less suseptible to improper values of beta")]
-  public class LaplacianKernel<T> : KernelBase<T> {
-
-    #region HLConstructors & Boilerplate
+  [Item("LaplacianKernel", "A kernel function that uses an exponential function.\nIt is equvalent to the Gaussian kernel but less susceptible to improper values of beta")]
+  public class LaplacianKernel : KernelBase {
     [StorableConstructor]
     protected LaplacianKernel(bool deserializing) : base(deserializing) { }
     [StorableHook(HookType.AfterDeserialization)]
     private void AfterDeserialization() { }
-    protected LaplacianKernel(LaplacianKernel<T> original, Cloner cloner) : base(original, cloner) { }
+    protected LaplacianKernel(LaplacianKernel original, Cloner cloner) : base(original, cloner) { }
     public LaplacianKernel() {
-      Parameters.Add(new FixedValueParameter<DoubleValue>(BetaParameterName, "The beta in the kernelfunction exp(-||x-c||/beta)", new DoubleValue(2)));
+      Parameters.Add(new FixedValueParameter<DoubleValue>(BetaParameterName, "The beta in the kernel function exp(-||x-c||/beta)", new DoubleValue(2)));
     }
     public override IDeepCloneable Clone(Cloner cloner) {
-      return new LaplacianKernel<T>(this, cloner);
+      return new LaplacianKernel(this, cloner);
     }
-    #endregion
 
     protected override double Get(double norm) {
Index: /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/MultiquadraticKernel.cs
===================================================================
--- /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/MultiquadraticKernel.cs	(revision 14871)
+++ /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/MultiquadraticKernel.cs	(revision 14872)
@@ -30,5 +30,5 @@
   [StorableClass]
   [Item("MultiquadraticKernel", "A kernel function that uses the multiquadratic function")]
-  public class MultiquadraticKernel<T> : KernelBase<T> {
+  public class MultiquadraticKernel : KernelBase {
 
     #region HLConstructors & Boilerplate
@@ -37,12 +37,12 @@
     [StorableHook(HookType.AfterDeserialization)]
     private void AfterDeserialization() { }
-    protected MultiquadraticKernel(MultiquadraticKernel<T> original, Cloner cloner)
+    protected MultiquadraticKernel(MultiquadraticKernel original, Cloner cloner)
                 : base(original, cloner) { }
 
     public MultiquadraticKernel() {
-      Parameters.Add(new FixedValueParameter<DoubleValue>(BetaParameterName, "The beta in the kernelfunction sqrt(1+||x-c||²/beta)", new DoubleValue(2)));
+      Parameters.Add(new FixedValueParameter<DoubleValue>(BetaParameterName, "The beta in the kernel function sqrt(1+||x-c||²/beta)", new DoubleValue(2)));
     }
     public override IDeepCloneable Clone(Cloner cloner) {
-      return new MultiquadraticKernel<T>(this, cloner);
+      return new MultiquadraticKernel(this, cloner);
     }
     #endregion
Index: /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/PolysplineKernel.cs
===================================================================
--- /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/PolysplineKernel.cs	(revision 14871)
+++ /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/PolysplineKernel.cs	(revision 14872)
@@ -30,5 +30,5 @@
   [StorableClass]
   [Item("PolysplineKernel", "A kernel function that uses the multiquadratic function")]
-  public class PolysplineKernel<T> : KernelBase<T> {
+  public class PolysplineKernel : KernelBase {
 
     #region HLConstructors & Boilerplate
@@ -37,5 +37,5 @@
     [StorableHook(HookType.AfterDeserialization)]
     private void AfterDeserialization() { }
-    protected PolysplineKernel(PolysplineKernel<T> original, Cloner cloner)
+    protected PolysplineKernel(PolysplineKernel original, Cloner cloner)
                 : base(original, cloner) { }
     public PolysplineKernel() {
@@ -43,5 +43,5 @@
     }
     public override IDeepCloneable Clone(Cloner cloner) {
-      return new PolysplineKernel<T>(this, cloner);
+      return new PolysplineKernel(this, cloner);
     }
     #endregion
Index: /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/ThinPlatePolysplineKernel.cs
===================================================================
--- /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/ThinPlatePolysplineKernel.cs	(revision 14871)
+++ /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/KernelFunctions/ThinPlatePolysplineKernel.cs	(revision 14872)
@@ -30,5 +30,5 @@
   [StorableClass]
   [Item("ThinPlatePolysplineKernel", "A kernel function that uses the ThinPlatePolyspline function")]
-  public class ThinPlatePolysplineKernel<T> : KernelBase<T> {
+  public class ThinPlatePolysplineKernel : KernelBase {
     #region HLConstructors & Boilerplate
     [StorableConstructor]
@@ -36,10 +36,10 @@
     [StorableHook(HookType.AfterDeserialization)]
     private void AfterDeserialization() { }
-    protected ThinPlatePolysplineKernel(ThinPlatePolysplineKernel<T> original, Cloner cloner) : base(original, cloner) { }
+    protected ThinPlatePolysplineKernel(ThinPlatePolysplineKernel original, Cloner cloner) : base(original, cloner) { }
     public ThinPlatePolysplineKernel() {
       Parameters.Add(new FixedValueParameter<DoubleValue>(BetaParameterName, "The Beta in the kernelfunction ||x-c||^(2*Beta)*log(||x-c||^Beta)", new DoubleValue(1)));
     }
     public override IDeepCloneable Clone(Cloner cloner) {
-      return new ThinPlatePolysplineKernel<T>(this, cloner);
+      return new ThinPlatePolysplineKernel(this, cloner);
     }
     #endregion
Index: anches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/MatrixUtilities.cs
===================================================================
--- /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/MatrixUtilities.cs	(revision 14871)
+++ 	(revision )
@@ -1,239 +1,0 @@
-﻿#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using HeuristicLab.Data;
-
-namespace HeuristicLab.Algorithms.DataAnalysis {
-  internal static class MatrixUtilities {
-
-    public static T[,] To2D<T>(T[][] source) {
-      try {
-        var firstDim = source.Length;
-        var secondDim = source.GroupBy(row => row.Length).Single().Key; // throws InvalidOperationException if source is not rectangular
-        var result = new T[firstDim, secondDim];
-        for (var i = 0; i < firstDim; ++i)
-          for (var j = 0; j < secondDim; ++j)
-            result[i, j] = source[i][j];
-        return result;
-      }
-      catch (InvalidOperationException) {
-        throw new InvalidOperationException("The given jagged array is not rectangular.");
-      }
-    }
-
-    public static DoubleMatrix SortRows(this DoubleMatrix x, int c1) {
-      var sortable = new List<double[]>();
-      for (var i = 0; i < x.Rows; i++)
-        sortable.Add(SelectRow(x, i).ToArray());
-      return new DoubleMatrix(To2D(sortable.OrderBy(p => p[c1]).ToArray()));
-    }
-    public static DoubleMatrix Ones(int rows, int cols) {
-      var val = new double[rows, cols];
-      for (var i = 0; i < rows; i++)
-        for (var j = 0; j < cols; j++)
-          val[i, j] = 1;
-      return new DoubleMatrix(val);
-    }
-    public static DoubleMatrix Identity(int rows, int cols) {
-      var val = new double[rows, cols];
-      for (var i = 0; i < Math.Min(rows, cols); i++)
-        val[i, i] = 1;
-      return new DoubleMatrix(val);
-    }
-    public static DoubleMatrix Elementwise(this DoubleMatrix m, Func<double, double> func) {
-      var val = new double[m.Rows, m.Columns];
-      for (var i = 0; i < m.Rows; i++)
-        for (var j = 0; j < m.Columns; j++)
-          val[i, j] = func.Invoke(m[i, j]);
-      return new DoubleMatrix(val);
-    }
-    public static DoubleMatrix Elementwise(this DoubleMatrix m, DoubleMatrix m1, Func<double, double, double> func) {
-      if (m.Rows != m1.Rows || m.Columns != m1.Columns) throw new ArgumentException("Matrices are of different sizes");
-      var val = new double[m.Rows, m.Columns];
-      for (var i = 0; i < m.Rows; i++)
-        for (var j = 0; j < m.Columns; j++)
-          val[i, j] = func.Invoke(m[i, j], m1[i, j]);
-      return new DoubleMatrix(val);
-    }
-    public static DoubleMatrix Elementwise(this DoubleMatrix m, DoubleMatrix m1, DoubleMatrix m2, Func<double, double, double, double> func) {
-      if (m.Rows != m1.Rows || m.Columns != m1.Columns || m1.Rows != m2.Rows || m1.Columns != m2.Columns) throw new ArgumentException("Matrices are of different sizes");
-      var val = new double[m.Rows, m.Columns];
-      for (var i = 0; i < m.Rows; i++)
-        for (var j = 0; j < m.Columns; j++)
-          val[i, j] = func.Invoke(m[i, j], m1[i, j], m2[i, j]);
-      return new DoubleMatrix(val);
-    }
-    public static DoubleMatrix SelectRow(this DoubleMatrix m, int row) {
-      var m1 = new DoubleMatrix(1, m.Columns);
-      for (var i = 0; i < m.Columns; i++) m1[0, i] = m[row, i];
-      return m1;
-    }
-    public static DoubleMatrix SelectColumn(this DoubleMatrix m, int col) {
-      var m1 = new DoubleMatrix(m.Rows, 1);
-      for (var i = 0; i < m.Rows; i++) m1[i, 0] = m[i, col];
-      return m1;
-    }
-    public static DoubleMatrix RowBind(this DoubleMatrix m1, DoubleMatrix m2) {
-      if (m1.Columns != m2.Columns) throw new ArgumentException("Matrices need to have the same number of columns for RowBind");
-      var m = new DoubleMatrix(m1.Rows + m2.Rows, m1.Columns);
-      for (var i = 0; i < m1.Rows; i++)
-        for (var j = 0; j < m.Columns; j++)
-          m[i, j] = m1[i, j];
-      for (var i = 0; i < m2.Rows; i++)
-        for (var j = 0; j < m.Columns; j++)
-          m[i + m1.Rows, j] = m2[i, j];
-      return m;
-
-    }
-    public static DoubleMatrix ColumnBind(this DoubleMatrix m1, DoubleMatrix m2) {
-      if (m1.Rows != m2.Rows) throw new ArgumentException("Matrices need to have the same number of rows for ColumnBind");
-      var m = new DoubleMatrix(m1.Rows, m1.Columns + m1.Columns);
-      for (var i = 0; i < m1.Rows; i++) {
-        for (var j = 0; j < m1.Columns; j++)
-          m[i, j] = m1[i, j];
-        for (var j = 0; j < m2.Columns; j++)
-          m[i, j + m1.Columns] = m2[i, j];
-      }
-      return m;
-    }
-    public static DoubleMatrix Select(this DoubleMatrix m, int[] rows, int[] cols) {
-      var res = new DoubleMatrix(rows.Length, cols.Length);
-      for (var i = 0; i < res.Rows; i++) {
-        for (var j = 0; j < res.Columns; j++)
-          res[i, j] = m[rows[i], cols[j]];
-      }
-      return res;
-    }
-    public static DoubleMatrix Select(this DoubleMatrix m, int[] rows) {
-      return Select(m, rows, GetIndexVector(m.Columns));
-    }
-    public static int[] GetIndexVector(int size) {
-      var res = new int[size];
-      for (var i = 0; i < size; i++)
-        res[i] = i;
-      return res;
-    }
-    public static DoubleMatrix Transpose(this DoubleMatrix m) {
-      var res = new DoubleMatrix(m.Columns, m.Rows);
-      for (var i = 0; i < res.Rows; i++)
-        for (var j = 0; j < res.Columns; j++)
-          res[i, j] = m[j, i];
-      return res;
-    }
-    public static DoubleMatrix ToRow(IEnumerable<double> values) {
-      var arr = values.ToArray();
-      var res = new DoubleMatrix(1, arr.Length);
-      for (var i = 0; i < arr.Length; i++) res[0, i] = arr[i];
-      return res;
-    }
-    public static double[] Min(this DoubleMatrix m, int dim) {
-      if (dim != 0 && dim != 1) throw new ArgumentException("Can only find the minimum along rows or colums");
-      var res = new double[dim == 0 ? m.Rows : m.Columns];
-      for (var i = 0; i < res.Length; i++)
-        res[i] = (dim == 0 ? SelectRow(m, i) : SelectColumn(m, i)).Min();
-      return res;
-    }
-    public static double[] Max(this DoubleMatrix m, int dim) {
-      if (dim != 0 && dim != 1) throw new ArgumentException("Can only find the minimum along rows or colums");
-      var res = new double[dim == 0 ? m.Rows : m.Columns];
-      for (var i = 0; i < res.Length; i++)
-        res[i] = (dim == 0 ? SelectRow(m, i) : SelectColumn(m, i)).Max();
-      return res;
-    }
-    public static double[] GetElementVector(int size) {
-      var res = new double[size];
-      for (var d = 1; d <= size; d++) {
-        res[d - 1] = d;
-      }
-      return res;
-    }
-    public static double[] GetRange(double min, double max, int length) {
-      if (length < 2 || min > max) throw new ArgumentException("can not create range of length: " + length + " from " + min + " to " + max);
-      var res = new double[length];
-      var step = (max - min) / (length - 1);
-      res[0] = min;
-      for (var i = 1; i < length; i++)
-        res[i] = step + res[i - 1];
-      return res;
-    }
-    public static int[] GetRange(int min, int max) {
-      if (min > max) throw new ArgumentException("can not create range from " + min + " to " + max);
-      var res = new int[max - min + 1];
-      var i = 0;
-      for (var v = min; v <= max; v++)
-        res[i++] = v;
-      return res;
-    }
-    public static bool IsEqualTo(this DoubleMatrix m1, DoubleMatrix m2) {
-      if (m1.Rows != m2.Rows) return false;
-      if (m1.Columns != m2.Columns) return false;
-      return m1.SequenceEqual(m2);
-    }
-    public static DoubleMatrix ToColumnVector(this IEnumerable<double> values) {
-      var arr = values.ToArray();
-      var res = new DoubleMatrix(arr.Length, 1);
-      for (var i = 0; i < arr.Length; i++)
-        res[i, 0] = arr[i];
-      return res;
-    }
-    public static DoubleMatrix ToMatrix<T>(this IEnumerable<T> rows) where T : IEnumerable<double> {
-      return new DoubleMatrix(To2D(rows.Select(x => x.ToArray()).ToArray())); //not the fastest way to do it
-
-    }
-
-    /// <summary>
-    /// m need to be symmetric positive definit
-    /// </summary>
-    /// <param name="m"></param>
-    /// <returns></returns>
-    public static DoubleMatrix Invert(this DoubleMatrix m) {
-      int info;
-      alglib.matinvreport report;
-      var upper = m.CloneAsMatrix();
-      alglib.rmatrixinverse(ref upper, out info, out report);
-      if (info != 1) throw new ArgumentException("Could not invert matrix. Is ist quadratic symmetric positive definite?");
-      return new DoubleMatrix(upper);
-    }
-    public static DoubleMatrix Mul(this DoubleMatrix left, DoubleMatrix right) {
-      if (left.Columns != right.Rows) throw new ArgumentException("Dims dont match");
-      var res = new double[left.Rows, right.Columns];
-      alglib.rmatrixgemm(left.Rows, right.Columns, left.Columns, 1, left.CloneAsMatrix(), 0, 0, 0, right.CloneAsMatrix(), 0, 0, 0, 0, ref res, 0, 0);
-      return new DoubleMatrix(res);
-    }
-    public static DoubleMatrix Solve(this DoubleMatrix a, DoubleMatrix b) {
-      if (b.Columns != 1 || a.Rows != b.Rows) throw new ArgumentException("This system can not be solved due to dimensions");
-      var b1 = b.ToArray();
-      double[] x;
-      int info;
-      alglib.densesolverlsreport denseSolveRep;//what is this used for? In HeuristicLab.Algorithms.DataAnalysis.GaussianProcessSurrogate is a use-case similar to this one. What do you normally do with the rep?
-      alglib.rmatrixsolvels(a.CloneAsMatrix(), a.Rows, a.Columns, b1, 0.0, out info, out denseSolveRep, out x);
-      if (info != 1) {
-        throw new ArgumentException("This system can not be solved due to content or numerics");
-      }
-
-      return x.ToColumnVector();
-    }
-
-  }
-}
Index: /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/RadialBasisFunctionModel.cs
===================================================================
--- /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/RadialBasisFunctionModel.cs	(revision 14871)
+++ /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/RadialBasisFunctionModel.cs	(revision 14872)
@@ -1,3 +1,3 @@
-#region License Information
+﻿#region License Information
 /* HeuristicLab
  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
@@ -22,8 +22,8 @@
 using System;
 using System.Collections.Generic;
+using System.Diagnostics;
 using System.Linq;
 using HeuristicLab.Common;
 using HeuristicLab.Core;
-using HeuristicLab.Data;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
 using HeuristicLab.Problems.DataAnalysis;
@@ -31,32 +31,35 @@
 namespace HeuristicLab.Algorithms.DataAnalysis {
   /// <summary>
-  /// Represents a Radial Basis Function regression model.
+  /// Represents an RBF regression model.
   /// </summary>
   [StorableClass]
-  [Item("RBFModel", "Represents a Gaussian process posterior.")]
+  [Item("RBFModel", "An RBF regression model")]
   public sealed class RadialBasisFunctionModel : RegressionModel, IConfidenceRegressionModel {
-    public override IEnumerable<string> VariablesUsedForPrediction
-    {
+    public override IEnumerable<string> VariablesUsedForPrediction {
       get { return allowedInputVariables; }
     }
 
     [Storable]
-    private string[] allowedInputVariables;
-    public string[] AllowedInputVariables
-    {
+    private readonly string[] allowedInputVariables;
+    public string[] AllowedInputVariables {
       get { return allowedInputVariables; }
     }
 
     [Storable]
-    private double[] alpha;
-    [Storable]
-    private IDataset trainingDataset; // it is better to store the original training dataset completely because this is more efficient in persistence
-    [Storable]
-    private int[] trainingRows;
-    [Storable]
-    private IKernelFunction<double[]> kernel;
-    [Storable]
-    private DoubleMatrix gramInvert;
-
+    private readonly double[] alpha;
+
+    [Storable]
+    private readonly double[,] trainX; // it is better to store the original training dataset completely because this is more efficient in persistence
+
+    [Storable]
+    private readonly ITransformation<double>[] scaling;
+
+    [Storable]
+    private readonly ICovarianceFunction kernel;
+
+    private double[,] gramInvert; // not storable as it can be large (recreate after deserialization as required)
+
+    [Storable]
+    private readonly double meanOffset; // implementation works for zero-mean target variables
 
     [StorableConstructor]
@@ -65,35 +68,80 @@
       : base(original, cloner) {
       // shallow copies of arrays because they cannot be modified
-      trainingRows = original.trainingRows;
       allowedInputVariables = original.allowedInputVariables;
       alpha = original.alpha;
-      trainingDataset = original.trainingDataset;
-      kernel = original.kernel;
-    }
-    public RadialBasisFunctionModel(IDataset dataset, string targetVariable, IEnumerable<string> allowedInputVariables, IEnumerable<int> rows, IKernelFunction<double[]> kernel)
+      trainX = original.trainX;
+      gramInvert = original.gramInvert;
+      scaling = original.scaling;
+
+      meanOffset = original.meanOffset;
+      if (original.kernel != null)
+        kernel = cloner.Clone(original.kernel);
+    }
+    public RadialBasisFunctionModel(IDataset dataset, string targetVariable, IEnumerable<string> allowedInputVariables, IEnumerable<int> rows,
+      bool scaleInputs, ICovarianceFunction kernel)
       : base(targetVariable) {
+      if (kernel.GetNumberOfParameters(allowedInputVariables.Count()) > 0) throw new ArgumentException("All parameters in the kernel function must be specified.");
       name = ItemName;
       description = ItemDescription;
       this.allowedInputVariables = allowedInputVariables.ToArray();
-      trainingRows = rows.ToArray();
-      trainingDataset = dataset;
-      this.kernel = (IKernelFunction<double[]>)kernel.Clone();
+      var trainingRows = rows.ToArray();
+      this.kernel = (ICovarianceFunction)kernel.Clone();
       try {
-        var data = ExtractData(dataset, trainingRows);
-        var qualities = dataset.GetDoubleValues(targetVariable, trainingRows).ToArray();
+        if (scaleInputs)
+          scaling = CreateScaling(dataset, trainingRows);
+        trainX = ExtractData(dataset, trainingRows, scaling);
+        var y = dataset.GetDoubleValues(targetVariable, trainingRows).ToArray();
+        meanOffset = y.Average();
+        for (int i = 0; i < y.Length; i++) y[i] -= meanOffset;
         int info;
+        // TODO: improve efficiency by decomposing matrix once instead of solving the system and then inverting the matrix
         alglib.densesolverlsreport denseSolveRep;
-        var gr = BuildGramMatrix(data);
-        alglib.rmatrixsolvels(gr, data.Length + 1, data.Length + 1, qualities.Concat(new[] { 0.0 }).ToArray(), 0.0, out info, out denseSolveRep, out alpha);
-        if (info != 1) throw new ArgumentException("Could not create Model.");
-        gramInvert = new DoubleMatrix(gr).Invert();
-      }
-      catch (alglib.alglibexception ae) {
+        gramInvert = BuildGramMatrix(trainX);
+        int n = trainX.GetLength(0);
+        alglib.rmatrixsolvels(gramInvert, n, n, y, 0.0, out info, out denseSolveRep, out alpha);
+        if (info != 1) throw new ArgumentException("Could not create model.");
+
+        alglib.matinvreport report;
+        alglib.rmatrixinverse(ref gramInvert, out info, out report);
+        if (info != 1) throw new ArgumentException("Could not invert matrix. Is it quadratic symmetric positive definite?");
+
+      } catch (alglib.alglibexception ae) {
         // wrap exception so that calling code doesn't have to know about alglib implementation
-        throw new ArgumentException("There was a problem in the calculation of the RBF process model", ae);
-      }
-    }
-    private double[][] ExtractData(IDataset dataset, IEnumerable<int> rows) {
-      return rows.Select(r => allowedInputVariables.Select(v => dataset.GetDoubleValue(v, r)).ToArray()).ToArray();
+        throw new ArgumentException("There was a problem in the calculation of the RBF model", ae);
+      }
+    }
+
+    private ITransformation<double>[] CreateScaling(IDataset dataset, int[] rows) {
+      var trans = new ITransformation<double>[allowedInputVariables.Length];
+      int i = 0;
+      foreach (var variable in allowedInputVariables) {
+        var lin = new LinearTransformation(allowedInputVariables);
+        var max = dataset.GetDoubleValues(variable, rows).Max();
+        var min = dataset.GetDoubleValues(variable, rows).Min();
+        lin.Multiplier = 1.0 / (max - min);
+        lin.Addend = -min / (max - min);
+        trans[i] = lin;
+        i++;
+      }
+      return trans;
+    }
+
+    private double[,] ExtractData(IDataset dataset, IEnumerable<int> rows, ITransformation<double>[] scaling = null) {
+      double[][] variables;
+      if (scaling != null) {
+        variables =
+          allowedInputVariables.Select((var, i) => scaling[i].Apply(dataset.GetDoubleValues(var, rows)).ToArray())
+            .ToArray();
+      } else {
+        variables =
+        allowedInputVariables.Select(var => dataset.GetDoubleValues(var, rows).ToArray()).ToArray();
+      }
+      int n = variables.First().Length;
+      var res = new double[n, variables.Length];
+      for (int r = 0; r < n; r++)
+        for (int c = 0; c < variables.Length; c++) {
+          res[r, c] = variables[c][r];
+        }
+      return res;
     }
 
@@ -104,38 +152,86 @@
     #region IRegressionModel Members
     public override IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) {
-      var solutions = ExtractData(dataset, rows);
-      var data = ExtractData(trainingDataset, trainingRows);
-      return solutions.Select(solution => alpha.Zip(data, (a, d) => a * kernel.Get(solution, d)).Sum() + 1 * alpha[alpha.Length - 1]).ToArray();
+      var newX = ExtractData(dataset, rows, scaling);
+      var dim = newX.GetLength(1);
+      var cov = kernel.GetParameterizedCovarianceFunction(new double[0], Enumerable.Range(0, dim).ToArray());
+
+      var pred = new double[newX.GetLength(0)];
+      for (int i = 0; i < pred.Length; i++) {
+        double sum = meanOffset;
+        for (int j = 0; j < alpha.Length; j++) {
+          sum += alpha[j] * cov.CrossCovariance(trainX, newX, j, i);
+        }
+        pred[i] = sum;
+      }
+      return pred;
     }
     public override IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {
-      return new RadialBasisFunctionRegressionSolution(this, new RegressionProblemData(problemData));
+      return new ConfidenceRegressionSolution(this, new RegressionProblemData(problemData));
     }
     #endregion
 
     public IEnumerable<double> GetEstimatedVariances(IDataset dataset, IEnumerable<int> rows) {
-      var data = ExtractData(trainingDataset, trainingRows);
-      return ExtractData(dataset, rows).Select(x => GetVariance(x, data));
+      if (gramInvert == null) CreateAndInvertGramMatrix();
+      int n = gramInvert.GetLength(0);
+      var newData = ExtractData(dataset, rows, scaling);
+      var dim = newData.GetLength(1);
+      var cov = kernel.GetParameterizedCovarianceFunction(new double[0], Enumerable.Range(0, dim).ToArray());
+
+      // TODO perf (matrix matrix multiplication)
+      for (int i = 0; i < newData.GetLength(0); i++) {
+        double[] p = new double[n];
+
+        for (int j = 0; j < trainX.GetLength(0); j++) {
+          p[j] = cov.CrossCovariance(trainX, newData, j, i);
+        }
+
+        var Ap = new double[n];
+        alglib.ablas.rmatrixmv(n, n, gramInvert, 0, 0, 0, p, 0, ref Ap, 0);
+        var res = 0.0;
+        // dot product
+        for (int j = 0; j < p.Length; j++) res += p[j] * Ap[j];
+        yield return res > 0 ? res : 0;
+      }
     }
     public double LeaveOneOutCrossValidationRootMeanSquaredError() {
-      return Math.Sqrt(alpha.Select((t, i) => t / gramInvert[i, i]).Sum(d => d * d) / gramInvert.Rows);
-    }
-
+      if (gramInvert == null) CreateAndInvertGramMatrix();
+      var n = gramInvert.GetLength(0);
+      var s = 1.0 / n;
+
+      var sum = 0.0;
+      for (int i = 0; i < alpha.Length; i++) {
+        var x = alpha[i] / gramInvert[i, i];
+        sum += x * x;
+      }
+      sum *= s;
+      return Math.Sqrt(sum);
+    }
+
+    private void CreateAndInvertGramMatrix() {
+      try {
+        gramInvert = BuildGramMatrix(trainX);
+        int info = 0;
+        alglib.matinvreport report;
+        alglib.rmatrixinverse(ref gramInvert, out info, out report);
+        if (info != 1)
+          throw new ArgumentException("Could not invert matrix. Is it quadratic symmetric positive definite?");
+      } catch (alglib.alglibexception) {
+        // wrap exception so that calling code doesn't have to know about alglib implementation
+        throw new ArgumentException("Could not invert matrix. Is it quadratic symmetric positive definite?");
+      }
+    }
     #region helpers
-    private double[,] BuildGramMatrix(double[][] data) {
-      var size = data.Length + 1;
-      var gram = new double[size, size];
-      for (var i = 0; i < size; i++)
-        for (var j = i; j < size; j++) {
-          if (j == size - 1 && i == size - 1) gram[i, j] = 0;
-          else if (j == size - 1 || i == size - 1) gram[j, i] = gram[i, j] = 1;
-          else gram[j, i] = gram[i, j] = kernel.Get(data[i], data[j]); //symmteric Matrix --> half of the work
+    private double[,] BuildGramMatrix(double[,] data) {
+      var n = data.GetLength(0);
+      var dim = data.GetLength(1);
+      var cov = kernel.GetParameterizedCovarianceFunction(new double[0], Enumerable.Range(0, dim).ToArray());
+      var gram = new double[n, n];
+      for (var i = 0; i < n; i++)
+        for (var j = i; j < n; j++) {
+          gram[j, i] = gram[i, j] = cov.Covariance(data, i, j); // symmetric matrix --> half of the work
         }
       return gram;
     }
-    private double GetVariance(double[] solution, IEnumerable<double[]> data) {
-      var phiT = data.Select(x => kernel.Get(x, solution)).Concat(new[] { 1.0 }).ToColumnVector();
-      var res = phiT.Transpose().Mul(gramInvert.Mul(phiT))[0, 0];
-      return res > 0 ? res : 0;
-    }
+
     #endregion
   }
Index: anches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/RadialBasisFunctionRegressionSolution.cs
===================================================================
--- /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/RadialBasisFunctionRegressionSolution.cs	(revision 14871)
+++ 	(revision )
@@ -1,49 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using HeuristicLab.Algorithms.DataAnalysis;
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-using HeuristicLab.Problems.DataAnalysis;
-
-namespace HeuristicLab.Algorithms.DataAnalysis {
-  /// <summary>
-  /// Represents a Radial Basis Function regression solution for a regression problem which can be visualized in the GUI.
-  /// </summary>
-  [Item("RBFRegressionSolution", "Represents an RBF solution for a regression problem which can be visualized in the GUI.")]
-  [StorableClass]
-  public sealed class RadialBasisFunctionRegressionSolution : ConfidenceRegressionSolution {
-
-    [StorableConstructor]
-    private RadialBasisFunctionRegressionSolution(bool deserializing)
-      : base(deserializing) {
-    }
-    private RadialBasisFunctionRegressionSolution(RadialBasisFunctionRegressionSolution original, Cloner cloner)
-      : base(original, cloner) { }
-    public RadialBasisFunctionRegressionSolution(RadialBasisFunctionModel model, IRegressionProblemData problemData)
-      : base(model, problemData) { }
-
-    public override IDeepCloneable Clone(Cloner cloner) {
-      return new RadialBasisFunctionRegressionSolution(this, cloner);
-    }
-  }
-}
Index: /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/RadialBasisRegression.cs
===================================================================
--- /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/RadialBasisRegression.cs	(revision 14871)
+++ /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/RadialBasisFunctions/RadialBasisRegression.cs	(revision 14872)
@@ -22,4 +22,5 @@
 using System;
 using System.Linq;
+using System.Threading;
 using HeuristicLab.Common;
 using HeuristicLab.Core;
@@ -34,26 +35,44 @@
   /// Linear regression data analysis algorithm.
   /// </summary>
-  [Item("Radial Basis Function Regression (RBF-R)", "Radial basis function regression data analysis algorithm (uses for ALGLIB).")]
+  [Item("Radial Basis Function Regression (RBF-R)", "Radial basis function regression data analysis algorithm.")]
   [Creatable(CreatableAttribute.Categories.DataAnalysisRegression, Priority = 100)]
   [StorableClass]
-  public sealed class RadialBasisRegression : FixedDataAnalysisAlgorithm<IRegressionProblem> {
-    private const string RadialBasisRegressionModelResultName = "RBF regression solution";
+  public sealed class RadialBasisRegression : BasicAlgorithm {
+    private const string RBFRegressionSolutionResultName = "RBF regression solution";
 
+    public override bool SupportsPause {
+      get { return false; }
+    }
+    public override Type ProblemType {
+      get { return typeof(IRegressionProblem); }
+    }
+    public new IRegressionProblem Problem {
+      get { return (IRegressionProblem)base.Problem; }
+      set { base.Problem = value; }
+    }
 
-    #region Parameternames
-    private const string Kernelname = "Kernel";
+    #region parameter names
+    private const string KernelParameterName = "Kernel";
+    private const string ScaleInputVariablesParameterName = "ScaleInputVariables";
     #endregion
 
-    #region Paramterproperties
-    public ValueParameter<IKernelFunction<double[]>> KernelParameter
-    {
-      get { return Parameters[Kernelname] as ValueParameter<IKernelFunction<double[]>>; }
+    #region parameter properties
+    public ValueParameter<ICovarianceFunction> KernelParameter {
+      get { return (ValueParameter<ICovarianceFunction>)Parameters[KernelParameterName]; }
+    }
+
+    public IFixedValueParameter<BoolValue> ScaleInputVariablesParameter {
+      get { return (IFixedValueParameter<BoolValue>)Parameters[ScaleInputVariablesParameterName]; }
     }
     #endregion
 
-    #region Properties
-    public IKernelFunction<double[]> Kernel
-    {
+    #region properties
+    public ICovarianceFunction Kernel {
       get { return KernelParameter.Value; }
+    }
+
+    public bool ScaleInputVariables {
+      get { return ScaleInputVariablesParameter.Value.Value; }
+      set { ScaleInputVariablesParameter.Value.Value = value; }
     }
 
@@ -67,8 +86,8 @@
     public RadialBasisRegression() {
       Problem = new RegressionProblem();
-      Parameters.Add(new ValueParameter<IKernelFunction<double[]>>(Kernelname, "The radial basis function"));
-      var kernel = new PolysplineKernel<double[]>();
+      Parameters.Add(new ValueParameter<ICovarianceFunction>(KernelParameterName, "The radial basis function"));
+      Parameters.Add(new FixedValueParameter<BoolValue>(ScaleInputVariablesParameterName, "Set to true if the input variables should be scaled to the interval [0..1]", new BoolValue(true)));
+      var kernel = new GaussianKernel();
       KernelParameter.Value = kernel;
-      kernel.BetaParameter.Value.Value = 1;
     }
     [StorableHook(HookType.AfterDeserialization)]
@@ -79,28 +98,23 @@
     }
 
-    #region regression
-    protected override void Run() {
-      double loocvrmse, cvRmsError;
-      var solution = CreateRadialBasisRegressionSolution(Problem.ProblemData, Kernel, out loocvrmse, out cvRmsError);
-      Results.Add(new Result(RadialBasisRegressionModelResultName, "The RBF regression solution.", solution));
-      Results.Add(new Result("LOOCVRMSE", "The root of the mean of squared errors of a leave-one-out-cross-validation on the trainingsset (This is not the RSME on the trainingset)", new DoubleValue(loocvrmse)));
-      Results.Add(new Result("Estimated root mean square error (cross-validation)", "The estimated root of the mean of squared errors of the linear regression solution via cross validation.", new DoubleValue(cvRmsError)));
+    protected override void Run(CancellationToken cancellationToken) {
+      double loocvrmse, rmsError;
+      var solution = CreateRadialBasisRegressionSolution(Problem.ProblemData, Kernel, ScaleInputVariables, out loocvrmse, out rmsError);
+      Results.Add(new Result(RBFRegressionSolutionResultName, "The RBF regression solution.", solution));
+      Results.Add(new Result("LOOCVRMSE", "The root mean squared error of a leave-one-out-cross-validation on the training set", new DoubleValue(loocvrmse)));
+      Results.Add(new Result("RMSE (test)", "The root mean squared error of the solution on the test set.", new DoubleValue(rmsError)));
     }
 
-    public static IConfidenceRegressionSolution CreateRadialBasisRegressionSolution(IRegressionProblemData problemData, IKernelFunction<double[]> kernel, out double loocvRmsError, out double cvRmsError) {
-      var model = new RadialBasisFunctionModel(problemData.Dataset, problemData.TargetVariable, problemData.AllowedInputVariables, problemData.TrainingIndices, kernel);
+    public static IRegressionSolution CreateRadialBasisRegressionSolution(IRegressionProblemData problemData, ICovarianceFunction kernel, bool scaleInputs, out double loocvRmsError, out double rmsError) {
+      var model = new RadialBasisFunctionModel(problemData.Dataset, problemData.TargetVariable, problemData.AllowedInputVariables, problemData.TrainingIndices, scaleInputs, kernel);
       loocvRmsError = model.LeaveOneOutCrossValidationRootMeanSquaredError();
-      cvRmsError = Math.Sqrt(model.GetEstimatedValues(problemData.Dataset, problemData.TestIndices)
+      rmsError = Math.Sqrt(model.GetEstimatedValues(problemData.Dataset, problemData.TestIndices)
         .Zip(problemData.TargetVariableTestValues, (a, b) => (a - b) * (a - b))
-        .Sum());
-      var solution = (RadialBasisFunctionRegressionSolution)model.CreateRegressionSolution((IRegressionProblemData)problemData.Clone());
-      solution.Model.Name = "Radial Basis Regression Model";
-      solution.Name = "Radial Basis Regression Solution";
+        .Average());
+      var solution = model.CreateRegressionSolution((IRegressionProblemData)problemData.Clone());
+      solution.Model.Name = "RBF Regression Model";
+      solution.Name = "RBF Regression Solution";
       return solution;
     }
-    #endregion
-
-    #region helpers
-    #endregion
   }
 }
Index: /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/TSNE/Distances/DistanceBase.cs
===================================================================
--- /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/TSNE/Distances/DistanceBase.cs	(revision 14871)
+++ /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/TSNE/Distances/DistanceBase.cs	(revision 14872)
@@ -19,5 +19,5 @@
  */
 #endregion
-
+using System.Collections;
 using System.Collections.Generic;
 using HeuristicLab.Common;
@@ -42,5 +42,5 @@
     }
 
-    private class DistanceComparer : IComparer<T> {
+    private class DistanceComparer : IComparer<T>, IComparer {
       private readonly T item;
       private readonly IDistance<T> dist;
@@ -54,4 +54,16 @@
         return dist.Get(x, item).CompareTo(dist.Get(y, item));
       }
+
+      public int Compare(object x, object y) {
+        return Compare((T)x, (T)y);
+      }
+    }
+
+    public double Get(object x, object y) {
+      return Get((T)x, (T)y);
+    }
+
+    public IComparer GetDistanceComparer(object item) {
+      return new DistanceComparer((T)item, this);
     }
   }
Index: /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/TSNE/Interfaces/IDistance.cs
===================================================================
--- /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/TSNE/Interfaces/IDistance.cs	(revision 14871)
+++ /branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/TSNE/Interfaces/IDistance.cs	(revision 14872)
@@ -19,10 +19,10 @@
  */
 #endregion
-
+using System.Collections;
 using System.Collections.Generic;
 using HeuristicLab.Core;
 
 namespace HeuristicLab.Algorithms.DataAnalysis {
-  public interface IDistance<in T> : IItem {
+  public interface IDistance<in T> : IDistance {
     /// <summary>
     /// Calculates a distance measure between two objects.
@@ -41,3 +41,8 @@
     IComparer<T> GetDistanceComparer(T item);
   }
+
+  public interface IDistance : IItem {
+    double Get(object x, object y);
+    IComparer GetDistanceComparer(object item);
+  }
 }
