Jon, I note Henry’s point about using <;.3 T if you wish to use the 2x2 
tessellation windows as per Henry’s suggestion, that is fine.  (it was my first 
approach on reading your question too).

But I notice you are choosing to “slice” separate subarrays (non overlapping) 
so I gather your question is a neater way to reconstruct IsMax as a simple 10 
10 array ?  If so, you gave this:
        10 10 $ , > |:"2  <"1 > IsMax

Then my suggestion is this (which reproduces your final line only):
        >,"1&.>/ ,&.>/ IsMax

HTH, Regards Rob


> On 29 Mar 2017, at 6:54 pm, 'Jon Hough' via Programming 
> <[email protected]> wrote:
> 
> I should also mention that my verb(s) work for subarrays other than 2x2.
> e.g. if T is a 12x12 array
> T =: 12 12 $ 0 _2 12 100 2 4.5 1 7 _5.5 3.2 120 2 _100 3 5 18 4
> is =:  12 $ 1 0 0
> IsMax =: (is;is)   ($$((>./=])@:,))&.>@:< interval T  NB. max of 3x3 subarrays
> 12 12 $ , > |:"2  <"1 > IsMax
> 
> Also creates the correct array.
> 
> --------------------------------------------
> On Wed, 3/29/17, 'Jon Hough' via Programming <[email protected]> 
> wrote:
> 
> Subject: [Jprogramming] Unboxing after subarray function
> To: "Programming Forum" <[email protected]>
> Date: Wednesday, March 29, 2017, 4:38 PM
> 
> I have a NxN matrix.
> For each 2x2 subarray of this (keep it simple, N is even), I
> want to calculate the maximum value and if the value of that
> cell equals the maximum of the 2x2 subarray write 1, else
> write 0.
> 
> e.g. 
> NB. T arbitrary 10x10 matrix
> T =: 10 10 $ 0 _2 12 100 2 4.5 1 7 _5.5 3.2 120 2 _100 3 5
> 18 4
> 
> interval =: ;.1
> is =:  10 $ 1 0
> 
>  IsMax =:
> (is;is)   ($$((>./=])@:,))&.>@:<
> interval T
> 
> So IsMax shows which elements are the max values of the 4x4
> subarrays.
> 
> Now I want to unbox and keep the indices correct.
> 
> This appears to work
> 
> 10 10 $ , > |:"2  <"1 > IsMax
> 
> But is incredibly messy. I'm hoping there is a nicer/ more
> terse / elegant way to do this.
> 
> Thanks,
> Jon
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to