On Tuesday, December 18, 2012 05:44:00 PM Jeff Bezanson wrote:
> Tim, I suspect this might be relevant/helpful to your grid package
> among many other things?'
I was thinking the same thing---Grid's "Counter" iterator is exactly of this
type. I once tried a similar implementation with tuples, and got pretty poor
performance with mine, especially compared to the Array-based implementation
in Grid now. Bbut I didn't try the one in Iterators, simply because I didn't
remember its existence.
In its current incarnation, Grid's Counter performance seems quite good, with
a caveat (you surely remember this, but for others...): for grids where the
first dimension is not small, it turns out you can get particularly good
performance simply by expunging the first dimension from the general
multidimensional iterator and handling it separately in a for loop. (An
example of this trick can be found in prolong() for non-BLAS types). Under
this condition, you get pretty close to linear-indexing performance, so there
isn't much room for performance improvement.
This trick works great for grids with sizable first dimensions, because you
don't end up incrementing the Counter that often. For small grids, I've not
had success in getting great performance from anything other than
make_arrayind_loop_nest type of code, which is a bit scary for routine use.
So something that works in the general case would be most welcome!
--Tim