private static Matrix Add(Matrix m1, Matrix m2) // Sčítání matic
{
if (m1.rows != m2.rows || m1.cols != m2.cols) throw new MException("Matrices must have the same dimensions!");
Matrix r = new Matrix(m1.rows, m1.cols);
for (int i = 0; i < r.rows; i++)
for (int j = 0; j < r.cols; j++)
r[i, j] = m1[i, j] + m2[i, j];
return r;
}