Determining if a matrix is square by applying QR decomposition

45 Views Asked by At

I have been solving least squares problems and I came across the following problem:

"Construct an algorithm based on the $QR$ decomposition ($A=QR$) that determines whether a square matrix is singular or not, you explicitly write your algorithm".

What I have tried is to do $QR$ and if it can check the determinant of $R$ and if it is zero the matrix A is singular.

My doubt is if what I am doing makes sense or if on the contrary there is a better way to do it(where some property of $QR$ is applied)?