/// <summary> /// Initializes a new instance of <see cref="TriangularLower"/> by copying the lower triangle of the provided 2D array. /// </summary> /// <param name="array2D">A 2-dimensional array containing the elements of the matrix. Constraints: /// <paramref name="array2D"/>.GetLength(0) == <paramref name="array2D"/>.GetLength(1).</param> /// <exception cref="NonMatchingDimensionsException">Thrown if <paramref name="array2D"/>.GetLength(0) != /// <paramref name="array2D"/>.GetLength(1).</exception> public static TriangularLower CreateFromArray(double[,] array2D) { int numRows = array2D.GetLength(0); int numCols = array2D.GetLength(1); if (numRows != numCols) { string msg = $"Provided array must have the same dimensions, but was ({numRows}x{numCols})"; throw new NonMatchingDimensionsException(msg); } return(new TriangularLower(Conversions.Array2DToPackedLowerRowMajor(array2D), numRows)); }