[Jprogramming] Boxing columns
Marshall Lochbaum
mwlochbaum at gmail.com
Thu Nov 20 20:09:25 UTC 2014
Aha! Raul's solution can be rewritten as
,"_2/^:3 >zz
(negative rank is quite a useful concept). Since ,. is (exactly) ,"_1
the two-dimensional solution is
,"_1/^:2 >z
Extending the pattern, we can reduce a blocked array using
merge =: 3 : 0
r =. #$y
,"(1-r)/^:r >y
)
This works on block arrays with large rank.
(-: [: merge (,:~2 3 4 5) <;._3 ]) i.4 9 16 25
1
Marshall
On Thu, Nov 20, 2014 at 12:28:07PM -0500, Raul Miller wrote:
> Perhaps
> ,"1/,"2/,"3/>zz
>
> Thanks,
>
> --
> Raul
>
> On Thu, Nov 20, 2014 at 10:42 AM, Ben Gorte - CITG
> <B.G.H.Gorte at tudelft.nl> wrote:
> > If I'm allowed to jump in here, I'm using ;. a lot to subdivide images into 2x2 blocks (think wavelet), and I guess it's okay to do it like:
> >
> > ]z =: (2 2,:2 2) < ;. _3 i.4 6
> > +-----+-----+-----+
> > |0 1 |2 3 | 4 5|
> > |6 7 |8 9 |10 11|
> > +-----+-----+-----+
> > |12 13|14 15|16 17|
> > |18 19|20 21|22 23|
> > +-----+-----+-----+
> >
> > I was quite happy to discover that:
> >
> > ,./,./> z
> > 0 1 2 3 4 5
> > 6 7 8 9 10 11
> > 12 13 14 15 16 17
> > 18 19 20 21 22 23
> >
> > does the inverse (it's even pleasant to type).
> >
> > Now I'm smoothly moving to 3d with
> >
> > ]zz =: (2 2 2,:2 2 2) < ;. _3 i.4 6 8
> >
> > but as the inverse is concerned I'm sort of stuck at:
> >
> > CutBack =: [: ([: ,/ ([: ,./ ,./)"4) 1 2 4 5&|:
> > (i.4 6 8) -: CutBack >zz
> > 1
> >
> > which I'm sure can be improved. Any suggestions?
> >
> > Thanks,
> > Ben
> > ________________________
> > From: programming-bounces at forums.jsoftware.com [programming-bounces at forums.jsoftware.com] on behalf of Henry Rich [HenryHRich at nc.rr.com]
> > Sent: Wednesday, November 19, 2014 23:40
> > To: programming at jsoftware.com
> > Subject: Re: [Jprogramming] Boxing columns
> >
> > Is the inverse implemented using ^:_1 ? I couldn't find it.
> >
> > I come up with ,.&:>/ as an inverse for ('';1)&(<;.1) .
> >
> > Henry Rich
> >
> > On 11/19/2014 5:28 PM, Roger Hui wrote:
> >> The inverse of this "block matrices cut" is also interesting.
> >>
> >>
> >> On Wed, Nov 19, 2014 at 2:27 PM, Roger Hui <rogerhui.canada at gmail.com>
> >> wrote:
> >>
> >>> ('';1) <;.1 i.3 3
> >>> ┌─┬─┬─┐
> >>> │0│1│2│
> >>> │3│4│5│
> >>> │6│7│8│
> >>> └─┴─┴─┘
> >>>
> >>>
> >>> On Wed, Nov 19, 2014 at 2:05 PM, Henry Rich <HenryHRich at nc.rr.com> wrote:
> >>>
> >>>> boxcols i. 3 3
> >>>> +-+-+-+
> >>>> |0|1|2|
> >>>> |3|4|5|
> >>>> |6|7|8|
> >>>> +-+-+-+
> >>>>
> >>>> Can you write boxcols?
> >>>>
> >>>> Can you write it tacitly without using a hook, fork, compose, or appose?
> >>>>
> >>>> Henry Rich
> >>>> ----------------------------------------------------------------------
> >>>> 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
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list