## Some issue while using Eigen 3.3.4 with ceres-Windows

slowersu
Registered Member
Posts
2
Karma
0

### Some issue while using Eigen 3.3.4 with ceres-Windows

Tue Nov 28, 2017 11:57 am
Enviornment: Eigen 3.3.4 + ceres-Windows + Visual Studio 2015.

I try create a rotation matrix from two non-orthogonal vector, R1 and R2, within my ceres cost function(it there is typename T = Jet).

First I try to calculate SDV of [R1 R2] for [U] and [V], it works fine under debug mode:

Code: Select all
`template <typename T>bool _RotateMatSvdOrth_Eigen3x2(Eigen::Matrix<T, 3, 1> *vecR1, Eigen::Matrix<T, 3, 1> *vecR2, Eigen::Matrix<T, 3, 3> &matOrthR){   if (vecR1 == NULL || vecR2 == NULL)      return false;   typedef Eigen::Matrix<T, 3, 2> EigenMatrixForSvd;   EigenMatrixForSvd matR1R2;   for (UINT8 i = 0; i < 3; i++)   {      matR1R2(i, 0) = (*vecR1)(i, 0);      matR1R2(i, 1) = (*vecR2)(i, 0);   }   Eigen::JacobiSVD<EigenMatrixForSvd> matSvd(matR1R2, Eigen::ComputeFullU | Eigen::ComputeFullV);   matR1R2.setZero();   for (int nSvdIdx = 0; nSvdIdx < matSvd.cols(); nSvdIdx++)      matR1R2 += matSvd.matrixU().col(nSvdIdx) * (matSvd.matrixV().col(nSvdIdx).transpose());   for (UINT8 i = 0; i < 3; i++)   {      matOrthR(i, 0) = matR1R2(i, 0);      matOrthR(i, 1) = matR1R2(i, 1);   }   matOrthR.col(2) = matR1R2.col(0).cross(matR1R2.col(1));   return true;}`

But with release mode, compile time becomes 1~2.5 hr(it takes only 3~4 min for debug). If I stop using this code:

Code: Select all
`Eigen::JacobiSVD<EigenMatrixForSvd> matSvd(matR1R2, Eigen::ComputeFullU | Eigen::ComputeFullV);`

Compile time back to normal (around 5 min).

So I try to avoid using JacobiSVD, and calls EigenSolver to solve eigen vector and creating [U] and [V] by myself. Still, it works fine, and results are all the same with JabociSVD debug test case(typename = double). But while I start to put my code into ceres cost function (this cause typename = Jet<>), a some C2678 errors pop out with c:\program files (x86)\microsoft visual studio 14.0\vc\include\complex (Line # 665, 666, 671, 685, 695). If I marks out this:

Code: Select all
`Eigen::EigenSolver<Eigen::Matrix<T, 3, 3>> esW(matW);Eigen::EigenSolver<Eigen::Matrix<T, 2, 2>> esK(matK);`

Error disappeared.

I got totally no idea how to fix this for whole week. Could any one kindly tell me 1. how to make release mode compile faster with calling of Eigen::JacobiSVD<Eigen::Matrix<Jet<.....>, 3, 2>>; or 2. how to fix those C2678 errors?
zhanxw
Registered Member
Posts
17
Karma
0

### Re: Some issue while using Eigen 3.3.4 with ceres-Windows

Fri Dec 08, 2017 10:11 pm
Maybe use "> >" to replace ">>"?
slowersu
Registered Member
Posts
2
Karma
0

### Re: Some issue while using Eigen 3.3.4 with ceres-Windows

Thu Dec 14, 2017 3:13 am
Great Idea, I will try it.

## Who is online

Registered users: Baidu [Spider], Bing [Bot], daret, Exabot [Bot], Google [Bot], j1nz6, JesusM, robgriff444, Sogou [Bot], ytomino