Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
    
The problem does not seem to exist on newer versions, I'd suggest upgrading. –  rcollyer Aug 5 '13 at 17:12
1  
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.