Makes sense. Was just thinking naively of the start and next functions
using tuples, as they would know the proper dimensions etc but I bet this
is what Cartesian index does and now I should look at it :-)

On Saturday, March 28, 2015, Tim Holy <[email protected]> wrote:

> Right now getindex(::AbstractArray, ::Tuple) isn't defined (though there's
> a
> proposal to define it as one of several options to solve a tricky problem,
> see
> https://github.com/JuliaLang/julia/pull/10525#issuecomment-84597488).
>
> More importantly, tuples don't have +, -, min, and max defined for them,
> and
> it's not obvious they should. But all that is supported by CartesianIndex.
>
> --Tim
>
> On Saturday, March 28, 2015 07:10:50 AM Sebastian Good wrote:
> > Random thought: If tuples can avoid boxing why not return tuples from the
> > iterator protocol?
> >
> > On Friday, March 27, 2015, Matt Bauman <[email protected] <javascript:;>>
> wrote:
> > > On Friday, March 27, 2015 at 8:21:10 AM UTC-4, Sebastian Good wrote:
> > >> Forgive my ignorance, but what is Cartesian indexing?
> > >
> > > There are two ways to iterate over all elements of an array: Linear
> > > indexing and Cartesian indexing. For example, given a 2x3 matrix,
> linear
> > > indexing would use just one index from 1:6, whereas Cartesian indexing
> > > specifies indices for both dimensions: (1,1), (1,2), (2,1), ...
> > >
> > >
> > > If an array isn't stored continuously in memory for linear indexing,
> > > converting to the Cartesian indices is very expensive (because it
> requires
> > > integer division, which is a surprising slow). The new `eachindex`
> method
> > > in 0.4 returns an iterator to go over all the Cartesian indices very
> > > quickly.
>
>

-- 
*Sebastian Good*

Reply via email to