Re: [eigen] On the implementation of STL iterator for Eigen::Matrix

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hi, thanks for the interest!

On 2018-10-02 15:14, Brook Milligan wrote:
On Oct 2, 2018, at 6:38 PM, Gael Guennebaud <gael.guennebaud@xxxxxxxxx> wrote:

we're eventually implementing STL iterators to iterator over the coefficients of a vector/matrix as well as over the columns or rows of a matrix, and your inputs might be welcome to help converging to a stable API, see below.

You can watch the WIP in PR 519 [1], and find some background in bug 231 [2]. Basically, to avoid ambiguities, we decided that iterators over coefficients would be defined for 1D expression only, meaning that to iterate over the elements of a 2D Matrix you'll have to explicitly reshape it as a 1D vector first.

Have you considered a solution such as used by Boost GIL (Generic Image Library)?  That has the concept of "pixel locators" which allow both 1-D and 2-D (i.e., up/down, right/left) movement through the pixels of an image.

In fact, I would be surprised if you cannot adapt a matrix to the GIL "image" concept and get a whole lot for free.

In any case, I think it would be worth investigating before you settle on the arbitrary restriction of a 1-D-only API.

The main idea here is to have something which is compatible with the std algorithms. And ranged-for-loops. Glancing over the GIL documentation on PixelLocators they seem to intentionally distinguish them from Iterators (which they implement, as well).

I would not rule out that Eigen could also provide something like 2D locators (not sure if there is a direct use case for that, though). But that would be independent of the current iterator implementation (of course, some code could be shared).


Christoph



--
 Dr.-Ing. Christoph Hertzberg

 Besuchsadresse der Nebengeschäftsstelle:
 DFKI GmbH
 Robotics Innovation Center
 Robert-Hooke-Straße 5
 28359 Bremen, Germany

 Postadresse der Hauptgeschäftsstelle Standort Bremen:
 DFKI GmbH
 Robotics Innovation Center
 Robert-Hooke-Straße 1
 28359 Bremen, Germany

 Tel.:     +49 421 178 45-4021
 Zentrale: +49 421 178 45-0
 E-Mail:   christoph.hertzberg@xxxxxxx

 Weitere Informationen: http://www.dfki.de/robotik
 -----------------------------------------------------------------------
 Deutsches Forschungszentrum fuer Kuenstliche Intelligenz GmbH
 Firmensitz: Trippstadter Straße 122, D-67663 Kaiserslautern
 Geschaeftsfuehrung: Prof. Dr. Dr. h.c. mult. Wolfgang Wahlster
 (Vorsitzender) Dr. Walter Olthoff
 Vorsitzender des Aufsichtsrats: Prof. Dr. h.c. Hans A. Aukes
 Amtsgericht Kaiserslautern, HRB 2313
 Sitz der Gesellschaft: Kaiserslautern (HRB 2313)
 USt-Id.Nr.:    DE 148646973
 Steuernummer:  19/672/50006
 -----------------------------------------------------------------------



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/