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

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

*To*: eigen <eigen@xxxxxxxxxxxxxxxxxxx>*Subject*: Re: [eigen] On the implementation of STL iterator for Eigen::Matrix*From*: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>*Date*: Wed, 3 Oct 2018 13:56:14 +0200*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=2Wr0Q2REmE0PUGhf2QBuCygBIZlumP4zlmgizyvcTJ0=; b=BORRGeAg3Qhrgw26yEtOkruKOhaaBV/S9X45tqvx0zHwOx2pvX625PhRGZLqIbH8qE UHphBeyFPTfEc/NlwJqt0yiObD/SMRRv21+8NOggKpnRVW4Rr5svvFMm3CGR/43abgfK 00YSyPCZZVWmO4sBB5VGUAeJi1P0Z/2J9vU8ZwTheJ4AB4rkNRLtyNmjxhp4YxinKVWE P6NwdaAWLarzUfkx6BFIgbYZHbGkIYwPCei1RVkvVdzJZQTy9FWLD+gVEJoQTcyciqDF Rxk4IHZALbGViFvtWBxMad54tFpzaPPhkTTIJGM5Hs8Mgz1xpmAYKQZkAWBW7dG/ozFv 6Zww==

On Tue, Oct 2, 2018 at 2:53 PM Gael Guennebaud <gael.guennebaud@xxxxxxxxx> wrote:

On my side, I'm rather reading it as "iterate over all elements of A in row-major order", which is unfortunate as if I'm not alone with such an interpretation, then we need to come up with new names. Since rows()/cols() are already taken, we could think of:for(auto x : A.allRows()) { ... }for(auto x : A.rowSet()) { ... }?????

After a bit more thoughts, abusing rowwise()/colwise() is perhaps not that bad if we redefine the return type of A.rowwise() as "a view of the 2D matrix A as a linear collection of row-vectors with vector-wise broadcasting facilities". With such a definition, partial reductions and broadcasting sill make sense:

A.rowwise().sum()

A.rowwise() - some_row_vector

and this open the doors for new usages, e.g.:

auto row_list = A.rowwise();

for (auto row : row_list) { .... }

auto it = find_if( row_list.begin(), row_list.end(), [](auto row) { return row.squaredNorm()==0; } );

but also, provided we add operator[] and size() members:

for (int i=0; i<row_list.size(); ++i) { auto row = row_list[i]; ... }

In an ideal world I would rename the current rows()/cols() methods to nrows()/ncols(), and rename rowwise()/colwise() to rows()/cols(), but that cannot happen ;)

gael

**Follow-Ups**:**Re: [eigen] On the implementation of STL iterator for Eigen::Matrix***From:*Wood, Tobias

**References**:**[eigen] On the implementation of STL iterator for Eigen::Matrix***From:*Gael Guennebaud

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] On the implementation of STL iterator for Eigen::Matrix** - Next by Date:
**Re: [eigen] On the implementation of STL iterator for Eigen::Matrix** - Previous by thread:
**Re: [eigen] On the implementation of STL iterator for Eigen::Matrix** - Next by thread:
**Re: [eigen] On the implementation of STL iterator for Eigen::Matrix**

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