Registered Member
|
I know it it is possible to set a matrix's diagonal elements to a constant like this:
However, I want to set the adjacent diagonal elements to particular constants too, i.e. I want to take not the main diagonal elements but the diagonal elements where each of the elements is one position below the main diagonal. Is there a way to do it without looping? EDIT: I have figured out one possible solution:
Besides this, is there a "better" way to do it? |
Moderator
|
yes, mat.diagonal(-1) or mat.diagonal(1) to get the sub/super diagonals, and of course you can get the other diagonals too... See: http://eigen.tuxfamily.org/dox-devel/cl ... 3dd988a7f7
|
Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft