Here's a starter... m1=:1+i.3 3 1 2 3 4 5 6 7 8 9 m1=:1+i.3 3 Now I have to tackle the real problem
Linda -----Original Message----- From: programming-boun...@forums.jsoftware.com [mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Alex Giannakopoulos Sent: Tuesday, November 13, 2012 6:44 AM To: J Programming forum Subject: [Jprogramming] Matrix Transformations based on local submatrices OK, I'm trying to do some work with matrices that involves transformations based on local properties of a matrix (neighbouring elements). This is the sort of thing you may find in image-processing "edge-detection", etc, or in some cellular automata of the type of Conway's "Life". In other words, I want to be able to supply a matrix, and have it so processed that the result is a new matrix where each new element was determined by a function which processed the old elements neighbours. Any direction, relevant help pages, etc, much appreciated. If anyone would go as far as offering some sample code that would be great, too! As a trivial example, suppose I want to calculate the sum of the neighbours of each element Say we have a matrix m0 =. 3 3 $ >:i.9 What I want is the verb "neighbours" whereby neighbours m0 11 19 13 23 40 27 17 31 19 Obviously, I am maily interested in how to extract the "neighbours" submatrix, without resorting to explicit looping, if that is possible. To make it a bit more interesting, how would I extract the neighbours if the matrix was a torus or infinite tiling, such that: neighb-torus m0 44 43 42 41 40 39 38 37 36 Thanks for any suggestions! Alex ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm