Registered Member
|
Hi,
I am facing problems when I want to call functions using eigen types as parameters. My final goal will be to create a project with the following structure: A 'main.cpp' using a function_1 written outside the main (with .cpp and .h files). 'function_1.ccp' uses also an external function 'function_2' (written in .cpp and .h files) I have succeeded to do that using as parameters of the functions simple types (int, float, ...) but I can't reproduce this method for eigen types parameters. I have looked to Eigen documentation 'Writing Functions Taking Eigen Types as Parameters' but It has not helped me since the documentation doesn't precise how to do with external functions. First I am trying to do that with a fake example. The minimal structure of my code is the following: main.cpp
function_1.cpp
function_1.h
function_2.cpp
function_2.h
I have the following error: In function 'main' undefined reference to 'void fonction_1<Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 1 ,0, -1, 1> >&) Thank you for your help, Julien |
Moderator
|
Template functions have to be defined in header files or explicitly instantiated for all possible template parameters. So if these two solutions are not suitable for you, you can use a Ref<VectorXd> type for you parameter. Compared to a simple VectorXd, this will give you more flexibility on the set of arguments that will be accepted without copy. See: http://eigen.tuxfamily.org/dox-devel/cl ... _1Ref.html for more details.
|
Registered Member
|
Thanks the Ref<Vector> works fine for me.
|
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]