New user self-registration is currently disabled. Please email eigen-core-team @ lists.tuxfamily.org if you need an account.
Bug 807 - Missing scalar type cast in umeyama()
Missing scalar type cast in umeyama()
Status: RESOLVED FIXED
Product: Eigen
Classification: Unclassified
Component: Geometry
3.2
All All
: Normal Unknown
Assigned To: Nobody
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-05-05 11:12 UTC by newstzpz
Modified: 2014-05-05 14:36 UTC (History)
4 users (show)



Attachments
umeyama() with Scalar type cast added. (6.58 KB, application/octet-stream)
2014-05-05 11:12 UTC, newstzpz
no flags Details

Description newstzpz 2014-05-05 11:12:16 UTC
Created attachment 460 [details]
umeyama() with Scalar type cast added.

In the function umeyama() in file Umeyama.h line 116, 139, 145, 148 and 159, the constant scalars in the code should be casted to Scalar type in order to use this function with some scalar types like ceres::Jet.

Line 116: 
  const RealScalar one_over_n = 1 / static_cast<RealScalar>(n);
->
  const RealScalar one_over_n = RealScalar(1) / static_cast<RealScalar>(n);

Line 139:
  if (sigma.determinant()<0) S(m-1) = -1;
->
  if (sigma.determinant()<Scalar(0)) S(m-1) = Scalar(-1);

Line 145:
    if ( svd.matrixU().determinant() * svd.matrixV().determinant() > 0 ) {
->
    if ( svd.matrixU().determinant() * svd.matrixV().determinant() > Scalar(0) ) {

Line 148:
      const Scalar s = S(m-1); S(m-1) = -1;
->
      const Scalar s = S(m-1); S(m-1) = Scalar(-1);

Line 159:
    const Scalar c = 1/src_var * svd.singularValues().dot(S);
->
    const Scalar c = Scalar(1)/src_var * svd.singularValues().dot(S);

The attachment is the file with Scalar type cast added.
Comment 1 Christoph Hertzberg 2014-05-05 14:36:32 UTC
Fixed in devel and 3.2

https://bitbucket.org/eigen/eigen/commits/bfe0a69
https://bitbucket.org/eigen/eigen/commits/e3e096c

Thanks for the report

Note You need to log in before you can comment on or make changes to this bug.