public static double Determinant(MatrixR m) { double result = 0.0; if (!m.IsSquared()) { throw new ArgumentOutOfRangeException( "Dimension", m.GetRows(), "The matrix must be squared!"); } if (m.GetRows() == 1) { result = m[0, 0]; } else { for (int i = 0; i < m.GetRows(); i++) { result += Math.Pow(-1, i) * m[0, i] * Determinant(MatrixR.Minor(m, 0, i)); } } return(result); }