I have a matrix, M, with very simple form: M[i,j]=a if i==j and M[i,j]=b everywhere else. M is very large (>10000) so I cannot initialize it or store it without using some sort of sparse matrix. It seems that the best way to store this matrix would be to use some sort of sparse matrix where non-entries are set to b instead of zero.
I have tried
M = spdiagm((a-b), N, N) .+ b
But doing it this way stores M as a 10 by 10 matrix with 100 entries which seems to mean that there is no compression.
Is there a better way to initialize this matrix?