New user self-registration is disabled due to spam. Please email eigen-core-team @ lists.tuxfamily.org if you need an account.
Before reporting a bug, please make sure that your Eigen version is up-to-date!
Bug 997 - .hnormalized() produces compilation errors
Summary: .hnormalized() produces compilation errors
Status: RESOLVED FIXED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Geometry (show other bugs)
Version: 3.2
Hardware: All All
: Normal Compilation Problem
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 3.3
  Show dependency treegraph
 
Reported: 2015-04-15 14:05 UTC by Sergiu Deitsch
Modified: 2015-06-08 13:45 UTC (History)
4 users (show)



Attachments

Description Sergiu Deitsch 2015-04-15 14:05:04 UTC
I have the following function, which is used in combination with ceres::Jet<> as scalar:

template
<
    class Derived1,
    class Derived2
>
inline Eigen::Matrix<typename Eigen::MatrixBase<Derived1>::Scalar, 2, 1> reproject(
        const Eigen::MatrixBase<Derived1>& pt,
        const Eigen::MatrixBase<Derived2>& W
    )
{
    return (W * pt.homogeneous()).hnormalized();
}

If I don't call .eval() before .hnormalized() this results in the following compilation error:

/usr/include/eigen3/Eigen/src/Core/DenseCoeffsBase.h:137:14: error: no viable conversion from 'const
      Eigen::ReturnByValue<Eigen::internal::homogeneous_left_product_impl<Eigen::Homogeneous<Eigen::Matrix<double, 2, 1, 0, 2, 1>, 0>, Eigen::Matrix<double, 3, 3, 0,
      3, 3> > >::YOU_ARE_TRYING_TO_ACCESS_A_SINGLE_COEFFICIENT_IN_A_SPECIAL_EXPRESSION_WHERE_THAT_IS_NOT_ALLOWED_BECAUSE_THAT_WOULD_BE_INEFFICIENT' to 'const double'
      return derived().coeff(index);
             ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Geometry/Homogeneous.h:163:40: note: in instantiation of member function
      'Eigen::DenseCoeffsBase<Eigen::ReturnByValue<Eigen::internal::homogeneous_left_product_impl<Eigen::Homogeneous<Eigen::Matrix<double, 2, 1, 0, 2, 1>, 0>,
      Eigen::Matrix<double, 3, 3, 0, 3, 3> > >, 0>::coeff' requested here
    ColsAtCompileTime==1?1:size()-1) / coeff(size()-1);


I'm using Clang 3.6 and Eigen 3.2.4.
Comment 1 Sergiu Deitsch 2015-04-15 14:53:59 UTC
By the way, this happens when using double as scalar as well.
Comment 2 Christoph Hertzberg 2015-04-15 19:03:28 UTC
The cleanest/most efficient workaround would be to store W as a Transform (and omit the homogeneous() and hnormalized() calls).
But I agree that your code should compile.
Comment 3 Sergiu Deitsch 2015-04-16 14:37:47 UTC
I don't see how storing W in a Transform can be more efficient. Wouldn't that still require to call .homogeneous() and .hnormalized(), would it?
Comment 4 Christoph Hertzberg 2015-04-16 19:45:11 UTC
(In reply to Sergiu Dotenco from comment #3)
> I don't see how storing W in a Transform can be more efficient. Wouldn't
> that still require to call .homogeneous() and .hnormalized(), would it?

I admit that I did not check the code. I wrongfully assumed, Transform * vector automatically normalizes when assigning to a vector of size dim (and not dim+1).
Comment 5 Gael Guennebaud 2015-04-16 20:24:14 UTC
Indeed, hnormalized should perform the call to eval for you.

In Eigen 3.3, evaluators should refactor this expression to:

(W.leftCols<2>() * pt + W.col(2)).hnormalized()

and, support for:

 W * lazyProduct( pt.homogeneous() )

has also to be added.
Comment 6 Gael Guennebaud 2015-06-08 13:45:03 UTC
Actually, this is already working fine in the devel branch.

The following changeset add support for lazyProduct:

https://bitbucket.org/eigen/eigen/commits/57baa6174354/
Changeset:   57baa6174354
User:        ggael
Date:        2015-06-08 13:43:41+00:00
Summary:     Bug 997: add missing evaluators for m.lazyProduct(v.homogeneous())

Backporting to 3.2 is impossible, so I vote for wontfix for 3.2 and fixed for the devel branch.

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