Because I am dealing with huge matrixes, my computer can not handle it, because of the memory. But, in my matrix, a very small percentage of the elements are non-zero. So I should use SparseArray as far as I am aware. The problem is that, I do not really know how to transform my old way of defining my matrix to the new "SparseArray way". I gonna give a very simple toy model of my old way:
n = 3;
H = ConstantArray[0, {n*n, n*n}];
Do[
i = ix + (iy - 1)*n;
j = jx + (jy - 1)*n;
x = ix;
y = iy;
If[i == n && j == i - 1, H[[i, j]] = t*Exp[I*x],
If[i == n && j == i + n, H[[i, j]] = t,
If[i == n && j == i - (n - 1), H[[i, j]] = t*Exp[-I*x],
If[i == n && j == i + n*(n - 1), H[[i, j]] = t, 0]]]],
{iy, 1, n,1}, {ix, 1, n, 1}, {jy, 1, n, 1}, {jx, 1, n, 1}];
So my matrixes are like this but with many-many If.
Could somebody give me an idea of how to do it?
Thanks a lot