/// <summary>
/// An IEnumerable<double[]> extension method that converts the source into a matrix.
/// </summary>
/// <exception cref="InvalidOperationException">Thrown when the requested operation is invalid.</exception>
/// <param name="source">The source to act on.</param>
/// <param name="vectorType">The <see cref="VectorType"/> of the input array.</param>
/// <returns>e as a Matrix.</returns>
public static Matrix ToMatrix(this IEnumerable <Vector> source, VectorType vectorType = VectorType.Row)
{
var c = source.Count();
if (c == 0)
{
throw new InvalidOperationException("Cannot create matrix from an empty set.");
}
return(Matrix.Stack(vectorType, source.ToArray()));
}