Registered Member
|
Hi,
I am working with Eigen matrix/vectors passing as parameters in function. The basic structure of my code is the following: main.cpp
f1.cpp
f1.h
When I run, I have this error: Assertion failed: rows()==other.row() && cols()==other.cols(), \Library\Eigen\Eigen\src\Core\Assign.h I suppose it's because in main I declare my vector v empty and in my function I want for example a vector of length 11. The thing is I don't know the length of my vector in the main, I want to determine it in f1.h. How can I do? Thank you, Julien |
Moderator
|
Only Matrix<> objects can be resized, so in your case the prototype of f should be:
void f(VectorXd& v); Indeed, a Ref<VectorXd> can reference the content of a VectorXf, but also a sub-vector, like vec.segment(1,10), or a Map<VectorXd>, etc. All these objects cannot be resized. |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]