>...everything went not so good, a 10000x10000 sparse matrix was >created (what was ok), but the kernel went nuts with the memory use, >some gigabytes for a small sparsearray (You can try with greater >parameters, but starting with K=5000 things go weird)
>I think the problem has to do with the "predictive interface" that >tries to generate the normal form of the matrix, so it uses a lot of >memory (and even produces a kernel crash).
A few comments:
First, I cannot reproduce your results. That using your code slightly cleaned up, I don't see any problems. By slightly cleaned up I mean replacing K (which as a built-in meaning) with k and eliminating the local variable res which isn't needed to get: