This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 1310 - .hnormalized() of .triangularView<> product issues a compilation error
Summary: .hnormalized() of .triangularView<> product issues a compilation error
Status: RESOLVED FIXED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - matrix products (show other bugs)
Version: 3.3 (current stable)
Hardware: All Windows
: Normal Compilation Problem
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-25 14:16 UTC by Sergiu Deitsch
Modified: 2019-12-04 16:20 UTC (History)
2 users (show)



Attachments
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;
        K.setIdentity();

        Eigen::Vector2d u;
        u.setZero();

        (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:

"THIS_METHOD_IS_ONLY_FOR_1x1_EXPRESSIONS"
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:

https://bitbucket.org/eigen/eigen/commits/256ec6fa646e/
Comment 5 Nobody 2019-12-04 16:20:07 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/1310.

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