# Matrix rank triangular matrix [closed]

Does MatrixRank check whether a matrix is triangular? If not, what would be the best way to calculate a matrix rank of a (say upper)triangular matrix in the following practical cases:

1. you have a lot of small matrices,
2. you have a huge dense matrix, and
3. you have a huge sparse matrix?

(Here dense means dense above/below the diagonal)

• Might be of relevant: Some Notes On Internal Implementation – Henrik Schumacher Dec 9 '19 at 17:49
• @bills No, take e.g. { {0,1}, {0,0} }. This one has rank 1 but the diagonal only has 0 elements – Gert Dec 9 '19 at 18:00
• MatrixRank utilizes singular value decomposition, and in absence of any more sophisticated methods (e.g., rank-revealing QR-factorization) in Mathematica I would indeed suggest to use MatrixRank or Length@*SingularValueList, but only for matrices of size $m \times n$ where $m$ and $n$ not more than a few thousand. – Henrik Schumacher Dec 9 '19 at 18:07