public static GeneralConfusionMatrix Combine(params GeneralConfusionMatrix[] matrices)
{
if (matrices == null)
throw new ArgumentNullException("matrices");
if (matrices.Length == 0)
throw new ArgumentException("At least one confusion matrix is required.", "matrices");
int classes = matrices[0].Classes;
int[,] total = new int[classes, classes];
foreach (var matrix in matrices)
{
if (matrix.Classes != classes)
throw new ArgumentException("The number of classes in one of the matrices differs.");
for (int j = 0; j < classes; j++)
for (int k = 0; k < classes; k++)
total[j, k] += matrix.Matrix[j, k];
}
return new GeneralConfusionMatrix(total);
}
}