When the Matrix argument is defined as constant I get
.resize(rows,cols) Matrix const MatrixXd as 'this' argument discards qualifiers error
void (const Eigen::MatrixXd &X){
X.resize(cols, rows) }
returns an error but this works as expected:
void(Eigen::MatrixXd &X){
X.resize(cols, rows)}
I'm not too familiar with c (other than using it for this class) and am wondering what this means?
Thanks for any pointers.
CodePudding user response:
The warning means that the resize
function that you called is not const qualified. The lack of const qualification means that the function cannot be called on a const lvalue. resize
is a function that modifies the object. The rough meaning of "const" is that modification isn't allowed.
X
is an lvalue reference to const, so non-const qualified functions cannot be called through the reference. You attempted to call a non-const qualified function through the const reference. Since that's not allowed, the compiler told you about the bug.