//I NEED DIS. public static Matrix operator-(Matrix mat1, double d) { Matrix temp = new Matrix(mat1.Rows, mat1.Columns); for (int i = 0; i < mat1.Rows; i++) { for (int j = 0; j < mat1.Columns; j++) { temp.SetElement(i, j, (mat1.Elements[i, j] - d)); } } return(temp); }
public static Matrix operator-(Matrix mat1, Matrix mat2) { if (mat1.Rows == mat2.Rows && mat1.Columns == mat2.Columns) { Matrix temp = new Matrix(mat1.Rows, mat2.Columns); for (int i = 0; i < mat1.Rows; i++) { for (int j = 0; j < mat1.Columns; j++) { temp.SetElement(i, j, (mat1.Elements[i, j] - mat2.Elements[i, j])); } } return(temp); } throw new Exception("Matrices are not the same size!"); }