Registered Member
|
Hi,
if I run the following code:
I get the following result:
What is my mistake? Thanks a lot, Markus |
Moderator
|
your mistake is that first, A.bottomRows(2) returns a Block<MatrixXd> that is then converted to a temporary MatrixXd object when you call the ctor of Test. Then you store a reference to this temporary which is by definition destroyed right after the end of the ctor, making your reference invalid.
|
Registered Member
|
Thank a lot - please excuse my ignorance.
What would be the most elegant solution to let a class have access to a block of a matrix that is altered outside during its lifetime? Cheers, Markus |
Moderator
|
you can store a Block<MatrixXd> object by value.
|
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]