1
$\begingroup$

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)

$\endgroup$
  • 1
    $\begingroup$ Might be of relevant: Some Notes On Internal Implementation $\endgroup$ – Henrik Schumacher Dec 9 '19 at 17:49
  • 1
    $\begingroup$ @bills No, take e.g. { {0,1}, {0,0} }. This one has rank 1 but the diagonal only has 0 elements $\endgroup$ – Gert Dec 9 '19 at 18:00
  • $\begingroup$ 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. $\endgroup$ – Henrik Schumacher Dec 9 '19 at 18:07