Registered Member
|
I am getting a block of a matrix like so:
How do I go about assigning it to a local variable (which must be...? Eigen::Block?) so that I can work with that block now instead of typing out all that code every time. I have looked through the documentation and know how to pass it as a function argument, but how do I create a local variable of the block to store it temporarily and at the same time affect the original matrix when the block elements change? As you can tell, I am also new to template programming, so this is confusing me a little bit |
Moderator
|
here you go:
Block<typeof_H> block_of_H = H.block(ii(0), ii(0), 2, lenx); |
Registered Member
|
Excellent, thanks! Follow up question, what should I do in the following two cases:
1) I want the block to change the original matrix. So when I change the elements in the block, the original matrix reflects the change 2) I want the block to NOT change the original matrix |
Moderator
|
for case 1: see my previous reply
for case 2: copy the block to a temporary: MatrixXd H; // ... MatrixXd block_of_H = H.block(ii(0), ii(0), 2, lenx); |
Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], q.ignora