3
$\begingroup$

I'm trying to create a probability matrix, starting by creating a 100,000 by 100,000 identity matrix. However, when I try to create this using:

IdentityMatrix[100000]

The interpreter just stops without an error message or prompt, and the variables turn blue. Why does this happen and How can I get around it?

$\endgroup$

1 Answer 1

5
$\begingroup$

This happens because you asked Mathematica to allocate this amount of memory (unless told otherwise, Mathematica tries to allocate a packed array of 64 bit integers):

UnitConvert[100000^2 Quantity[64, "Bits"], "Gigabytes"]

Quantity[80, "Gigabytes"]

Might be a bit too much for your system.

Better use

IdentityMatrix[100000, SparseArray]

In general, I suggest to get in touch with SparseArray in order to learn how to construct sparse matrices efficiently.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.