Registered Member
|
Hello, I'm new to this library and I am trying to get some results fast.
I am using the generalized eigen solver, I can cout the values but I cannot access them individually or convert them with eigen2cv(MatrixXd(ges.eigenvals().real()), vals); In fact when compiling ges.eigenvals().real(); gives YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY How could I acces each element of the vector of eigenvalues individually? Thank you for reading, Dan |
Moderator
|
Can you be more specific? The following works for me:
BTW, in the case A and B are symmetric and one is positive definite, I'd recommend GeneralizedSelfAdjointEigenSolver: http://eigen.tuxfamily.org/dox/classEig ... olver.html |
Registered Member
|
First, thank you for the effort of answering. Your code does run without any issues.
Second, i've spent all day building opencv 2.4.6 hoping that their eigen module is faulty and it would work in the last version. The difference is that I'm not generating the values randomly, I'm filling the matrices from OpenCv like this: Mat vecs,vals; MatrixXf A; MatrixXf B; MatrixXf AmlB; VectorXf evals; cv2eigen(S, A); cv2eigen(C, B); GeneralizedEigenSolver<MatrixXd> ges(A,B); now, i get the same error at the GeneralizedEigenSolver constructor. With the older OpenCv version it was stopping only when calling eivals = ges.geteigenvalues().real(); and previously ges.compute(A, B); didn't raise errors. Dan |
Registered Member
|
Is the issue perhaps that A and B are of type MatrixXf (matrix of floats), but ges is expecting MatrixXd (matrix of doubles)? Can you change the type of ges to GeneralizedEigenSolver<MatrixXf> ?
|
Registered Member
|
Yes, as I was headding to the forum to write this issue I noticed you have already noticed it.
Thank you for putting up with this |
Registered users: Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]