public Vector MatrixOnVectorMultiplication(Vector vector) { if (GetColumnsCount() != vector.GetSize()) { throw new ArgumentException("Vector must be <= columns count", nameof(vector)); } double[] value = new double[GetRowsCount()]; for (int i = 0; i < GetRowsCount(); i++) { value[i] = Vector.ScalarMultiplication(vector, Rows[i]); } return(new Vector(value)); }
public static Matrix Multiplication(Matrix firstMatrix, Matrix secondMatrix) { if (firstMatrix.GetColumnsCount() != secondMatrix.GetRowsCount()) { throw new Exception("Columns count 1 matrix must be equals rows count 2 matrix and rows count 1 matrix must be equals columns count 2 matrix"); } Matrix matrix = new Matrix(firstMatrix.GetRowsCount(), secondMatrix.GetColumnsCount()); double[] value = new double[matrix.GetColumnsCount()]; for (int i = 0; i < matrix.GetRowsCount(); i++) { for (int j = 0; j < matrix.GetColumnsCount(); j++) { value[j] = Vector.ScalarMultiplication(firstMatrix.Rows[i], secondMatrix.GetColumn(j)); } matrix.Rows[i] = new Vector(value); } return(matrix); }