Re: [eigen] On a flexible API for submatrices, slicing, indexing, masking, etc.

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




On Sun, Jan 1, 2017 at 4:58 AM, Yuanchen Zhu <yuanchen.zhu@xxxxxxxxx> wrote: 

- The word "range" is overloaded much more than span. There's boost::range, the WIP range v3, and the "range-based" for loops. These big shots can have different conventions, some times [first, last) (range-based for), some times [begin, end) (boost's irange). For span, the only conflict is gsl::span right now (which should really be named array_view anyway, akin to std::string_view. It also takes in (base_ptr, length), so it's categorically different from our use).

gsl::span was initially called array_view, so I doubt they will change its name back. It is also interesting that gsl::span is defined as a "start"+"length" as in my initial distinction between range(start,stop) and span(start,size). Writing span(start,stop) does not sounds right to me.

​Yeah I was aware of the original name. They changed it cause there's a different array_view akin to eigen's map being developed. 

thanks for the info.
 
I wasn't aware of Eigen::size(). Is it going to be similar to std::size, but works for Eigen types?​

We already agreed that having more free-function aliases would be very convenient, and an Eigen::size would definitely be useful. I actually had to implement a std::size/Eigen::size like function for the demo of this topic.
 
Still I'd say that changing the case to avoid a name collision is against most sane coding conventions, especially when the particular coding convention uses case to differentiate between the type of the name.

To tell you the truth, I don't feel comfortable in introducing a "Size" function... it's just that the respective size/length/count/etc. property should be accessible through a 'size' function for consistency, and thus it feels odd not to call the respective argument 'size/Size'.  I would thus rather try to make the option (A) below works out...
  
So at this stage of the discutions, if we could find a good name for a generic Zzzz<N>, then I would lean for option (A).

​Just to throw around some:​

Static<V>,
CompileTime<V>

this makes me thought about a simple:

Fixed<V>

For the fun, here is a name-free attempt that I share just to see if this could give some more reasonable ideas to others:

Xxxx(first, last, (int[2]){})

The declaration of Xxxx is:

template <int N>
auto Xxxx(int, int, const int (&)[N]);

(it does not work with a negative value)
 
Maybe we should find a block of example code that makes heavy use of various ranged index, and convert it to the alternative indexing API notations, and have people judge which looks better.

definitely! Feel-free to edit the wiki-page to add examples.
 
​Why can "_" only be defined through a macro? The following compiles on https://godbolt.org/ using gcc 6.2:

struct all_tag{};
constexpr all_tag _{};

int f(all_tag) {
  return 0;
};

int main() {
  return f(_);
}​

my bad!

gael


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