/// <summary> /// Adds the <see cref="SquareMatrix{T}"/> and the <see cref="SymmetricalMatrix{T}"/>. /// </summary> /// <typeparam name="T">Type of matrices elements.</typeparam> /// <param name="firstMatrix">The first matrix to add.</param> /// <param name="secondMatrix">The second matrix to add.</param> /// <returns>The matrix of added matrices elements.</returns> public static SymmetricalMatrix <T> Add <T>(this SquareMatrix <T> firstMatrix, SymmetricalMatrix <T> secondMatrix) { CheckMatrix <T>(firstMatrix, secondMatrix); T[,] resultArray = new T[firstMatrix.Order, secondMatrix.Order]; for (int i = 0; i < firstMatrix.Order; i++) { for (int j = 0; j < secondMatrix.Order; j++) { resultArray[i, j] = (dynamic)firstMatrix[i, j] + (dynamic)secondMatrix[i, j]; resultArray[j, i] = resultArray[i, j]; } } return(new SymmetricalMatrix <T>(resultArray)); }
/// <summary> /// Adds the <see cref="SymmetricalMatrix{T}"/> and the <see cref="SquareMatrix{T}"/>. /// </summary> /// <typeparam name="T">Type of matrices elements.</typeparam> /// <param name="firstMatrix">The first matrix to add.</param> /// <param name="secondMatrix">The second matrix to add.</param> /// <returns>The matrix of added matrices elements.</returns> public static SymmetricalMatrix <T> Add <T>(this SymmetricalMatrix <T> firstMatrix, SquareMatrix <T> secondMatrix) => Add(secondMatrix, firstMatrix);
/// <summary> /// Adds the <see cref="SymmetricalMatrix{T}"/> and the <see cref="SymmetricalMatrix{T}"/>. /// </summary> /// <typeparam name="T">Type of matrices elements.</typeparam> /// <param name="firstMatrix">The first matrix to add.</param> /// <param name="secondMatrix">The second matrix to add.</param> /// <returns>The matrix of added matrices elements.</returns> public static SymmetricalMatrix <T> Add <T>(this SymmetricalMatrix <T> firstMatrix, SymmetricalMatrix <T> secondMatrix) { return(new SymmetricalMatrix <T>(AddMatrix <T>(firstMatrix, secondMatrix))); }