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 1366 - TriangularView<Derived, UnitLower>::coeff() does not return 1.0 for diagonal entries
Summary: TriangularView<Derived, UnitLower>::coeff() does not return 1.0 for diagonal ...
Status: NEW
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 3.3 (current stable)
Hardware: All All
: Normal Documentation
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-20 02:51 UTC by Jeff Trull
Modified: 2016-12-20 17:21 UTC (History)
3 users (show)



Attachments
code demonstrating that coeff() is not affected by the mode (566 bytes, text/x-c++src)
2016-12-20 02:51 UTC, Jeff Trull
no flags Details

Description Jeff Trull 2016-12-20 02:51:20 UTC
Created attachment 763 [details]
code demonstrating that coeff() is not affected by the mode

If you assign a TriangularView to a dense matrix, the diagonal entries are 1.0 as expected.  However, if you use the coeff() method to access entries in the TriangularView, you get the underlying values, not the 0 (above the diagonal) or 1 (on the diagonal) values you would expect.

The same appears to be true for UnitUpper.
Comment 1 Christoph Hertzberg 2016-12-20 15:19:24 UTC
This is expected behavior (having a branch in the coeff() would be too costly), and you should generally avoid low-level access to TriangularView (or SelfAdjointView).
Admittedly, this should be documented!

Actually, TriangularView::operator()(Index, Index) and SelfAdjointView::coeff(Index, Index) do check their input coordinates. 
Usually coeff() does no assertions, but should only be used when correct usage is guaranteed by the calling method.
Comment 2 Jeff Trull 2016-12-20 17:21:55 UTC
I am OK with calling this a documentation bug.

As an outsider it would help to understand in what cases the "View" classes can be substituted for matrices.  I naively assumed they would behave in all respects like the higher-level construct, while in fact that is only true for some uses, e.g., multiplication, assignment, etc.

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