I'm trying to construct a lower triangular matrix of a particular form, and as of right now, I'm using the following for loop:
M = sparse(eye(DIM));
for k = 1 : DIM - 1
ak = -z*(1-z)^(k-1);
M = M + sparse(diag(ak * ones(1, DIM - k), -k));
end
Basically, each diagonal from the main diagonal down is constant. I didn't include my definitions for DIM and z since they're not relevant to the construction of the matrix.
Does anyone know a faster way to do this? Maybe a vectorized version?