|Re: [eigen] Initial implementation of tensor support|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
> (Such features should be coded in
> C++11 *only* if C++11 is necessary for their implementation, or if it
> greatly reduces code duplication/complexity.) Off the top of my head
> these features could include:
> * tensor support (as you have implemented), though it may take some
> convincing that C++11 is truly necessary here
The primary reason to use C++11 is because of argument lists for
accessors, if you want them to be fast and optimizable at compile time.
Without C++11 you have two options: 1) use va_list (stdarg.h) to
implement that, but the compiler can't optimize that away *and* it has
the problem that you can't know the type the user has used to specify
the index (try t(0,0,0) vs. t(0ll,0ll,0ll)) and 2) write an own
specialization for each possible rank, so even if we restrict that to 7
(which is what Fortran does), then there'd have to be seven
near-identical implementations of the accessors (and then some more
duplication for const/non-const, packet access, etc.); I don't think
that'd be very maintainable.
I chose C++11 here, because a reasonably generic, maintainable and
feature-rich tensor implementation is not possible without variadic
templates in my eyes. That does not mean, however, that I want to
advocate C++11 requirements for all parts of Eigen. I completely
understand that there are good reasons for keeping compatibility with
older compilers for the other parts. But in this case, it's really a
self-contained feature, so no C++11 is required if you don't use it.
(Also, I doubt that tensor support is that relevant for embedded
systems, which where mentioned in this thread.)
> If no Eigen core developers chime in or they do not want to include the
> tensor code in unsupported/, I encourage you to pull the tensor code out
> from the Eigen fork you initially posted and to make it something which
> is much smaller and instead depends on Eigen. This way it will be much
> more approachable to somebody wishing to use it, and it can continue to
> be used as new versions of Eigen are released in the future.
I might do that should it come to that.