Home Constructing lower triangular matrix
Reply: 0

Constructing lower triangular matrix

user555
1#
user555 Published in June 18, 2018, 3:37 am

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?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.320743 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO