My question is related to my issue from yesterday (Initializing very large matrices). It was recommended to use SparseArray to initialize large matrices efficiently. However, I struggle to do so with my current issue. I want to initialize a matrix that approximates the Laplace operator in 3D with periodic boundary conditions. My ansatz for this is to calculate Kronecker products from the identity matrix $I$ and the matrix $A$,
$$\Delta_{3D}=I\otimes I \otimes A+I\otimes A\otimes I+A\otimes I \otimes I\,\, ,$$
where the matrix $A$ is the 1D-Laplace operator with periodic boundary conditions defined through:
A = SparseArray[{Band[{1, 1}] -> -2, Band[{2, 1}] -> 1, Band[{1, 2}] -> 1,
{M, 1} -> 1, {1, M} -> 1}, {M, M}];
My general goal is to calculate the smallest eigenvalues of such a big matrix. I am using the following code, but when I run it on my (maybe too old) laptop, Mathematica crashes.
M = 128;
A = SparseArray[{Band[{1, 1}] -> -2, Band[{2, 1}] -> 1,
Band[{1, 2}] -> 1, {M, 1} -> 1, {1, M} -> 1}, {M, M}];
Ident = IdentityMatrix[M];
Laplace = KroneckerProduct[Ident, Ident, A] +
KroneckerProduct[Ident, A, Ident] +
KroneckerProduct[A, Ident, Ident];
AbsoluteTiming[Eigenvalues[1.0*Laplace, -2,
Method -> {"Arnoldi", "Criteria" -> "Magnitude",
"MaxIterations" -> 10000}] // Chop]
I would be glad for any suggestions that make my code working (or even working faster and more efficiently).