Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceLinearArd.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceLinearArd.cs	(revision 8932)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceLinearArd.cs	(revision 8933)
@@ -99,6 +99,8 @@
       if (columnIndices == null) columnIndices = Enumerable.Range(0, x.GetLength(1));
 
+      int k = 0;
       foreach (int columnIndex in columnIndices) {
-        yield return -2.0 * x[i, columnIndex] * x[j, columnIndex] * inverseLength[columnIndex] * inverseLength[columnIndex];
+        yield return -2.0 * x[i, columnIndex] * x[j, columnIndex] * inverseLength[k] * inverseLength[k];
+        k++;
       }
     }
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceMask.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceMask.cs	(revision 8932)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceMask.cs	(revision 8933)
@@ -20,4 +20,5 @@
 #endregion
 
+using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -111,12 +112,23 @@
 
     public double GetCovariance(double[,] x, int i, int j, IEnumerable<int> columnIndices) {
+      // cov mask overwrites the previously selected columnIndices 
+      // -> stacking of CovarianceMask is not supported
+      if (columnIndices != null && columnIndices.Count() != x.GetLength(1))
+        throw new InvalidOperationException("Stacking of masking covariance functions is not supported.");
+
       return cov.GetCovariance(x, i, j, selectedDimensions);
     }
 
     public IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices) {
+      if (columnIndices != null && columnIndices.Count() != x.GetLength(1))
+        throw new InvalidOperationException("Stacking of masking covariance functions is not supported.");
+
       return cov.GetGradient(x, i, j, selectedDimensions);
     }
 
     public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable<int> columnIndices) {
+      if (columnIndices != null && columnIndices.Count() != x.GetLength(1))
+        throw new InvalidOperationException("Stacking of masking covariance functions is not supported.");
+
       return cov.GetCrossCovariance(x, xt, i, j, selectedDimensions);
     }
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceRationalQuadraticArd.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceRationalQuadraticArd.cs	(revision 8932)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceRationalQuadraticArd.cs	(revision 8933)
@@ -148,6 +148,8 @@
                    : Util.SqrDist(x, i, j, inverseLength, columnIndices);
       double b = 1 + 0.5 * d / shape;
+      int k = 0;
       foreach (var columnIndex in columnIndices) {
-        yield return sf2 * Math.Pow(b, -shape - 1) * Util.SqrDist(x[i, columnIndex] * inverseLength[columnIndex], x[j, columnIndex] * inverseLength[columnIndex]);
+        yield return sf2 * Math.Pow(b, -shape - 1) * Util.SqrDist(x[i, columnIndex] * inverseLength[k], x[j, columnIndex] * inverseLength[k]);
+        k++;
       }
       yield return 2 * sf2 * Math.Pow(b, -shape);
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSquaredExponentialArd.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSquaredExponentialArd.cs	(revision 8932)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSquaredExponentialArd.cs	(revision 8933)
@@ -122,8 +122,9 @@
                    ? 0.0
                    : Util.SqrDist(x, i, j, inverseLength, columnIndices);
-
+      int k = 0;
       foreach (var columnIndex in columnIndices) {
-        double sqrDist = Util.SqrDist(x[i, columnIndex] * inverseLength[columnIndex], x[j, columnIndex] * inverseLength[columnIndex]);
+        double sqrDist = Util.SqrDist(x[i, columnIndex] * inverseLength[k], x[j, columnIndex] * inverseLength[k]);
         yield return sf2 * Math.Exp(-d / 2.0) * sqrDist;
+        k++;
       }
 
