Registered Member
|
template <typename Derived>
void PrintMatrix(const EigenBase<Derived>& M, int row_th, int nRows) //void PrintMatrix(MatrixXd & M, int row_th, int nRows) { cout<<left<<setw(8)<<setfill(' ')<<" "; for (int j=0;j<M.cols();j++) { cout<<"\t"<<setw(8)<<(j); } cout<<endl; for (int i=0;i<nRows;i++) { cout<<left<<setw(8)<<setfill(' ')<<row_th+i; for (int j=0;j<M.cols();j++) { cout<<"\t"<<setw(8)<<M(i+row_th,j); } cout<<endl; } } ----------------------------- Above is my function for print Eigen Matrix in a customized way. It used to work if the matrix argument is MatrixXd. Now I want to make the argument can be any matrix type. I read documentation and thought this is easy. But an error cannot be avoid as: "Undefined symbols for architecture x86_64: "void PrintMatrix<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::EigenBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, int, int)", referenced from: S5_Sort1NNByCommonFace_BCC() in S5_Sort1NNByCommonFace_BCC-2cc757.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)" I guess maybe some other things are wrong? Thanks, L |
Moderator
|
This is probably because you defined your function in a separate cpp file. Template functions must be defined in header files.
|
Registered Member
|
Thank you! I fixed it. You are always very helpful.
L |
Registered users: Bing [Bot], Evergrowing, Google [Bot], rockscient