For Programmers: Free Programming Magazines  


Home > Archive > APL > April 2005 > adjacency problem









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author adjacency problem
Leonard

2005-04-13, 3:55 pm

suppose I have a matrix M {assign}24 24 {rho}{iota}576

I'm trying to efficiently generate an array R that contains adjacency
information about the entries of M. for example, my adjaceny rule is such
that for M[1;1] which is 1, I would want 1 2 25 26 and for M[1;2] I want 1 2
3 25 25 27 and for M[2;2] I want 1 2 325 26 27 49 50 51 and so on.

The number of adjacent values can be either 4, 6, or 9 depending if the cell
is a corner, edge but not corner, or interior. The output matrix R needs to
be rectangular so in the case of a corner or edge the adjacency values can
be repeated until there are a total of 9, and the value of the M[i;j] needs
to be included too, so that the resulting R is of dimension {rho}R gives
576 10 and for example, R[1;] could be 1 1 2 25 26 1 2 25 26 1 where R[1;1]
is
M[1;1] and R[1; 2 ....10] is the adjacency numbers repeated until filling up
the row.

Any thoughts on a good way to build R?

Thanks



----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Veli-Matti Jantunen

2005-04-13, 3:55 pm

> Any thoughts on a good way to build R?
>


Not necessary _good_, or extremely beautiful, but perhaps this one works the
way you wanted ([]IO = 1):

(<disclose>3
3)<rho><each>3,/[1]3,/M[1,(<iota><first><rho>M),<first><rho>M;1,(<iota>1<dro
p><rho>M),1<drop><rho>M]

- Veli-Matti


stevemansour@yahoo.com

2005-04-14, 3:55 pm

Try this--it works with []IO = 1

(A B)<-(<rho>M)<min>1<max>(<enclose>-1 0 1)
<jot>.+<each><iota><each><rho>M

R<-(,M),,[1 2],[3 4]3 4 1 2<transpose>M[A;B]



Steve Mansour

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com