|
[Date Index]
[Thread Index]
[Author Index]
Re: Getting coordinates of array member
- To: mathgroup at smc.vnet.net
- Subject: [mg26263] Re: Getting coordinates of array member
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Sun, 10 Dec 2000 00:19:37 -0500 (EST)
- Organization: Universitaet Leipzig
- References: <90krir$r50@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
that looks not mich like a Mathematica question ?
You may look at "The Art of Computer Programming" Volume I
that contains an extensive chapter on linear addressing.
You have a (n,m) array and
(i,j)=(1,3)
the linear index is k=j*n+i
The reversion is done by
j=Mod[k,n]
i= k-j*n
Regards
Jens
PS: Is it right that you transpose the index because 7 is on
position (3,1) in your matrix?
Stephane Hebert wrote:
>
> Hi folks,
>
> Ok, let's say I have this
>
> 1 2 3
> -----------
> 1| 1 2 3
> 2| 4 5 6
> 3| 7 8 9
>
> A 3x3 matrice or array. Each number in the array represents its' position
> from top left to bottom right.
>
> What I need to do is:
>
> Find what position 1,3 is. Just by looking at the array, we find that 7 is
> the answer.
>
> Find what are the coordinates of 7. Again just by looking at the array we
> see that the answer is 1,3
>
> I need to come up with a simplu function that will return these.
>
> pos = GetPos(x,y)
>
> coord = GetCoord(pos)
>
> I've done this before, way long ago and can't find it.
>
> Thanks.
>
> --
> Stephane Hebert
> =========================
> stephhebert at yourpants~videotron.ca
> Remove yourpants~ to reply
> =========================
Prev by Date:
Re: Getting coordinates of array member
Next by Date:
Re: Mathlink probs under Unix
Previous by thread:
Re: Getting coordinates of array member
Next by thread:
Re: Getting coordinates of array member
|