New user self-registration is currently disabled. Please email eigen-core-team @ if you need an account.
Bug 1310 - .hnormalized() of .triangularView<> product issues a compilation error
.hnormalized() of .triangularView<> product issues a compilation error
Product: Eigen
Classification: Unclassified
Component: Core - matrix products
3.3 (current stable)
All Windows
: Normal Compilation Problem
Assigned To: Nobody
Depends on:
  Show dependency treegraph
Reported: 2016-09-25 14:16 UTC by Sergiu Deitsch
Modified: 2016-09-30 20:51 UTC (History)
2 users (show)

VC14 log output (5.99 KB, text/plain)
2016-09-25 14:16 UTC, Sergiu Deitsch
no flags Details

Description Sergiu Deitsch 2016-09-25 14:16:54 UTC
Created attachment 738 [details]
VC14 log output

I have the following code which does not compile Eigen 3.3-rc1 (it does with Eigen 3.2.9 though):

    #include <Eigen/Core>
    #include <Eigen/Geometry>
    #include <Eigen/LU>

    int main()
        Eigen::Matrix3d K;

        Eigen::Vector2d u;

        (K.triangularView<Eigen::Upper>() * u.homogeneous()).hnormalized();

        // Eigen::Matrix4d::Identity().lu().solve(Eigen::Vector3d::Ones().homogeneous()).hnormalized();

I've attached the compiler output. The code was compiled using the following command-line:

    cl /W4 /EHsc test.cpp
Comment 1 Gael Guennebaud 2016-09-27 07:31:21 UTC
For me it does not compile with 3.2. I get a static assertion:

Comment 2 Sergiu Deitsch 2016-09-27 09:29:33 UTC
You are right. I missed an .eval() in front of .hnormalized() (i.e. after the product).

(K.triangularView<Eigen::Upper>() * u.homogeneous()).eval().hnormalized();

However, it would be nice if such expressions could be evaluated without an explicit .eval() call.
Comment 3 Gael Guennebaud 2016-09-29 12:13:24 UTC
Alright, so in 3.2, what happened is that in this case u.homogeneous() gets evaluated into a Vector3d before the product takes place:

K.triangularView<Eigen::Upper>() * (u.homogeneous()).eval()

In 3.2, this was done implicitly, so the easy "fix" would be to do the same explicitly in 3.3 before we add a special optimized path.
Comment 4 Gael Guennebaud 2016-09-30 20:51:10 UTC
Since this compiled in 3.2, here is a quick workaround for 3.3:

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