I'll give it a try. It's missing scalar addition, though.

CartesianIndex((4,5)) + 1   # error

Thanks!

On Friday, January 22, 2016 at 8:26:53 PM UTC-5, Tim Holy wrote:
>
> Check out CartesianIndex. It's a little annoying to type long names, but 
> it 
> supports all those operations, and julia already has all the indexing 
> operations defined for it. 
>
> --Tim 
>
> On Friday, January 22, 2016 05:20:59 PM Cedric St-Jean wrote: 
> > I manipulate a lot of images, and I have to deal with image coordinates 
> > (aka indexes) all the time. I've been storing them as vectors so far, 
> but 
> > the inefficiency of creating a full-blown array object to store 2 
> integers 
> > is gross (and it might add up, though it's hard to profile). OTOH, 
> tuples 
> > are very awkward, in particular because 
> > 
> > ind1 = (4, 5) 
> > ind2 = (20, 67) 
> > ind2 .- ind1 # not defined 
> > ind1 .+ 1 # not defined either 
> > 
> > Is there any reason why I should _not_ define those operations? In 
> general, 
> > I don't want to implement a method I didn't create over a type I didn't 
> > create, but this seems harmless enough...? Is there any consideration 
> that 
> > I'm missing? 
> > 
> > Cédric 
>
>

Reply via email to