[Tutor] rotation within arrays

Bob Gailer bgailer at alum.rpi.edu
Wed Jul 4 20:40:14 CEST 2007


Andy Cheesman wrote:
> Dear People,
>
> I wondering if any of you lovely people can make a suggestion on a
> problem which I have with a n dimensional array.
> For example, I've a 3x3 array 
What mechanism (module?) are you using to store the array? Or are you 
asking us for a recommendation?
> and I have been mapping an element from 1D
> to the one directly above it. 3->12
>
> 0 1 2
> 3 4 5
> 6 7 8
>
>  9 10 11
> 12 13 14
> 15 16 17
>
> The problem which I have is that I now need to rotated alternative layer
> of the arrays 
arrays? I only see the 2nd as "rotated". And do you mean "transpose"? 
That is what the result looks like. What prevents you from keeping the 
original for the mapping and also having a transposed copy?
> but I still need to have the original mapping i.e 3 -> 12.
>
> 0 1 2
> 3 4 5
> 6 7 8
>
> 11 14 17
> 10 13 16
>  9 12 15
>   
The mapping can be defined in another array (I'm using origin 1 indexing 
here):
1,1 1,2 1,3
2,1 2,2 2,3
3,1 3,2 3,3
Then you'd transpose that when you transpose the other array.



-- 
Bob Gailer
510-978-4454 Oakland, CA
919-636-4239 Chapel Hill, NC




More information about the Tutor mailing list