Can you find the determinant of a matrix given its row echelon form?

I believe I stumbled on a resource for quickly computing the determinant of a matrix by converting it to row echelon form then acting upon the diagonal elements, either they're sum or product. However, I cannot find the specific link/resource, and so I'm no longer sure that this is a valid way of reaching the determinant.

Edit: B is an upper-triangular matrix, so detB is the product of its diagonal entries so perhaps my question should be, is it better/easier to just use the upper triangular matrix than to work with row echelon form?

You need to keep track of how many row swaps you have done because this multiplies the determinant by $$-1$$.
You can use elementary row operation matrices. The ones that correspond to adding/subtracting a row to another one have determinant one. Swapping rows has determinant $$-1$$. Hence, your determinant is the determinant of the matrix in row echelon from multiplied by $$(-1)^n$$, where $$n$$ is the number of row swaps you have done.
EDIT: I was using the wrong definition of row echelon form. One also has to keep track of the values you get in the diagonal before you divide to get $$1$$, and multiply it at the end as well.
• Likewise, in REF, the leading non-zero entries for each row should be 1. So, $1^n$ or $-1^n$ would only return $1|-1$ depending on the specific value of $n$, right? Commented Mar 24, 2021 at 17:12