Closed JohanCarlsen closed 1 year ago
I found that you can make a tridiagonal matrix pretty easy with this:
arma::mat A = arma::mat(N,N); A.diag(-1).fill(a); A.diag(0).fill(d); A.diag(1).fill(e);
arma::mat A = arma::mat(N,N);
A.diag(-1).fill(a);
A.diag(0).fill(d);
A.diag(1).fill(e);
The method .diag(k) extracts the k'th diagonal, with k=0 being the main diagonal, k=-1 the sub diagonal and k=1 the super diagonal.
.diag(k)
k=0
k=-1
k=1
I found that you can make a tridiagonal matrix pretty easy with this:
arma::mat A = arma::mat(N,N);
A.diag(-1).fill(a);
A.diag(0).fill(d);
A.diag(1).fill(e);
The method
.diag(k)
extracts the k'th diagonal, withk=0
being the main diagonal,k=-1
the sub diagonal andk=1
the super diagonal.