Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceProd.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceProd.cs	(revision 8435)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceProd.cs	(revision 8439)
@@ -87,5 +87,20 @@
 
     public double[] GetGradient(int i, int j) {
-      return factors.Select(t => t.GetGradient(i, j)).SelectMany(seq => seq).ToArray();
+      return Enumerable.Range(0, GetNumberOfParameters(numberOfVariables)).Select(k => GetGradient(i, j, k)).ToArray();
+    }
+    public double GetGradient(int i, int j, int k) {
+      // map from parameter index to factor
+      var vi = factors.Select((f, idx) => Enumerable.Repeat(idx, f.GetNumberOfParameters(numberOfVariables))).SelectMany(x => x).ToArray();
+      double res = 1.0;
+      int jj = Enumerable.Range(0, k).Count(e => vi[e] == vi[k]);
+      for (int ii = 0; ii < factors.Count; ii++) {
+        var f = factors[ii];
+        if (ii == vi[k]) {
+          res *= f.GetGradient(i, j)[jj];
+        } else {
+          res *= f.GetCovariance(i, j);
+        }
+      }
+      return res;
     }
   }
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanProd.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanProd.cs	(revision 8439)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanProd.cs	(revision 8439)
@@ -0,0 +1,105 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Algorithms.DataAnalysis {
+  [StorableClass]
+  [Item(Name = "MeanProd", Description = "Product of mean functions for Gaussian processes.")]
+  public class MeanProd : Item, IMeanFunction {
+    [Storable]
+    private ItemList<IMeanFunction> factors;
+
+    [Storable]
+    private int numberOfVariables;
+
+    public ItemList<IMeanFunction> Factors {
+      get { return factors; }
+    }
+
+    public int GetNumberOfParameters(int numberOfVariables) {
+      this.numberOfVariables = numberOfVariables;
+      return factors.Select(t => t.GetNumberOfParameters(numberOfVariables)).Sum();
+    }
+
+    [StorableConstructor]
+    protected MeanProd(bool deserializing)
+      : base(deserializing) {
+    }
+
+    protected MeanProd(MeanProd original, Cloner cloner)
+      : base(original, cloner) {
+      this.factors = cloner.Clone(original.factors);
+      this.numberOfVariables = original.numberOfVariables;
+    }
+
+    public MeanProd() {
+      this.factors = new ItemList<IMeanFunction>();
+    }
+
+    public void SetParameter(double[] hyp) {
+      int offset = 0;
+      foreach (var t in factors) {
+        var numberOfParameters = t.GetNumberOfParameters(numberOfVariables);
+        t.SetParameter(hyp.Skip(offset).Take(numberOfParameters).ToArray());
+        offset += numberOfParameters;
+      }
+    }
+
+    public void SetData(double[,] x) {
+      foreach (var t in factors) t.SetData(x);
+    }
+
+    public double[] GetMean(double[,] x) {
+      var res = factors.First().GetMean(x);
+      foreach (var t in factors.Skip(1)) {
+        var a = t.GetMean(x);
+        for (int i = 0; i < res.Length; i++) res[i] *= a[i];
+      }
+      return res;
+    }
+
+    public double[] GetGradients(int k, double[,] x) {
+      double[] res = Enumerable.Repeat(1.0, x.GetLength(0)).ToArray();
+      foreach (var f in factors) {
+        var numParam = f.GetNumberOfParameters(numberOfVariables);
+        if (k >= 0 && k < numParam) {
+          // multiply gradient
+          var g = f.GetGradients(k, x);
+          for (int i = 0; i < res.Length; i++) res[i] *= g[i];
+          k -= numParam;
+        } else {
+          // multiply mean
+          var m = f.GetMean(x);
+          for (int i = 0; i < res.Length; i++) res[i] *= m[i];
+          k -= numParam;
+        }
+      }
+      return res;
+    }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new MeanProd(this, cloner);
+    }
+  }
+}
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanSum.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanSum.cs	(revision 8439)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanSum.cs	(revision 8439)
@@ -0,0 +1,89 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Algorithms.DataAnalysis {
+  [StorableClass]
+  [Item(Name = "MeanSum", Description = "Sum of mean functions for Gaussian processes.")]
+  public class MeanSum : Item, IMeanFunction {
+    [Storable]
+    private ItemList<IMeanFunction> terms;
+
+    [Storable]
+    private int numberOfVariables;
+    public ItemList<IMeanFunction> Terms {
+      get { return terms; }
+    }
+
+    public int GetNumberOfParameters(int numberOfVariables) {
+      this.numberOfVariables = numberOfVariables;
+      return terms.Select(t => t.GetNumberOfParameters(numberOfVariables)).Sum();
+    }
+    [StorableConstructor]
+    protected MeanSum(bool deserializing) : base(deserializing) { }
+    protected MeanSum(MeanSum original, Cloner cloner)
+      : base(original, cloner) {
+      this.terms = cloner.Clone(original.terms);
+      this.numberOfVariables = original.numberOfVariables;
+    }
+    public MeanSum() {
+      this.terms = new ItemList<IMeanFunction>();
+    }
+
+    public void SetParameter(double[] hyp) {
+      int offset = 0;
+      foreach (var t in terms) {
+        var numberOfParameters = t.GetNumberOfParameters(numberOfVariables);
+        t.SetParameter(hyp.Skip(offset).Take(numberOfParameters).ToArray());
+        offset += numberOfParameters;
+      }
+    }
+
+    public void SetData(double[,] x) {
+      foreach (var t in terms) t.SetData(x);
+    }
+
+    public double[] GetMean(double[,] x) {
+      var res = terms.First().GetMean(x);
+      foreach (var t in terms.Skip(1)) {
+        var a = t.GetMean(x);
+        for (int i = 0; i < res.Length; i++) res[i] += a[i];
+      }
+      return res;
+    }
+
+    public double[] GetGradients(int k, double[,] x) {
+      int i = 0;
+      while (k >= terms[i].GetNumberOfParameters(numberOfVariables)) {
+        k -= terms[i].GetNumberOfParameters(numberOfVariables);
+        i++;
+      }
+      return terms[i].GetGradients(k, x);
+    }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new MeanSum(this, cloner);
+    }
+  }
+}
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj	(revision 8435)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj	(revision 8439)
@@ -120,4 +120,6 @@
     </Compile>
     <Compile Include="FixedDataAnalysisAlgorithm.cs" />
+    <Compile Include="GaussianProcess\MeanProd.cs" />
+    <Compile Include="GaussianProcess\MeanSum.cs" />
     <Compile Include="GaussianProcess\CovarianceProd.cs" />
     <Compile Include="GaussianProcess\CovarianceSum.cs" />
Index: trunk/sources/HeuristicLab.Tests/HeuristicLab.Algorithms.DataAnalysis-3.4/GaussianProcessFunctionsTest.cs
===================================================================
--- trunk/sources/HeuristicLab.Tests/HeuristicLab.Algorithms.DataAnalysis-3.4/GaussianProcessFunctionsTest.cs	(revision 8439)
+++ trunk/sources/HeuristicLab.Tests/HeuristicLab.Algorithms.DataAnalysis-3.4/GaussianProcessFunctionsTest.cs	(revision 8439)
@@ -0,0 +1,878 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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.Linq;
+using HeuristicLab.Algorithms.DataAnalysis;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace HeuristicLab.Algorithms.DataAnalysis_34.Tests {
+  [TestClass]
+
+  // reference values calculated with Rasmussen's GPML MATLAB package
+  public class GaussianProcessFunctionsTest {
+    [TestMethod]
+    public void MeanConstTest() {
+      TestMeanFunction(new MeanConst(), 0,
+        new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        new double[][] { new double[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } }
+      );
+      TestMeanFunction(new MeanConst(), 1,
+        new double[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
+        new double[][] { new double[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } }
+      );
+    }
+
+    [TestMethod]
+    public void MeanZeroTest() {
+      TestMeanFunction(new MeanZero(), 0,
+        new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        new double[][] { new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
+      );
+      TestMeanFunction(new MeanZero(), 1,
+        new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        new double[][] { new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
+      );
+    }
+
+    [TestMethod]
+    public void MeanSumTest() {
+      var sum = new MeanSum();
+      sum.Terms.Add(new MeanConst());
+      sum.Terms.Add(new MeanConst());
+      TestMeanFunction(sum, 0,
+        new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        new double[][]
+          {
+            new double[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
+            new double[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
+          }
+      );
+      TestMeanFunction(sum, 1,
+        new double[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 },
+        new double[][]
+          {
+            new double[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
+            new double[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
+          }
+      );
+    }
+    [TestMethod]
+    public void MeanProdTest() {
+      var prod = new MeanProd();
+      prod.Factors.Add(new MeanConst());
+      prod.Factors.Add(new MeanConst());
+      TestMeanFunction(prod, 0,
+        new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        new double[][]
+          {
+            new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+            new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+          }
+      );
+      TestMeanFunction(prod, 1,
+        new double[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
+        new double[][]
+          {
+            new double[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
+            new double[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
+          }
+      );
+
+      prod.Factors.Clear();
+      prod.Factors.Add(new MeanZero());
+      prod.Factors.Add(new MeanLinear());
+      TestMeanFunction(prod, 0,
+        new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        new double[][]
+          {
+            new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+            new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+            new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+            new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+            new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+          }
+      );
+      TestMeanFunction(prod, 1,
+        new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        new double[][]
+          {
+            new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+            new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+            new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+            new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+            new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+          }
+      );
+
+      //      prod.Factors.Clear();
+      //      prod.Factors.Add(new MeanConst());
+      //      prod.Factors.Add(new MeanLinear());
+      //      TestMeanFunction(prod, 1,
+      //  new double[] { 2.9087, 1.8646, 3.1971, 1.9889, 1.7639, 1.2801, 2.8059, 3.7243, 3.1901, 1.4979 },
+      //  new double[][]
+      //          {
+      //            new double[] { 1.8436,    2.1279,    3.1166,    1.6886,    3.2505,    2.9613,    2.3260,    1.7293,   1.7697,    2.3982 },
+      //            new double[] { 0.6443,    0.3786,    0.8116,    0.5328,    0.3507,    0.9390,    0.8759,    0.5502,   0.6225,    0.5870 },
+      //            new double[] { 0.2077,    0.3012,    0.4709,    0.2305,    0.8443,    0.1948,    0.2259,    0.1707,   0.2277,    0.4357 },
+      //            new double[] { 0.3111,    0.9234,    0.4302,    0.1848,    0.9049,    0.9797,    0.4389,    0.1111,   0.2581,    0.4087 },
+      //            new double[] { 0.5949,    0.2622,    0.6028,    0.7112,    0.2217,    0.1174,    0.2967,    0.3188,   0.4242,    0.5079 },
+      //            new double[] { 0.0855,    0.2625,    0.8010,    0.0292,    0.9289,    0.7303,    0.4886,    0.5785,   0.2373,    0.4588 }
+      //          }
+      //);
+    }
+
+    [TestMethod]
+    public void MeanLinear() {
+      TestMeanFunction(new MeanLinear(), 0,
+        new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+        new double[][]
+          {
+            new double[] { 0.4173, 0.0497, 0.9027, 0.9448, 0.4909, 0.4893, 0.3377, 0.9001, 0.3692, 0.1112 },
+            new double[] { 0.7803, 0.3897, 0.2417, 0.4039, 0.0965, 0.1320, 0.9421, 0.9561, 0.5752, 0.0598 },
+            new double[] { 0.2348, 0.3532, 0.8212, 0.0154, 0.0430, 0.1690, 0.6491, 0.7317, 0.6477, 0.4509 },
+            new double[] { 0.5470, 0.2963, 0.7447, 0.1890, 0.6868, 0.1835, 0.3685, 0.6256, 0.7802, 0.0811 },
+            new double[] { 0.9294, 0.7757, 0.4868, 0.4359, 0.4468, 0.3063, 0.5085, 0.5108, 0.8176, 0.7948 }
+          }
+      );
+      TestMeanFunction(new MeanLinear(), 1,
+        new double[] { 1.8436, 2.1279, 3.1166, 1.6886, 3.2505, 2.9613, 2.3260, 1.7293, 1.7697, 2.3982 },
+        new double[][]
+          {
+            new double[] { 0.4173, 0.0497, 0.9027, 0.9448, 0.4909, 0.4893, 0.3377, 0.9001, 0.3692, 0.1112 },
+            new double[] { 0.7803, 0.3897, 0.2417, 0.4039, 0.0965, 0.1320, 0.9421, 0.9561, 0.5752, 0.0598 },
+            new double[] { 0.2348, 0.3532, 0.8212, 0.0154, 0.0430, 0.1690, 0.6491, 0.7317, 0.6477, 0.4509 },
+            new double[] { 0.5470, 0.2963, 0.7447, 0.1890, 0.6868, 0.1835, 0.3685, 0.6256, 0.7802, 0.0811 },
+            new double[] { 0.9294, 0.7757, 0.4868, 0.4359, 0.4468, 0.3063, 0.5085, 0.5108, 0.8176, 0.7948 }
+          }
+      );
+    }
+
+    [TestMethod]
+    public void CovSeIsoTest() {
+      TestCovarianceFunction(new CovarianceSEiso(), 0,
+        new double[,]
+          {
+{    0.5771,    0.5404,    0.8569,    0.5612,    0.7545,    0.4980,    0.6649,    0.7484,    0.6564,    0.8184},
+{    0.6206,    0.7027,    0.7091,    0.6015,    0.7295,    0.5338,    0.6705,    0.8202,    0.7155,    0.8029},
+{    0.7743,    0.7513,    0.8468,    0.6865,    0.5645,    0.7861,    0.8404,    0.6625,    0.7555,    0.8335},
+{    0.7773,    0.5513,    0.7792,    0.7166,    0.4534,    0.5870,    0.8913,    0.8796,    0.8656,    0.8245},
+{    0.8839,    0.5934,    0.7689,    0.8982,    0.4126,    0.4741,    0.7883,    0.9201,    0.9077,    0.8649},
+{    0.8746,    0.7341,    0.7020,    0.8323,    0.4826,    0.5922,    0.8706,    0.9508,    0.9524,    0.8660},
+{    0.6133,    0.7560,    0.7280,    0.5749,    0.8722,    0.5651,    0.6530,    0.6260,    0.6633,    0.8195},
+{    0.6113,    0.6277,    0.8110,    0.5489,    0.7110,    0.6221,    0.6948,    0.5425,    0.6227,    0.7828},
+{    0.6394,    0.6950,    0.8669,    0.6107,    0.7933,    0.5985,    0.6823,    0.6858,    0.6702,    0.8492},
+{    0.5790,    0.7156,    0.6274,    0.5324,    0.6323,    0.6100,    0.6863,    0.8091,    0.6855,    0.7173},
+          },
+        new double[][,]
+          {
+            new double[,] {
+{    0.6345,    0.6652,    0.2647,    0.6484,    0.4251,    0.6943,    0.5427,    0.4338,    0.5527,    0.3280},
+{    0.5921,    0.4959,    0.4876,    0.6115,    0.4601,    0.6702,    0.5360,    0.3252,    0.4791,    0.3526},
+{    0.3961,    0.4296,    0.2816,    0.5165,    0.6456,    0.3784,    0.2923,    0.5455,    0.4237,    0.3036},
+{    0.3916,    0.6566,    0.3888,    0.4777,    0.7173,    0.6255,    0.2051,    0.2256,    0.2498,    0.3182},
+{    0.2181,    0.6194,    0.4041,    0.1929,    0.7305,    0.7077,    0.3750,    0.1532,    0.1758,    0.2510},
+{    0.2344,    0.4538,    0.4967,    0.3056,    0.7032,    0.6205,    0.2413,    0.0960,    0.0929,    0.2492},
+{    0.5996,    0.4229,    0.4622,    0.6365,    0.2384,    0.6451,    0.5566,    0.5865,    0.5446,    0.3263},
+{    0.6017,    0.5846,    0.3398,    0.6585,    0.4850,    0.5905,    0.5060,    0.6636,    0.5900,    0.3834},
+{    0.5719,    0.5057,    0.2476,    0.6023,    0.3674,    0.6144,    0.5216,    0.5174,    0.5364,    0.2776},
+{    0.6327,    0.4789,    0.5849,    0.6712,    0.5796,    0.6030,    0.5167,    0.3428,    0.5177,    0.4767},
+            },
+            new double[,] {
+{    1.1542,    1.0808,    1.7137,    1.1224,    1.5090,    0.9961,    1.3298,    1.4968,    1.3127,    1.6369},
+{    1.2413,    1.4053,    1.4181,    1.2031,    1.4591,    1.0675,    1.3411,    1.6404,    1.4309,    1.6057},
+{    1.5486,    1.5027,    1.6936,    1.3729,    1.1289,    1.5721,    1.6807,    1.3251,    1.5109,    1.6670},
+{    1.5547,    1.1026,    1.5584,    1.4331,    0.9067,    1.1739,    1.7826,    1.7593,    1.7313,    1.6490},
+{    1.7679,    1.1868,    1.5379,    1.7963,    0.8253,    0.9483,    1.5767,    1.8403,    1.8154,    1.7298},
+{    1.7492,    1.4683,    1.4041,    1.6646,    0.9652,    1.1845,    1.7411,    1.9016,    1.9048,    1.7320},
+{    1.2267,    1.5121,    1.4560,    1.1498,    1.7445,    1.1302,    1.3060,    1.2519,    1.3266,    1.6389},
+{    1.2227,    1.2555,    1.6220,    1.0978,    1.4220,    1.2443,    1.3896,    1.0850,    1.2454,    1.5656},
+{    1.2789,    1.3900,    1.7339,    1.2214,    1.5866,    1.1971,    1.3647,    1.3715,    1.3404,    1.6984},
+{    1.1581,    1.4312,    1.2549,    1.0647,    1.2647,    1.2200,    1.3726,    1.6182,    1.3709,    1.4346},
+          }
+          }
+      );
+      TestCovarianceFunction(new CovarianceSEiso(), 1,
+         new double[,]
+           {
+{    6.8592,    6.7985,    7.2362,    6.8334,    7.1127,    6.7239,    6.9920,    7.1048,    6.9798,    7.1914},
+{    6.9271,    7.0445,    7.0531,    6.8979,    7.0803,    6.7872,    7.0000,    7.1935,    7.0617,    7.1727},
+{    7.1376,    7.1086,    7.2246,    7.0223,    6.8388,    7.1522,    7.2172,    6.9886,    7.1139,    7.2091},
+{    7.1414,    6.8169,    7.1438,    7.0632,    6.6389,    6.8750,    7.2749,    7.2619,    7.2462,    7.1986},
+{    7.2667,    6.8852,    7.1309,    7.2824,    6.5548,    6.6792,    7.1550,    7.3063,    7.2929,    7.2454},
+{    7.2563,    7.0864,    7.0436,    7.2078,    6.6953,    6.8834,    7.2517,    7.3388,    7.3405,    7.2466},
+{    6.9160,    7.1146,    7.0783,    6.8557,    7.2536,    6.8398,    6.9750,    6.9351,    6.9897,    7.1926},
+{    6.9130,    6.9378,    7.1825,    6.8129,    7.0557,    6.9294,    7.0338,    6.8021,    6.9302,    7.1482},
+{    6.9551,    7.0340,    7.2476,    6.9120,    7.1611,    6.8932,    7.0166,    7.0213,    6.9995,    7.2274},
+{    6.8624,    7.0619,    6.9373,    6.7848,    6.9446,    6.9109,    7.0221,    7.1802,    7.0209,    7.0642},
+           },
+         new double[][,]
+          {
+            new double[,] {
+{    1.0207,    1.1326,    0.3026,    1.0685,    0.5423,    1.2686,    0.7724,    0.5574,    0.7955,    0.3900},
+{    0.8944,    0.6729,    0.6564,    0.9490,    0.6043,    1.1534,    0.7573,    0.3860,    0.6400,    0.4263},
+{    0.4942,    0.5501,    0.3252,    0.7151,    1.0586,    0.4660,    0.3398,    0.7787,    0.5400,    0.3554},
+{    0.4868,    1.0987,    0.4824,    0.6372,    1.4215,    0.9914,    0.2266,    0.2521,    0.2830,    0.3760},
+{    0.2427,    0.9726,    0.5072,    0.2117,    1.5705,    1.3491,    0.4606,    0.1646,    0.1911,    0.2846},
+{    0.2632,    0.5928,    0.6745,    0.3581,    1.3203,    0.9760,    0.2721,    0.1002,    0.0969,    0.2822},
+{    0.9151,    0.5386,    0.6082,    1.0272,    0.2684,    1.0567,    0.8045,    0.8794,    0.7766,    0.3876},
+{    0.9208,    0.8744,    0.4072,    1.1062,    0.6514,    0.8901,    0.6932,    1.1260,    0.8886,    0.4738},
+{    0.8418,    0.6927,    0.2801,    0.9226,    0.4489,    0.9576,    0.7259,    0.7169,    0.7582,    0.3198},
+{    1.0149,    0.6396,    0.8752,    1.1578,    0.8615,    0.9246,    0.7154,    0.4117,    0.7177,    0.6353},
+            },
+            new double[,] {
+{   13.7185,   13.5970,   14.4724,   13.6668,   14.2254,   13.4477,   13.9840,   14.2096,   13.9596,   14.3828},
+{   13.8542,   14.0889,   14.1062,   13.7957,   14.1607,   13.5743,   14.0000,   14.3869,   14.1234,   14.3454},
+{   14.2753,   14.2173,   14.4492,   14.0445,   13.6775,   14.3044,   14.4343,   13.9773,   14.2278,   14.4183},
+{   14.2829,   13.6339,   14.2875,   14.1263,   13.2777,   13.7501,   14.5498,   14.5238,   14.4923,   14.3972},
+{   14.5334,   13.7703,   14.2618,   14.5649,   13.1097,   13.3585,   14.3100,   14.6126,   14.5857,   14.4907},
+{   14.5125,   14.1727,   14.0872,   14.4155,   13.3905,   13.7667,   14.5035,   14.6775,   14.6809,   14.4932},
+{   13.8321,   14.2292,   14.1566,   13.7114,   14.5073,   13.6796,   13.9499,   13.8703,   13.9795,   14.3852},
+{   13.8260,   13.8756,   14.3651,   13.6258,   14.1115,   13.8588,   14.0675,   13.6042,   13.8604,   14.2964},
+{   13.9103,   14.0681,   14.4953,   13.8241,   14.3221,   13.7864,   14.0331,   14.0426,   13.9991,   14.4548},
+{   13.7248,   14.1238,   13.8747,   13.5695,   13.8893,   13.8218,   14.0442,   14.3604,   14.0418,   14.1283},
+            },
+          }
+       );
+    }
+
+
+    [TestMethod]
+    public void CovLinearTest() {
+      TestCovarianceFunction(new CovarianceLinear(), 0,
+        new double[,]
+          {
+{    0.9089,    0.9972,    1.8813,    0.8618,    2.0021,    1.5168,    1.2612,    1.1009,    0.9505,    1.3851},
+{    0.4654,    0.7436,    1.1758,    0.4150,    1.4523,    1.0699,    0.7535,    0.6763,    0.5205,    0.8497},
+{    1.3720,    1.4959,    2.0386,    1.2323,    1.8810,    2.1422,    1.6645,    1.1482,    1.2602,    1.5724},
+{    0.8471,    0.6576,    1.4266,    0.7465,    1.1331,    1.3214,    1.1946,    0.9028,    0.8676,    1.0329},
+{    0.7965,    0.5520,    1.2342,    0.7932,    0.8598,    0.9288,    0.8927,    0.7687,    0.7359,    0.9016},
+{    0.5306,    0.5096,    0.8879,    0.4618,    0.7612,    0.8960,    0.7367,    0.5462,    0.5287,    0.6475},
+{    0.8779,    1.2411,    1.6264,    0.7940,    2.0552,    1.5512,    1.1513,    0.8304,    0.8692,    1.2945},
+{    1.4220,    1.6026,    2.2818,    1.2951,    2.3982,    2.1948,    1.7607,    1.2346,    1.3533,    1.7961},
+{    1.0930,    1.3304,    1.9745,    1.0278,    2.1338,    1.7821,    1.3686,    1.0951,    1.0529,    1.5035},
+{    0.3406,    0.7064,    0.9980,    0.2373,    1.2538,    1.1479,    0.7212,    0.6072,    0.4222,    0.6815},
+          },
+        new double[][,]
+          {            
+          }
+      );
+    }
+
+    [TestMethod]
+    public void CovPeriodicTest() {
+      TestCovarianceFunction(new CovariancePeriodic(), 0,
+        new double[,]
+          {
+{    0.9548,    0.7965,    0.1438,    0.8971,    0.3692,    0.5608,    0.8367,    0.3951,    0.8773,    0.1881},
+{    0.9894,    0.6290,    0.5931,    0.9987,    0.4838,    0.7608,    0.8078,    0.1852,    0.5579,    0.2184},
+{    0.2962,    0.3824,    0.1517,    0.7208,    0.9105,    0.2604,    0.1580,    0.8483,    0.3653,    0.1660},
+{    0.2864,    0.8521,    0.2806,    0.5519,    0.3502,    0.9797,    0.1364,    0.1354,    0.1391,    0.1784},
+{    0.1354,    0.9908,    0.3145,    0.1389,    0.2266,    0.4391,    0.2541,    0.1592,    0.1452,    0.1394},
+{    0.1362,    0.4609,    0.6325,    0.1675,    0.4801,    0.9891,    0.1372,    0.2435,    0.2512,    0.1389},
+{    0.9975,    0.3630,    0.4916,    0.9481,    0.1367,    0.9130,    0.8921,    0.9800,    0.8445,    0.1864},
+{    0.9988,    0.9762,    0.2016,    0.8402,    0.5823,    0.9870,    0.6736,    0.8076,    0.9861,    0.2698},
+{    0.9440,    0.6724,    0.1385,    0.9991,    0.2411,    0.9966,    0.7439,    0.7247,    0.8095,    0.1496},
+{    0.9605,    0.5569,    0.9769,    0.7531,    0.9651,    0.9994,    0.7216,    0.2054,    0.7264,    0.5478},
+          },
+        new double[][,]
+          {      
+            new double[,]
+              {
+{    0.0883,    0.3624,    0.5578,    0.1949,    0.7358,    0.6487,    0.2984,    0.7338,    0.2296,    0.6286},
+{    0.0211,    0.5833,    0.6197,    0.0027,    0.7026,    0.4160,    0.3448,    0.6246,    0.6512,    0.6645},
+{    0.7208,    0.7352,    0.5721,    0.4719,    0.1707,    0.7008,    0.5831,    0.2792,    0.7357,    0.5962},
+{    0.7162,    0.2728,    0.7132,    0.6561,    0.7349,    0.0401,    0.5435,    0.5416,    0.5487,    0.6150},
+{    0.5414,    0.0183,    0.7276,    0.5484,    0.6728,    0.7228,    0.6963,    0.5851,    0.5603,    0.5493},
+{    0.5430,    0.7140,    0.5794,    0.5986,    0.7046,    0.0216,    0.5451,    0.6879,    0.6941,    0.5484},
+{    0.0050,    0.7357,    0.6982,    0.1011,    0.5441,    0.1662,    0.2038,    0.0396,    0.2855,    0.6263},
+{    0.0025,    0.0470,    0.6457,    0.2925,    0.6298,    0.0258,    0.5324,    0.3451,    0.0275,    0.7069},
+{    0.1088,    0.5338,    0.5476,    0.0019,    0.6859,    0.0068,    0.4402,    0.4667,    0.3421,    0.5684},
+{    0.0774,    0.6520,    0.0457,    0.4271,    0.0686,    0.0013,    0.4709,    0.6502,    0.4644,    0.6594},                
+              },
+            new double[,]
+              {
+{    1.8911,    3.5259,   -0.1726,    2.7462,   -1.7412,    3.7725,   -2.7071,   -1.8853,   -2.5019,   -0.5552},
+{   -0.8840,   -2.8021,   -2.7150,    0.3273,   -2.3218,    3.6802,   -2.8022,   -0.5330,   -2.6079,   -0.7758},
+{   -1.2996,   -1.8154,   -0.2547,   -2.9071,    2.5861,   -1.0654,   -0.3131,   -2.6579,   -1.7190,   -0.3814},
+{   -1.2366,    3.1709,   -1.1989,   -2.5877,    2.7645,    1.2794,    0.0523,   -0.0174,   -0.1087,   -0.4806},
+{    0.0086,    0.8629,   -1.4146,    0.0921,    1.6565,    3.3174,   -1.0231,    0.2231,    0.1477,   -0.1137},
+{   -0.0491,   -2.2183,   -2.8095,   -0.3938,    3.5099,    0.9382,   -0.0753,    0.4427,    0.4556,   -0.1062},
+{   -0.4372,   -1.7059,   -2.3555,    2.0194,   -0.0642,    2.5547,   -2.4014,   -1.1924,   -2.6748,   -0.5422},
+{   -0.3101,   -1.2911,   -0.6547,    3.2602,   -2.6843,   -0.9727,   -2.8761,    3.4673,   -1.0044,   -1.1276},
+{   -1.8766,   -2.8747,   -0.0998,   -0.2703,   -0.9342,    0.5245,   -2.9018,   -2.9072,   -2.7976,   -0.2342},
+{    1.7731,   -2.6049,   -1.2740,    3.7069,   -1.5344,   -0.2241,   -2.9071,   -0.6824,   -2.9071,   -2.5738},             
+              },
+            new double[,]
+              {
+{    1.9096,    1.5931,    0.2877,    1.7941,    0.7384,    1.1215,    1.6733,    0.7902,    1.7547,    0.3763},
+{    1.9788,    1.2580,    1.1862,    1.9973,    0.9676,    1.5216,    1.6156,    0.3704,    1.1157,    0.4367},
+{    0.5925,    0.7648,    0.3033,    1.4416,    1.8211,    0.5208,    0.3160,    1.6965,    0.7306,    0.3320},
+{    0.5729,    1.7041,    0.5612,    1.1037,    0.7004,    1.9595,    0.2729,    0.2709,    0.2781,    0.3568},
+{    0.2707,    1.9816,    0.6289,    0.2779,    0.4531,    0.8782,    0.5082,    0.3184,    0.2903,    0.2788},
+{    0.2723,    0.9219,    1.2651,    0.3350,    0.9602,    1.9782,    0.2744,    0.4870,    0.5024,    0.2778},
+{    1.9950,    0.7261,    0.9832,    1.8961,    0.2735,    1.8260,    1.7841,    1.9600,    1.6889,    0.3729},
+{    1.9975,    1.9524,    0.4031,    1.6805,    1.1645,    1.9741,    1.3471,    1.6152,    1.9723,    0.5395},
+{    1.8880,    1.3447,    0.2770,    1.9981,    0.4821,    1.9932,    1.4877,    1.4494,    1.6190,    0.2991},
+{    1.9210,    1.1139,    1.9538,    1.5061,    1.9301,    1.9987,    1.4432,    0.4107,    1.4528,    1.0956},        
+              },
+          }
+      );
+      TestCovarianceFunction(new CovariancePeriodic(), 1,
+        new double[,]
+          {
+{    5.8283,    5.7618,    6.7049,    5.7980,    6.3126,    5.7012,    6.0358,    6.2917,    6.0128,    6.5482},
+{    5.9230,    6.1447,    6.1643,    5.8794,    6.2291,    5.7511,    6.0513,    6.5551,    6.1842,    6.4880},
+{    6.3822,    6.3018,    6.6628,    6.0966,    5.8040,    6.4250,    6.6362,    6.0294,    6.3159,    6.6082},
+{    6.3932,    5.7803,    6.4000,    6.1876,    5.6577,    5.8483,    6.8550,    6.8032,    6.7423,    6.5723},
+{    6.8221,    5.8618,    6.3630,    6.8860,    5.6385,    5.6752,    6.4334,    6.9877,    6.9298,    6.7393},
+{    6.7811,    6.2441,    6.1428,    6.6035,    5.6837,    5.8594,    6.7636,    7.1358,    7.1438,    6.7439},
+{    5.9060,    6.3179,    6.2241,    5.8240,    6.7709,    5.8052,    6.0040,    5.9357,    6.0315,    6.5522},
+{    5.9014,    5.9400,    6.5193,    5.7761,    6.1703,    5.9266,    6.1211,    5.7652,    5.9278,    6.4131},
+{    5.9689,    6.1217,    6.7479,    5.9000,    6.4518,    5.8729,    6.0847,    6.0946,    6.0504,    6.6728},
+{    5.8322,    6.1847,    5.9393,    5.7489,    5.9512,    5.8983,    6.0962,    6.5118,    6.0937,    6.1900},
+          },
+        new double[][,]
+          {            
+            new double[,]
+              {
+{    2.7658,    2.8666,    1.3028,    2.8119,    1.9878,    2.9569,    2.4420,    2.0231,    2.4786,    1.5821},
+{    2.6198,    2.2663,    2.2343,    2.6874,    2.1274,    2.8825,    2.4171,    1.5700,    2.2016,    1.6875},
+{    1.8698,    2.0061,    1.3786,    2.3444,    2.8027,    1.7965,    1.4262,    2.4522,    1.9823,    1.4760},
+{    1.8510,    2.8387,    1.8395,    2.1959,    3.0210,    2.7352,    1.0285,    1.1240,    1.2352,    1.5397},
+{    1.0892,    2.7145,    1.9025,    0.9710,    3.0490,    2.9953,    1.7820,    0.7805,    0.8894,    1.2407},
+{    1.1645,    2.1025,    2.2694,    1.4845,    2.9828,    2.7182,    1.1965,    0.4978,    0.4823,    1.2323},
+{    2.6463,    1.9790,    2.1357,    2.7724,    1.1832,    2.8010,    2.4926,    2.6000,    2.4488,    1.5751},
+{    2.6534,    2.5933,    1.6329,    2.8450,    2.2244,    2.6143,    2.3047,    2.8613,    2.6123,    1.8170},
+{    2.5480,    2.3036,    1.2251,    2.6556,    1.7503,    2.6975,    2.3636,    2.3476,    2.4186,    1.3608},
+{    2.7599,    2.2008,    2.5944,    2.8858,    2.5757,    2.6581,    2.3450,    1.6460,    2.3490,    2.1920},
+              },
+            new double[,]
+              {
+{    1.2575,    1.0910,    1.1185,    1.1908,    1.4623,    0.8439,    1.4825,    1.4718,    1.4712,    1.2892},
+{    1.3993,    1.5049,    1.5043,    1.3445,    1.4935,    1.0563,    1.4887,    1.2825,    1.5024,    1.3439},
+{    1.4231,    1.4673,    1.1682,    1.5008,    1.2052,    1.3938,    1.1981,    1.4796,    1.4607,    1.2285},
+{    1.4160,    1.1451,    1.4114,    1.5019,    0.5165,    1.2949,    0.9209,    0.9927,    1.0722,    1.2656},
+{    0.9668,    1.3176,    1.4350,    0.8763,    0.1550,    0.6776,    1.3876,    0.7218,    0.8114,    1.0761},
+{    1.0221,    1.4893,    1.5049,    1.2335,    0.7388,    1.3137,    1.0450,    0.4752,    0.4611,    1.0702},
+{    1.3798,    1.4597,    1.4948,    1.2488,    1.0355,    1.2079,    1.4662,    1.4126,    1.4806,    1.2853},
+{    1.3741,    1.4168,    1.3163,    1.1334,    1.5039,    1.4032,    1.5040,    1.1017,    1.4045,    1.4024},
+{    1.4421,    1.5040,    1.0652,    1.3723,    1.3735,    1.3349,    1.4984,    1.5004,    1.4883,    1.1567},
+{    1.2652,    1.5023,    1.4161,    1.0487,    1.4273,    1.3702,    1.5007,    1.3231,    1.5003,    1.5016},
+              },
+            new double[,]
+              {
+{   11.6566,   11.5235,   13.4099,   11.5959,   12.6253,   11.4024,   12.0716,   12.5834,   12.0256,   13.0964},
+{   11.8460,   12.2894,   12.3285,   11.7588,   12.4583,   11.5022,   12.1027,   13.1103,   12.3684,   12.9759},
+{   12.7645,   12.6035,   13.3256,   12.1932,   11.6081,   12.8500,   13.2725,   12.0588,   12.6318,   13.2165},
+{   12.7864,   11.5605,   12.7999,   12.3753,   11.3155,   11.6967,   13.7101,   13.6063,   13.4846,   13.1446},
+{   13.6442,   11.7236,   12.7260,   13.7721,   11.2771,   11.3504,   12.8668,   13.9754,   13.8595,   13.4785},
+{   13.5621,   12.4883,   12.2856,   13.2070,   11.3674,   11.7187,   13.5272,   14.2715,   14.2876,   13.4877},
+{   11.8120,   12.6357,   12.4483,   11.6480,   13.5417,   11.6104,   12.0079,   11.8714,   12.0630,   13.1045},
+{   11.8028,   11.8801,   13.0386,   11.5521,   12.3406,   11.8531,   12.2422,   11.5305,   11.8557,   12.8261},
+{   11.9378,   12.2435,   13.4957,   11.8000,   12.9036,   11.7458,   12.1694,   12.1892,   12.1009,   13.3455},
+{   11.6644,   12.3694,   11.8785,   11.4978,   11.9025,   11.7967,   12.1924,   13.0236,   12.1874,   12.3800},
+
+              },
+          }
+      );
+    }
+
+    [TestMethod]
+    public void CovSEardTest() {
+      TestCovarianceFunction(new CovarianceSEard(), 0,
+        new double[,]
+          {
+{    0.5771,    0.5404,    0.8569,    0.5612,    0.7545,    0.4980,    0.6649,    0.7484,    0.6564,    0.8184},
+{    0.6206,    0.7027,    0.7091,    0.6015,    0.7295,    0.5338,    0.6705,    0.8202,    0.7155,    0.8029},
+{    0.7743,    0.7513,    0.8468,    0.6865,    0.5645,    0.7861,    0.8404,    0.6625,    0.7555,    0.8335},
+{    0.7773,    0.5513,    0.7792,    0.7166,    0.4534,    0.5870,    0.8913,    0.8796,    0.8656,    0.8245},
+{    0.8839,    0.5934,    0.7689,    0.8982,    0.4126,    0.4741,    0.7883,    0.9201,    0.9077,    0.8649},
+{    0.8746,    0.7341,    0.7020,    0.8323,    0.4826,    0.5922,    0.8706,    0.9508,    0.9524,    0.8660},
+{    0.6133,    0.7560,    0.7280,    0.5749,    0.8722,    0.5651,    0.6530,    0.6260,    0.6633,    0.8195},
+{    0.6113,    0.6277,    0.8110,    0.5489,    0.7110,    0.6221,    0.6948,    0.5425,    0.6227,    0.7828},
+{    0.6394,    0.6950,    0.8669,    0.6107,    0.7933,    0.5985,    0.6823,    0.6858,    0.6702,    0.8492},
+{    0.5790,    0.7156,    0.6274,    0.5324,    0.6323,    0.6100,    0.6863,    0.8091,    0.6855,    0.7173},
+
+          },
+        new double[][,]
+          {      
+            new double[,]
+              {
+{    0.0297,    0.0008,    0.1332,    0.0075,    0.0033,    0.1356,    0.1399,    0.0132,    0.0276,    0.0236},
+{    0.2195,    0.0760,    0.4116,    0.1404,    0.0661,    0.4222,    0.4578,    0.2055,    0.2348,    0.2319},
+{    0.0517,    0.2064,    0.0070,    0.0939,    0.1720,    0.0010,    0.0006,    0.0824,    0.0593,    0.0831},
+{    0.0702,    0.1767,    0.0138,    0.1216,    0.1600,    0.0000,    0.0042,    0.1370,    0.0899,    0.1055},
+{    0.0208,    0.0075,    0.0791,    0.0016,    0.0081,    0.0952,    0.1169,    0.0032,    0.0157,    0.0080},
+{    0.0210,    0.0090,    0.0729,    0.0016,    0.0093,    0.1198,    0.1302,    0.0035,    0.0169,    0.0083},
+{    0.0577,    0.0013,    0.1635,    0.0219,    0.0001,    0.2043,    0.1892,    0.0282,    0.0538,    0.0509},
+{    0.0400,    0.1707,    0.0063,    0.0740,    0.2146,    0.0009,    0.0004,    0.0664,    0.0480,    0.0767},
+{    0.0484,    0.0001,    0.1696,    0.0163,    0.0003,    0.1943,    0.1752,    0.0224,    0.0430,    0.0403},
+{    0.1646,    0.0512,    0.3078,    0.0946,    0.0363,    0.4180,    0.4014,    0.1559,    0.1792,    0.1624},
+              },
+            new double[,]
+              {
+{    0.1891,    0.1240,    0.0820,    0.1696,    0.0031,    0.1707,    0.2043,    0.2781,    0.2004,    0.0972},
+{    0.0206,    0.0055,    0.0047,    0.0153,    0.1507,    0.0203,    0.0180,    0.0393,    0.0188,    0.0017},
+{    0.0009,    0.0027,    0.0445,    0.0001,    0.2050,    0.0017,    0.0002,    0.0033,    0.0001,    0.0314},
+{    0.0299,    0.0058,    0.0035,    0.0216,    0.0879,    0.0257,    0.0282,    0.0478,    0.0269,    0.0008},
+{    0.0109,    0.0249,    0.1078,    0.0161,    0.2308,    0.0046,    0.0132,    0.0051,    0.0156,    0.0995},
+{    0.0050,    0.0210,    0.0807,    0.0081,    0.2449,    0.0023,    0.0077,    0.0014,    0.0087,    0.0799},
+{    0.3307,    0.3104,    0.1616,    0.2911,    0.0083,    0.3156,    0.3349,    0.3724,    0.3385,    0.2101},
+{    0.3424,    0.2692,    0.1909,    0.2890,    0.0089,    0.3606,    0.3705,    0.3347,    0.3304,    0.2120},
+{    0.0863,    0.0522,    0.0094,    0.0726,    0.0574,    0.0866,    0.0832,    0.1122,    0.0810,    0.0165},
+{    0.0127,    0.0417,    0.1061,    0.0155,    0.3892,    0.0111,    0.0189,    0.0100,    0.0193,    0.1014},
+              },
+            new double[,]
+              {
+{    0.0034,    0.2562,    0.0327,    0.0014,    0.3388,    0.2764,    0.0277,    0.0114,    0.0004,    0.0248},
+{    0.0011,    0.2285,    0.0042,    0.0170,    0.2221,    0.2096,    0.0049,    0.0480,    0.0065,    0.0025},
+{    0.2015,    0.0078,    0.1295,    0.2780,    0.0040,    0.0198,    0.1228,    0.3341,    0.2396,    0.1418},
+{    0.0680,    0.4545,    0.1341,    0.0206,    0.3587,    0.5459,    0.1598,    0.0081,    0.0510,    0.1276},
+{    0.0635,    0.4599,    0.1153,    0.0181,    0.3065,    0.4160,    0.1235,    0.0043,    0.0420,    0.1157},
+{    0.0177,    0.4178,    0.0479,    0.0002,    0.2613,    0.3893,    0.0634,    0.0032,    0.0076,    0.0498},
+{    0.0701,    0.0569,    0.0349,    0.1239,    0.0571,    0.0618,    0.0289,    0.1812,    0.1014,    0.0474},
+{    0.1082,    0.0231,    0.0737,    0.1642,    0.0213,    0.0383,    0.0596,    0.2089,    0.1397,    0.0817},
+{    0.0725,    0.0528,    0.0410,    0.1309,    0.0525,    0.0660,    0.0298,    0.1975,    0.1018,    0.0485},
+{    0.0113,    0.1597,    0.0003,    0.0377,    0.1303,    0.1706,    0.0001,    0.0934,    0.0255,    0.0013},
+              },
+            new double[,]
+              {
+{    0.0013,    0.0438,    0.0027,    0.0151,    0.0798,    0.0919,    0.0417,    0.0390,    0.0099,    0.0013},
+{    0.0553,    0.0008,    0.0666,    0.1035,    0.0041,    0.0171,    0.0000,    0.0004,    0.0117,    0.0359},
+{    0.0174,    0.1749,    0.0170,    0.0008,    0.1544,    0.3093,    0.1687,    0.1202,    0.0776,    0.0468},
+{    0.1281,    0.0030,    0.1335,    0.1954,    0.0005,    0.0030,    0.0103,    0.0148,    0.0479,    0.0839},
+{    0.0075,    0.1070,    0.0054,    0.0005,    0.0892,    0.1537,    0.1200,    0.1246,    0.0626,    0.0277},
+{    0.1480,    0.0045,    0.1234,    0.2318,    0.0007,    0.0026,    0.0111,    0.0174,    0.0552,    0.0911},
+{    0.0314,    0.0085,    0.0400,    0.0675,    0.0188,    0.0356,    0.0034,    0.0015,    0.0021,    0.0159},
+{    0.0006,    0.0829,    0.0004,    0.0040,    0.1160,    0.1607,    0.0752,    0.0511,    0.0253,    0.0109},
+{    0.0220,    0.1865,    0.0273,    0.0029,    0.2474,    0.2629,    0.1595,    0.1460,    0.0850,    0.0630},
+{    0.1528,    0.0235,    0.1708,    0.2114,    0.0125,    0.0008,    0.0319,    0.0457,    0.0807,    0.1306},
+              },
+            new double[,]
+              {
+{    0.4109,    0.2403,    0.0141,    0.4547,    0.0000,    0.0197,    0.1292,    0.0921,    0.3144,    0.1812},
+{    0.2957,    0.1851,    0.0005,    0.3352,    0.0171,    0.0011,    0.0553,    0.0319,    0.2074,    0.0806},
+{    0.1247,    0.0378,    0.0836,    0.1437,    0.1103,    0.0466,    0.0000,    0.0056,    0.0470,    0.0007},
+{    0.0954,    0.0166,    0.1039,    0.1185,    0.1102,    0.0509,    0.0025,    0.0179,    0.0341,    0.0004},
+{    0.1154,    0.0202,    0.0965,    0.1566,    0.0959,    0.0381,    0.0014,    0.0160,    0.0398,    0.0001},
+{    0.0427,    0.0014,    0.1718,    0.0639,    0.1870,    0.1065,    0.0289,    0.0704,    0.0045,    0.0201},
+{    0.1097,    0.0458,    0.0623,    0.1321,    0.1541,    0.0278,    0.0003,    0.0031,    0.0488,    0.0020},
+{    0.1106,    0.0387,    0.0683,    0.1273,    0.1243,    0.0300,    0.0003,    0.0025,    0.0466,    0.0021},
+{    0.3427,    0.2142,    0.0002,    0.3796,    0.0098,    0.0046,    0.0739,    0.0392,    0.2257,    0.1093},
+{    0.2913,    0.2028,    0.0000,    0.3120,    0.0114,    0.0025,    0.0644,    0.0379,    0.2131,    0.0810},
+              },
+            new double[,]
+              {
+{    1.1542,    1.0808,    1.7137,    1.1224,    1.5090,    0.9961,    1.3298,    1.4968,    1.3127,    1.6369},
+{    1.2413,    1.4053,    1.4181,    1.2031,    1.4591,    1.0675,    1.3411,    1.6404,    1.4309,    1.6057},
+{    1.5486,    1.5027,    1.6936,    1.3729,    1.1289,    1.5721,    1.6807,    1.3251,    1.5109,    1.6670},
+{    1.5547,    1.1026,    1.5584,    1.4331,    0.9067,    1.1739,    1.7826,    1.7593,    1.7313,    1.6490},
+{    1.7679,    1.1868,    1.5379,    1.7963,    0.8253,    0.9483,    1.5767,    1.8403,    1.8154,    1.7298},
+{    1.7492,    1.4683,    1.4041,    1.6646,    0.9652,    1.1845,    1.7411,    1.9016,    1.9048,    1.7320},
+{    1.2267,    1.5121,    1.4560,    1.1498,    1.7445,    1.1302,    1.3060,    1.2519,    1.3266,    1.6389},
+{    1.2227,    1.2555,    1.6220,    1.0978,    1.4220,    1.2443,    1.3896,    1.0850,    1.2454,    1.5656},
+{    1.2789,    1.3900,    1.7339,    1.2214,    1.5866,    1.1971,    1.3647,    1.3715,    1.3404,    1.6984},
+{    1.1581,    1.4312,    1.2549,    1.0647,    1.2647,    1.2200,    1.3726,    1.6182,    1.3709,    1.4346},
+              },
+          }
+      );
+      TestCovarianceFunction(new CovarianceSEard(), 1,
+        new double[,]
+          {
+{    6.8592,    6.7985,    7.2362,    6.8334,    7.1127,    6.7239,    6.9920,    7.1048,    6.9798,    7.1914},
+{    6.9271,    7.0445,    7.0531,    6.8979,    7.0803,    6.7872,    7.0000,    7.1935,    7.0617,    7.1727},
+{    7.1376,    7.1086,    7.2246,    7.0223,    6.8388,    7.1522,    7.2172,    6.9886,    7.1139,    7.2091},
+{    7.1414,    6.8169,    7.1438,    7.0632,    6.6389,    6.8750,    7.2749,    7.2619,    7.2462,    7.1986},
+{    7.2667,    6.8852,    7.1309,    7.2824,    6.5548,    6.6792,    7.1550,    7.3063,    7.2929,    7.2454},
+{    7.2563,    7.0864,    7.0436,    7.2078,    6.6953,    6.8834,    7.2517,    7.3388,    7.3405,    7.2466},
+{    6.9160,    7.1146,    7.0783,    6.8557,    7.2536,    6.8398,    6.9750,    6.9351,    6.9897,    7.1926},
+{    6.9130,    6.9378,    7.1825,    6.8129,    7.0557,    6.9294,    7.0338,    6.8021,    6.9302,    7.1482},
+{    6.9551,    7.0340,    7.2476,    6.9120,    7.1611,    6.8932,    7.0166,    7.0213,    6.9995,    7.2274},
+{    6.8624,    7.0619,    6.9373,    6.7848,    6.9446,    6.9109,    7.0221,    7.1802,    7.0209,    7.0642},
+          },
+        new double[][,]
+          {            
+            new double[,]
+              {
+{    0.0479,    0.0014,    0.1523,    0.0123,    0.0043,    0.2477,    0.1991,    0.0170,    0.0398,    0.0281},
+{    0.3315,    0.1032,    0.5541,    0.2179,    0.0869,    0.7265,    0.6468,    0.2439,    0.3136,    0.2803},
+{    0.0645,    0.2643,    0.0081,    0.1300,    0.2820,    0.0013,    0.0007,    0.1176,    0.0756,    0.0972},
+{    0.0873,    0.2957,    0.0172,    0.1622,    0.3171,    0.0000,    0.0047,    0.1531,    0.1019,    0.1247},
+{    0.0232,    0.0117,    0.0993,    0.0017,    0.0174,    0.1815,    0.1436,    0.0035,    0.0171,    0.0091},
+{    0.0236,    0.0117,    0.0990,    0.0019,    0.0174,    0.1884,    0.1468,    0.0037,    0.0176,    0.0094},
+{    0.0880,    0.0016,    0.2151,    0.0353,    0.0002,    0.3347,    0.2735,    0.0424,    0.0767,    0.0605},
+{    0.0612,    0.2553,    0.0076,    0.1243,    0.2881,    0.0014,    0.0006,    0.1127,    0.0723,    0.0948},
+{    0.0712,    0.0001,    0.1919,    0.0250,    0.0003,    0.3028,    0.2438,    0.0311,    0.0607,    0.0464},
+{    0.2640,    0.0683,    0.4605,    0.1632,    0.0539,    0.6409,    0.5558,    0.1872,    0.2484,    0.2165},
+
+              },
+            new double[,]
+              {
+{    0.3043,    0.2111,    0.0937,    0.2795,    0.0039,    0.3119,    0.2908,    0.3573,    0.2884,    0.1155},
+{    0.0311,    0.0075,    0.0063,    0.0237,    0.1980,    0.0349,    0.0254,    0.0467,    0.0251,    0.0021},
+{    0.0011,    0.0034,    0.0514,    0.0001,    0.3361,    0.0021,    0.0002,    0.0048,    0.0002,    0.0367},
+{    0.0372,    0.0097,    0.0043,    0.0287,    0.1743,    0.0407,    0.0312,    0.0534,    0.0305,    0.0010},
+{    0.0122,    0.0391,    0.1353,    0.0177,    0.4961,    0.0087,    0.0162,    0.0055,    0.0170,    0.1128},
+{    0.0056,    0.0275,    0.1095,    0.0095,    0.4598,    0.0037,    0.0087,    0.0015,    0.0091,    0.0905},
+{    0.5047,    0.3954,    0.2126,    0.4698,    0.0094,    0.5169,    0.4841,    0.5584,    0.4828,    0.2496},
+{    0.5240,    0.4027,    0.2288,    0.4855,    0.0119,    0.5436,    0.5076,    0.5679,    0.4977,    0.2620},
+{    0.1271,    0.0714,    0.0107,    0.1112,    0.0702,    0.1350,    0.1159,    0.1555,    0.1144,    0.0190},
+{    0.0203,    0.0557,    0.1587,    0.0268,    0.5785,    0.0170,    0.0262,    0.0120,    0.0268,    0.1351},
+              },
+            new double[,]
+              {
+{    0.0054,    0.4363,    0.0374,    0.0023,    0.4322,    0.5050,    0.0394,    0.0147,    0.0005,    0.0294},
+{    0.0017,    0.3100,    0.0057,    0.0265,    0.2917,    0.3606,    0.0070,    0.0570,    0.0086,    0.0030},
+{    0.2513,    0.0100,    0.1495,    0.3849,    0.0065,    0.0243,    0.1428,    0.4769,    0.3053,    0.1660},
+{    0.0845,    0.7606,    0.1664,    0.0274,    0.7108,    0.8653,    0.1766,    0.0090,    0.0577,    0.1507},
+{    0.0707,    0.7222,    0.1447,    0.0198,    0.6589,    0.7932,    0.1517,    0.0046,    0.0456,    0.1311},
+{    0.0198,    0.5458,    0.0650,    0.0002,    0.4907,    0.6123,    0.0715,    0.0033,    0.0079,    0.0564},
+{    0.1069,    0.0724,    0.0459,    0.2000,    0.0642,    0.1012,    0.0417,    0.2717,    0.1447,    0.0563},
+{    0.1655,    0.0345,    0.0884,    0.2758,    0.0286,    0.0577,    0.0816,    0.3546,    0.2104,    0.1009},
+{    0.1067,    0.0723,    0.0464,    0.2005,    0.0641,    0.1028,    0.0414,    0.2736,    0.1438,    0.0559},
+{    0.0182,    0.2133,    0.0004,    0.0650,    0.1937,    0.2616,    0.0001,    0.1122,    0.0353,    0.0017},
+              },
+            new double[,]
+              {
+{    0.0021,    0.0746,    0.0031,    0.0249,    0.1018,    0.1679,    0.0593,    0.0501,    0.0143,    0.0015},
+{    0.0836,    0.0011,    0.0897,    0.1607,    0.0053,    0.0294,    0.0000,    0.0005,    0.0156,    0.0434},
+{    0.0217,    0.2240,    0.0197,    0.0011,    0.2531,    0.3809,    0.1960,    0.1716,    0.0989,    0.0547},
+{    0.1593,    0.0050,    0.1656,    0.2607,    0.0010,    0.0048,    0.0114,    0.0166,    0.0543,    0.0991},
+{    0.0083,    0.1680,    0.0068,    0.0006,    0.1918,    0.2930,    0.1474,    0.1339,    0.0681,    0.0314},
+{    0.1662,    0.0059,    0.1676,    0.2716,    0.0013,    0.0041,    0.0126,    0.0182,    0.0575,    0.1032},
+{    0.0480,    0.0109,    0.0526,    0.1090,    0.0211,    0.0583,    0.0049,    0.0023,    0.0029,    0.0189},
+{    0.0009,    0.1240,    0.0005,    0.0068,    0.1558,    0.2422,    0.1030,    0.0867,    0.0381,    0.0134},
+{    0.0323,    0.2554,    0.0309,    0.0045,    0.3023,    0.4098,    0.2220,    0.2023,    0.1201,    0.0726},
+{    0.2451,    0.0313,    0.2555,    0.3645,    0.0186,    0.0012,    0.0442,    0.0549,    0.1118,    0.1741},
+              },
+            new double[,]
+              {
+{    0.6611,    0.4092,    0.0161,    0.7494,    0.0000,    0.0361,    0.1838,    0.1184,    0.4525,    0.2155},
+{    0.4466,    0.2511,    0.0006,    0.5202,    0.0225,    0.0019,    0.0781,    0.0379,    0.2771,    0.0975},
+{    0.1555,    0.0484,    0.0965,    0.1990,    0.1809,    0.0574,    0.0000,    0.0080,    0.0599,    0.0008},
+{    0.1186,    0.0277,    0.1289,    0.1581,    0.2184,    0.0807,    0.0027,    0.0200,    0.0387,    0.0005},
+{    0.1284,    0.0317,    0.1211,    0.1718,    0.2062,    0.0727,    0.0017,    0.0172,    0.0433,    0.0001},
+{    0.0479,    0.0018,    0.2333,    0.0749,    0.3511,    0.1675,    0.0326,    0.0736,    0.0047,    0.0228},
+{    0.1675,    0.0583,    0.0820,    0.2131,    0.1735,    0.0455,    0.0004,    0.0046,    0.0696,    0.0024},
+{    0.1692,    0.0579,    0.0819,    0.2138,    0.1669,    0.0452,    0.0005,    0.0042,    0.0702,    0.0026},
+{    0.5045,    0.2934,    0.0003,    0.5815,    0.0120,    0.0071,    0.1028,    0.0543,    0.3190,    0.1259},
+{    0.4673,    0.2708,    0.0000,    0.5382,    0.0169,    0.0039,    0.0891,    0.0455,    0.2954,    0.1079},
+              },
+            new double[,]
+              {
+{   13.7185,   13.5970,   14.4724,   13.6668,   14.2254,   13.4477,   13.9840,   14.2096,   13.9596,   14.3828},
+{   13.8542,   14.0889,   14.1062,   13.7957,   14.1607,   13.5743,   14.0000,   14.3869,   14.1234,   14.3454},
+{   14.2753,   14.2173,   14.4492,   14.0445,   13.6775,   14.3044,   14.4343,   13.9773,   14.2278,   14.4183},
+{   14.2829,   13.6339,   14.2875,   14.1263,   13.2777,   13.7501,   14.5498,   14.5238,   14.4923,   14.3972},
+{   14.5334,   13.7703,   14.2618,   14.5649,   13.1097,   13.3585,   14.3100,   14.6126,   14.5857,   14.4907},
+{   14.5125,   14.1727,   14.0872,   14.4155,   13.3905,   13.7667,   14.5035,   14.6775,   14.6809,   14.4932},
+{   13.8321,   14.2292,   14.1566,   13.7114,   14.5073,   13.6796,   13.9499,   13.8703,   13.9795,   14.3852},
+{   13.8260,   13.8756,   14.3651,   13.6258,   14.1115,   13.8588,   14.0675,   13.6042,   13.8604,   14.2964},
+{   13.9103,   14.0681,   14.4953,   13.8241,   14.3221,   13.7864,   14.0331,   14.0426,   13.9991,   14.4548},
+{   13.7248,   14.1238,   13.8747,   13.5695,   13.8893,   13.8218,   14.0442,   14.3604,   14.0418,   14.1283},
+              },
+          }
+      );
+    }
+
+    [TestMethod]
+    public void CovSumTest() {
+      var cov = new CovarianceSum();
+      cov.Terms.Add(new CovarianceSEiso());
+      cov.Terms.Add(new CovarianceLinear());
+      TestCovarianceFunction(cov, 0,
+        new double[,]
+          {
+{    1.4860,    1.5376,    2.7382,    1.4230,    2.7566,    2.0148,    1.9261,    1.8493,    1.6069,    2.2035},
+{    1.0861,    1.4463,    1.8848,    1.0165,    2.1818,    1.6036,    1.4240,    1.4965,    1.2360,    1.6526},
+{    2.1463,    2.2472,    2.8854,    1.9188,    2.4455,    2.9283,    2.5049,    1.8107,    2.0157,    2.4059},
+{    1.6245,    1.2089,    2.2059,    1.4630,    1.5864,    1.9084,    2.0859,    1.7825,    1.7332,    1.8574},
+{    1.6804,    1.1454,    2.0031,    1.6914,    1.2725,    1.4029,    1.6810,    1.6888,    1.6437,    1.7665},
+{    1.4052,    1.2437,    1.5900,    1.2941,    1.2438,    1.4882,    1.6072,    1.4970,    1.4811,    1.5135},
+{    1.4913,    1.9972,    2.3544,    1.3689,    2.9275,    2.1163,    1.8043,    1.4564,    1.5325,    2.1139},
+{    2.0334,    2.2303,    3.0928,    1.8439,    3.1092,    2.8169,    2.4555,    1.7771,    1.9760,    2.5789},
+{    1.7324,    2.0254,    2.8414,    1.6386,    2.9270,    2.3807,    2.0510,    1.7808,    1.7231,    2.3527},
+{    0.9196,    1.4220,    1.6254,    0.7696,    1.8861,    1.7579,    1.4076,    1.4163,    1.1077,    1.3988},
+          },
+        new double[][,]
+          {      
+            new double[,]
+              {
+{    0.6345,    0.6652,    0.2647,    0.6484,    0.4251,    0.6943,    0.5427,    0.4338,    0.5527,    0.3280},
+{    0.5921,    0.4959,    0.4876,    0.6115,    0.4601,    0.6702,    0.5360,    0.3252,    0.4791,    0.3526},
+{    0.3961,    0.4296,    0.2816,    0.5165,    0.6456,    0.3784,    0.2923,    0.5455,    0.4237,    0.3036},
+{    0.3916,    0.6566,    0.3888,    0.4777,    0.7173,    0.6255,    0.2051,    0.2256,    0.2498,    0.3182},
+{    0.2181,    0.6194,    0.4041,    0.1929,    0.7305,    0.7077,    0.3750,    0.1532,    0.1758,    0.2510},
+{    0.2344,    0.4538,    0.4967,    0.3056,    0.7032,    0.6205,    0.2413,    0.0960,    0.0929,    0.2492},
+{    0.5996,    0.4229,    0.4622,    0.6365,    0.2384,    0.6451,    0.5566,    0.5865,    0.5446,    0.3263},
+{    0.6017,    0.5846,    0.3398,    0.6585,    0.4850,    0.5905,    0.5060,    0.6636,    0.5900,    0.3834},
+{    0.5719,    0.5057,    0.2476,    0.6023,    0.3674,    0.6144,    0.5216,    0.5174,    0.5364,    0.2776},
+{    0.6327,    0.4789,    0.5849,    0.6712,    0.5796,    0.6030,    0.5167,    0.3428,    0.5177,    0.4767},
+              },
+            new double[,]
+              {
+{    1.1542,    1.0808,    1.7137,    1.1224,    1.5090,    0.9961,    1.3298,    1.4968,    1.3127,    1.6369},
+{    1.2413,    1.4053,    1.4181,    1.2031,    1.4591,    1.0675,    1.3411,    1.6404,    1.4309,    1.6057},
+{    1.5486,    1.5027,    1.6936,    1.3729,    1.1289,    1.5721,    1.6807,    1.3251,    1.5109,    1.6670},
+{    1.5547,    1.1026,    1.5584,    1.4331,    0.9067,    1.1739,    1.7826,    1.7593,    1.7313,    1.6490},
+{    1.7679,    1.1868,    1.5379,    1.7963,    0.8253,    0.9483,    1.5767,    1.8403,    1.8154,    1.7298},
+{    1.7492,    1.4683,    1.4041,    1.6646,    0.9652,    1.1845,    1.7411,    1.9016,    1.9048,    1.7320},
+{    1.2267,    1.5121,    1.4560,    1.1498,    1.7445,    1.1302,    1.3060,    1.2519,    1.3266,    1.6389},
+{    1.2227,    1.2555,    1.6220,    1.0978,    1.4220,    1.2443,    1.3896,    1.0850,    1.2454,    1.5656},
+{    1.2789,    1.3900,    1.7339,    1.2214,    1.5866,    1.1971,    1.3647,    1.3715,    1.3404,    1.6984},
+{    1.1581,    1.4312,    1.2549,    1.0647,    1.2647,    1.2200,    1.3726,    1.6182,    1.3709,    1.4346},
+              },
+          }
+      );
+      TestCovarianceFunction(cov, 1,
+        new double[,]
+          {
+{    7.7681,    7.7957,    9.1175,    7.6951,    9.1148,    8.2406,    8.2532,    8.2057,    7.9303,    8.5765},
+{    7.3926,    7.7881,    8.2289,    7.3128,    8.5326,    7.8570,    7.7535,    7.8698,    7.5822,    8.0224},
+{    8.5096,    8.6045,    9.2632,    8.2546,    8.7198,    9.2945,    8.8817,    8.1368,    8.3741,    8.7816},
+{    7.9886,    7.4745,    8.5704,    7.8096,    7.7719,    8.1964,    8.4695,    8.1648,    8.1138,    8.2315},
+{    8.0632,    7.4371,    8.3651,    8.0757,    7.4147,    7.6080,    8.0477,    8.0750,    8.0288,    8.1469},
+{    7.7869,    7.5959,    7.9316,    7.6696,    7.4564,    7.7793,    7.9884,    7.8850,    7.8692,    7.8941},
+{    7.7940,    8.3557,    8.7048,    7.6497,    9.3089,    8.3910,    8.1263,    7.7655,    7.8589,    8.4871},
+{    8.3350,    8.5404,    9.4643,    8.1079,    9.4540,    9.1241,    8.7945,    8.0367,    8.2835,    8.9443},
+{    8.0481,    8.3644,    9.2221,    7.9399,    9.2948,    8.6753,    8.3852,    8.1164,    8.0524,    8.7309},
+{    7.2030,    7.7683,    7.9353,    7.0220,    8.1984,    8.0588,    7.7433,    7.7874,    7.4431,    7.7457},
+          },
+        new double[][,]
+          {            
+            new double[,]
+              {
+{    1.0207,    1.1326,    0.3026,    1.0685,    0.5423,    1.2686,    0.7724,    0.5574,    0.7955,    0.3900},
+{    0.8944,    0.6729,    0.6564,    0.9490,    0.6043,    1.1534,    0.7573,    0.3860,    0.6400,    0.4263},
+{    0.4942,    0.5501,    0.3252,    0.7151,    1.0586,    0.4660,    0.3398,    0.7787,    0.5400,    0.3554},
+{    0.4868,    1.0987,    0.4824,    0.6372,    1.4215,    0.9914,    0.2266,    0.2521,    0.2830,    0.3760},
+{    0.2427,    0.9726,    0.5072,    0.2117,    1.5705,    1.3491,    0.4606,    0.1646,    0.1911,    0.2846},
+{    0.2632,    0.5928,    0.6745,    0.3581,    1.3203,    0.9760,    0.2721,    0.1002,    0.0969,    0.2822},
+{    0.9151,    0.5386,    0.6082,    1.0272,    0.2684,    1.0567,    0.8045,    0.8794,    0.7766,    0.3876},
+{    0.9208,    0.8744,    0.4072,    1.1062,    0.6514,    0.8901,    0.6932,    1.1260,    0.8886,    0.4738},
+{    0.8418,    0.6927,    0.2801,    0.9226,    0.4489,    0.9576,    0.7259,    0.7169,    0.7582,    0.3198},
+{    1.0149,    0.6396,    0.8752,    1.1578,    0.8615,    0.9246,    0.7154,    0.4117,    0.7177,    0.6353},
+              },
+            new double[,]
+              {
+{   13.7185,   13.5970,   14.4724,   13.6668,   14.2254,   13.4477,   13.9840,   14.2096,   13.9596,   14.3828},
+{   13.8542,   14.0889,   14.1062,   13.7957,   14.1607,   13.5743,   14.0000,   14.3869,   14.1234,   14.3454},
+{   14.2753,   14.2173,   14.4492,   14.0445,   13.6775,   14.3044,   14.4343,   13.9773,   14.2278,   14.4183},
+{   14.2829,   13.6339,   14.2875,   14.1263,   13.2777,   13.7501,   14.5498,   14.5238,   14.4923,   14.3972},
+{   14.5334,   13.7703,   14.2618,   14.5649,   13.1097,   13.3585,   14.3100,   14.6126,   14.5857,   14.4907},
+{   14.5125,   14.1727,   14.0872,   14.4155,   13.3905,   13.7667,   14.5035,   14.6775,   14.6809,   14.4932},
+{   13.8321,   14.2292,   14.1566,   13.7114,   14.5073,   13.6796,   13.9499,   13.8703,   13.9795,   14.3852},
+{   13.8260,   13.8756,   14.3651,   13.6258,   14.1115,   13.8588,   14.0675,   13.6042,   13.8604,   14.2964},
+{   13.9103,   14.0681,   14.4953,   13.8241,   14.3221,   13.7864,   14.0331,   14.0426,   13.9991,   14.4548},
+{   13.7248,   14.1238,   13.8747,   13.5695,   13.8893,   13.8218,   14.0442,   14.3604,   14.0418,   14.1283},
+              },
+          }
+      );
+    }
+    [TestMethod]
+    public void CovProdTest() {
+      var cov = new CovarianceProd();
+      cov.Factors.Add(new CovarianceSEiso());
+      cov.Factors.Add(new CovarianceLinear());
+      TestCovarianceFunction(cov, 0,
+        new double[,]
+          {
+{    0.5245,    0.5389,    1.6120,    0.4836,    1.5106,    0.7554,    0.8386,    0.8239,    0.6239,    1.1336},
+{    0.2889,    0.5225,    0.8337,    0.2496,    1.0595,    0.5710,    0.5052,    0.5547,    0.3724,    0.6822},
+{    1.0623,    1.1239,    1.7263,    0.8459,    1.0618,    1.6839,    1.3988,    0.7607,    0.9521,    1.3106},
+{    0.6585,    0.3625,    1.1117,    0.5349,    0.5137,    0.7756,    1.0648,    0.7942,    0.7510,    0.8516},
+{    0.7040,    0.3275,    0.9490,    0.7125,    0.3548,    0.4404,    0.7037,    0.7073,    0.6680,    0.7798},
+{    0.4641,    0.3741,    0.6234,    0.3844,    0.3673,    0.5306,    0.6413,    0.5193,    0.5036,    0.5608},
+{    0.5385,    0.9383,    1.1840,    0.4565,    1.7927,    0.8766,    0.7518,    0.5198,    0.5765,    1.0608},
+{    0.8694,    1.0060,    1.8506,    0.7108,    1.7052,    1.3654,    1.2234,    0.6698,    0.8427,    1.4060},
+{    0.6989,    0.9246,    1.7118,    0.6277,    1.6927,    1.0667,    0.9339,    0.7510,    0.7057,    1.2768},
+{    0.1972,    0.5055,    0.6262,    0.1263,    0.7928,    0.7002,    0.4950,    0.4913,    0.2894,    0.4889},
+
+          },
+        new double[][,]
+          {      
+            new double[,]
+              {
+{    0.5767,    0.6633,    0.4980,    0.5588,    0.8510,    1.0532,    0.6845,    0.4776,    0.5254,    0.4543},
+{    0.2756,    0.3688,    0.5733,    0.2537,    0.6682,    0.7170,    0.4039,    0.2199,    0.2494,    0.2996},
+{    0.5435,    0.6426,    0.5741,    0.6365,    1.2144,    0.8107,    0.4866,    0.6263,    0.5340,    0.4774},
+{    0.3317,    0.4317,    0.5547,    0.3566,    0.8127,    0.8265,    0.2450,    0.2037,    0.2167,    0.3287},
+{    0.1737,    0.3419,    0.4987,    0.1530,    0.6281,    0.6573,    0.3347,    0.1177,    0.1294,    0.2263},
+{    0.1244,    0.2312,    0.4411,    0.1411,    0.5353,    0.5559,    0.1778,    0.0524,    0.0491,    0.1614},
+{    0.5264,    0.5249,    0.7518,    0.5054,    0.4900,    1.0006,    0.6408,    0.4870,    0.4733,    0.4224},
+{    0.8556,    0.9368,    0.7753,    0.8528,    1.1632,    1.2961,    0.8909,    0.8193,    0.7984,    0.6886},
+{    0.6251,    0.6728,    0.4889,    0.6191,    0.7840,    1.0950,    0.7139,    0.5665,    0.5648,    0.4174},
+{    0.2155,    0.3383,    0.5837,    0.1593,    0.7267,    0.6922,    0.3726,    0.2082,    0.2186,    0.3249},
+              },
+            new double[,]
+              {
+{    1.0490,    1.0777,    3.2240,    0.9672,    3.0213,    1.5108,    1.6771,    1.6478,    1.2478,    2.2672},
+{    0.5777,    1.0450,    1.6673,    0.4992,    2.1190,    1.1421,    1.0104,    1.1094,    0.7448,    1.3644},
+{    2.1246,    2.2479,    3.4526,    1.6919,    2.1236,    3.3679,    2.7976,    1.5214,    1.9041,    2.6212},
+{    1.3170,    0.7250,    2.2233,    1.0698,    1.0274,    1.5513,    2.1295,    1.5883,    1.5021,    1.7032},
+{    1.4080,    0.6551,    1.8980,    1.4249,    0.7096,    0.8808,    1.4075,    1.4146,    1.3360,    1.5596},
+{    0.9281,    0.7482,    1.2467,    0.7687,    0.7347,    1.0613,    1.2826,    1.0386,    1.0071,    1.1216},
+{    1.0770,    1.8767,    2.3681,    0.9129,    3.5854,    1.7532,    1.5037,    1.0396,    1.1531,    2.1215},
+{    1.7387,    2.0120,    3.7012,    1.4217,    3.4103,    2.7309,    2.4467,    1.3395,    1.6854,    2.8121},
+{    1.3978,    1.8493,    3.4235,    1.2554,    3.3854,    2.1334,    1.8678,    1.5019,    1.4113,    2.5536},
+{    0.3944,    1.0110,    1.2523,    0.2526,    1.5856,    1.4004,    0.9900,    0.9825,    0.5788,    0.9777},
+              },
+          }
+      );
+      TestCovarianceFunction(cov, 1,
+        new double[,]
+          {
+{    6.2342,    6.7795,   13.6134,    5.8887,   14.2405,   10.1987,    8.8183,    7.8217,    6.6344,    9.9609},
+{    3.2242,    5.2384,    8.2928,    2.8624,   10.2826,    7.2613,    5.2743,    4.8651,    3.6758,    6.0948},
+{    9.7926,   10.6338,   14.7280,    8.6537,   12.8640,   15.3218,   12.0130,    8.0240,    8.9653,   11.3359},
+{    6.0497,    4.4825,   10.1916,    5.2725,    7.5223,    9.0848,    8.6907,    6.5563,    6.2868,    7.4352},
+{    5.7877,    3.8005,    8.8010,    5.7766,    5.6360,    6.2037,    6.3872,    5.6164,    5.3671,    6.5321},
+{    3.8501,    3.6110,    6.2543,    3.3286,    5.0963,    6.1672,    5.3421,    4.0085,    3.8812,    4.6925},
+{    6.0719,    8.8301,   11.5124,    5.4433,   14.9080,   10.6099,    8.0304,    5.7589,    6.0753,    9.3107},
+{    9.8306,   11.1183,   16.3892,    8.8231,   16.9213,   15.2084,   12.3844,    8.3980,    9.3789,   12.8390},
+{    7.6019,    9.3580,   14.3105,    7.1044,   15.2800,   12.2846,    9.6031,    7.6887,    7.3699,   10.8667},
+{    2.3372,    4.9884,    6.9233,    1.6100,    8.7070,    7.9328,    5.0646,    4.3597,    2.9643,    4.8145},
+          },
+        new double[][,]
+          {            
+            new double[,]
+              {
+{    0.9277,    1.1294,    0.5692,    0.9208,    1.0857,    1.9243,    0.9742,    0.6136,    0.7561,    0.5402},
+{    0.4163,    0.5003,    0.7718,    0.3938,    0.8777,    1.2339,    0.5706,    0.2610,    0.3331,    0.3622},
+{    0.6780,    0.8229,    0.6629,    0.8812,    1.9912,    0.9983,    0.5655,    0.8941,    0.6805,    0.5589},
+{    0.4124,    0.7225,    0.6882,    0.4757,    1.6107,    1.3101,    0.2707,    0.2276,    0.2455,    0.3883},
+{    0.1933,    0.5369,    0.6259,    0.1679,    1.3503,    1.2531,    0.4112,    0.1265,    0.1406,    0.2566},
+{    0.1396,    0.3021,    0.5989,    0.1654,    1.0050,    0.8744,    0.2004,    0.0548,    0.0512,    0.1827},
+{    0.8034,    0.6684,    0.9892,    0.8156,    0.5515,    1.6391,    0.9263,    0.7302,    0.6750,    0.5018},
+{    1.3094,    1.4012,    0.9292,    1.4326,    1.5622,    1.9537,    1.2206,    1.3902,    1.2026,    0.8509},
+{    0.9201,    0.9215,    0.5531,    0.9483,    0.9578,    1.7066,    0.9935,    0.7850,    0.7983,    0.4808},
+{    0.3456,    0.4518,    0.8735,    0.2747,    1.0802,    1.0614,    0.5160,    0.2500,    0.3030,    0.4330},
+              },
+            new double[,]
+              {
+{   12.4684,   13.5589,   27.2269,   11.7775,   28.4810,   20.3974,   17.6367,   15.6433,   13.2687,   19.9218},
+{    6.4483,   10.4768,   16.5855,    5.7248,   20.5652,   14.5226,   10.5485,    9.7302,    7.3516,   12.1897},
+{   19.5852,   21.2676,   29.4561,   17.3075,   25.7280,   30.6436,   24.0261,   16.0481,   17.9305,   22.6719},
+{   12.0994,    8.9651,   20.3832,   10.5449,   15.0447,   18.1696,   17.3814,   13.1126,   12.5737,   14.8704},
+{   11.5753,    7.6010,   17.6020,   11.5533,   11.2719,   12.4074,   12.7745,   11.2328,   10.7342,   13.0642},
+{    7.7002,    7.2219,   12.5086,    6.6571,   10.1926,   12.3345,   10.6842,    8.0169,    7.7623,    9.3850},
+{   12.1437,   17.6603,   23.0249,   10.8865,   29.8159,   21.2199,   16.0607,   11.5178,   12.1505,   18.6213},
+{   19.6612,   22.2367,   32.7783,   17.6462,   33.8425,   30.4168,   24.7688,   16.7960,   18.7578,   25.6781},
+{   15.2039,   18.7161,   28.6209,   14.2089,   30.5600,   24.5693,   19.2063,   15.3774,   14.7399,   21.7333},
+{    4.6744,    9.9769,   13.8465,    3.2199,   17.4141,   15.8657,   10.1292,    8.7194,    5.9286,    9.6290},
+              },
+          }
+      );
+    }
+
+
+    private void TestCovarianceFunction(ICovarianceFunction cf, double hypValue, double[,] expectedCov, double[][,] expectedGradients) {
+      var x = GetData();
+      var xt = GetDataTest();
+
+      int nHyp = cf.GetNumberOfParameters(x.GetLength(1));
+      var hyp = Enumerable.Repeat(hypValue, nHyp).ToArray();
+      cf.SetParameter(hyp);
+      cf.SetData(x, xt);
+
+      int rows0 = x.GetLength(0);
+      int rows1 = xt.GetLength(0);
+      var actualCov = new double[rows0, rows1];
+      for (int i = 0; i < rows0; i++)
+        for (int j = 0; j < rows1; j++)
+          actualCov[i, j] = cf.GetCovariance(i, j);
+
+      AssertEqual(expectedCov, actualCov);
+
+      for (int i = 0; i < rows0; i++)
+        for (int j = 0; j < rows1; j++) {
+          var g = cf.GetGradient(i, j);
+          for (int k = 0; k < nHyp; k++)
+            Assert.AreEqual(expectedGradients[k][i, j], g[k], 5E-3);
+        }
+    }
+
+
+    private void TestMeanFunction(IMeanFunction mf, double hypValue, double[] expectedMean, double[][] expectedGradients) {
+      var x = GetData();
+      var xt = GetDataTest();
+
+      int nHyp = mf.GetNumberOfParameters(x.GetLength(1));
+      var hyp = Enumerable.Repeat(hypValue, nHyp).ToArray();
+      mf.SetParameter(hyp);
+      mf.SetData(x);
+
+      var m = mf.GetMean(xt);
+
+      AssertEqual(expectedMean, m);
+
+      for (int i = 0; i < nHyp; i++) {
+        var g = mf.GetGradients(i, x);
+        AssertEqual(expectedGradients[i], g);
+      }
+    }
+
+
+    private void AssertEqual(double[] expected, double[] actual) {
+      Assert.AreEqual(expected.Length, actual.Length);
+      for (int i = 0; i < expected.Length; i++)
+        Assert.AreEqual(expected[i], actual[i], 1E-3);
+    }
+    private void AssertEqual(double[,] expected, double[,] actual) {
+      Assert.AreEqual(expected.Length, actual.Length);
+      for (int i = 0; i < expected.GetLength(0); i++)
+        for (int j = 0; j < expected.GetLength(1); j++)
+          Assert.AreEqual(expected[i, j], actual[i, j], 5E-3);
+    }
+
+    private double[,] GetData() {
+      return new double[,]
+               {
+                 {0.4173, 0.7803, 0.2348, 0.5470, 0.9294},
+                 {0.0497, 0.3897, 0.3532, 0.2963, 0.7757},
+                 {0.9027, 0.2417, 0.8212, 0.7447, 0.4868},
+                 {0.9448, 0.4039, 0.0154, 0.1890, 0.4359},
+                 {0.4909, 0.0965, 0.0430, 0.6868, 0.4468},
+                 {0.4893, 0.1320, 0.1690, 0.1835, 0.3063},
+                 {0.3377, 0.9421, 0.6491, 0.3685, 0.5085},
+                 {0.9001, 0.9561, 0.7317, 0.6256, 0.5108},
+                 {0.3692, 0.5752, 0.6477, 0.7802, 0.8176},
+                 {0.1112, 0.0598, 0.4509, 0.0811, 0.7948}
+               };
+    }
+
+    private double[,] GetDataTest() {
+      return new double[,]
+               {
+                 {0.6443, 0.2077, 0.3111, 0.5949, 0.0855},
+                 {0.3786, 0.3012, 0.9234, 0.2622, 0.2625},
+                 {0.8116, 0.4709, 0.4302, 0.6028, 0.8010},
+                 {0.5328, 0.2305, 0.1848, 0.7112, 0.0292},
+                 {0.3507, 0.8443, 0.9049, 0.2217, 0.9289},
+                 {0.9390, 0.1948, 0.9797, 0.1174, 0.7303},
+                 {0.8759, 0.2259, 0.4389, 0.2967, 0.4886},
+                 {0.5502, 0.1707, 0.1111, 0.3188, 0.5785},
+                 {0.6225, 0.2277, 0.2581, 0.4242, 0.2373},
+                 {0.5870, 0.4357, 0.4087, 0.5079, 0.4588}
+               };
+    }
+  }
+}
Index: trunk/sources/HeuristicLab.Tests/HeuristicLab.Tests.csproj
===================================================================
--- trunk/sources/HeuristicLab.Tests/HeuristicLab.Tests.csproj	(revision 8435)
+++ trunk/sources/HeuristicLab.Tests/HeuristicLab.Tests.csproj	(revision 8439)
@@ -290,4 +290,5 @@
     <Compile Include="HeuristicLab-3.3\ThreadSafeLogTest.cs" />
     <Compile Include="HeuristicLab-3.3\ToStringTest.cs" />
+    <Compile Include="HeuristicLab.Algorithms.DataAnalysis-3.4\GaussianProcessFunctionsTest.cs" />
     <Compile Include="HeuristicLab.Analysis-3.3\MultidimensionalScalingTest.cs" />
     <Compile Include="HeuristicLab.Encodings.BinaryVectorEncoding-3.3\Auxiliary.cs" />
