# Det and MatrixRank freezes on SparseArray with nonzero default value

Why does the following simple code never come to an end (at least with version 8)

n = 5;
mat = SparseArray[{i_, i_} -> 1, {n, n}, -1/(n - 1)];
MatrixRank[mat]


when the following clearly doesn't cause any problem?

n = 5;
mat = Normal@SparseArray[{i_, i_} -> 1, {n, n}, -1/(n - 1)];
MatrixRank[mat]


The same issue appears to exist with Det instead of MatrixRank.

-
The problem does not seem to exist on newer versions, I'd suggest upgrading. –  rcollyer Aug 5 '13 at 17:12
On V8.0.4 (Mac) it more or less immediately crashes the kernel. The problem seems to be mixing Integer and Rational -- obviously a bug. Here's a workaround: mat = SparseArray[{i_, i_} -> 1/2, {n, n}, -1/(2 (n - 1))]. Then MatrixRank[mat] and Det[mat] return values. You would have to multiply the determinant by 2^n, but it returns zero. –  Michael E2 Aug 5 '13 at 18:20
The question code also crashes v7, and the workaround from @Michael works there too. –  Mr.Wizard Aug 5 '13 at 20:04