Registered Member
|
i'm a neophyte of C++ programmation. i have to implement a program witch calculates the pseuinverse of a matrix. as the Eigen tutorial suggests, i have written a code like this:
if i try to compile it i'll get the errors: tut_eigen/pinv.cpp: In function ‘void pinv(Eigen::MatrixXf&)’: tut_eigen/pinv.cpp:18:14: error: ‘m_isInitialized’ was not declared in this scope tut_eigen/pinv.cpp:18:58: error: ‘ei_assert’ was not declared in this scope tut_eigen/pinv.cpp:20:4: error: ‘SingularValuesType’ was not declared in this scope tut_eigen/pinv.cpp:20:23: error: expected ‘;’ before ‘m_sigma_inv’ tut_eigen/pinv.cpp:21:22: error: ‘m_workMatrix’ was not declared in this scope tut_eigen/pinv.cpp:22:19: error: ‘m_sigma’ was not declared in this scope tut_eigen/pinv.cpp:23:19: error: ‘m_sigma_inv’ was not declared in this scope tut_eigen/pinv.cpp:24:22: error: ‘m_sigma_inv’ was not declared in this scope tut_eigen/pinv.cpp:26:15: error: ‘m_matV’ was not declared in this scope tut_eigen/pinv.cpp:26:22: error: ‘m_sigma_inv’ was not declared in this scope tut_eigen/pinv.cpp:26:47: error: ‘m_matU’ was not declared in this scope why?? they are not declared in SVD file? thank for your helping |
Registered Member
|
You should not use private variables of a class ( all of m_*) outside of a class definition. No tutorial page suggest that.
You should use high levels functions to access the values you want. To get the singular values, you can use the JacobiSVD class http://eigen.tuxfamily.org/dox-devel/cl ... biSVD.html |
Registered Member
|
thank you Dee33.
so...nobody can use this code!? why is it present in the FAQ? Should I modify my code using the types defined in JacobiSVD library instead of SVD library? can you suggest me how? thank you again |
Registered Member
|
ok I see. You mean the old fragment of code in this page http://eigen.tuxfamily.org/index.php?title=FAQ
The code was intended to be put in the SVD class, probably in Eigen2. For your own purposes, just use the matrices U, V and the singularvalues from the JacobiSVD class to compute the pseudo-inverse. This modified version of that code should do the job
Last edited by Dee33 on Tue Nov 06, 2012 2:39 pm, edited 1 time in total.
|
Registered Member
|
mmm
i included JacobiSVD and i tried the modified code but doesn't work: acer@ubuntu:~$ g++ -I / tut_eigen/pinv.cpp -o pinv tut_eigen/pinv.cpp:33:15: error: variable or field ‘pinv’ declared void tut_eigen/pinv.cpp:33:15: error: ‘MatrixType’ was not declared in this scope tut_eigen/pinv.cpp:33:27: error: ‘pinvmat’ was not declared in this scope i don't understand ...MatrixType is a template defined in JacobiSVD |
Registered Member
|
MatrixType is just a template type for that function.
I forgot to put template<typename MatrixType> before the definition of the function. |
Registered Member
|
yes, i had already tried it...
but... tut_eigen/pinv.cpp: In function ‘void pinv(MatrixType&)’: tut_eigen/pinv.cpp:37:7: error: ‘SingularValuesType’ was not declared in this scope tut_eigen/pinv.cpp:37:26: error: expected ‘;’ before ‘sigma’ tut_eigen/pinv.cpp:38:7: error: ‘sigma’ was not declared in this scope tut_eigen/pinv.cpp:39:7: error: ‘sigma_inv’ was not declared in this scope ......... |
Registered Member
|
Please, note that the goal here is to show you how to access outputs from Eigen classes. It's up to you to read the manual pages and to write your code for your own purposes. |
Registered Member
|
This version will works for you triangular test matrix.
|
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]