[Jprogramming] Reshaping 3+d matrices
Rob Hodgkinson
rhodgkin at me.com
Wed Jan 24 07:32:18 UTC 2018
Hi John, did you try dyadic transpose (x |: y) where x is a reposition vector of dimensions …
(1 0 2 |: mat) -: |:"2|:"3|:"2 mat
1
…/Rob
> On 24 Jan 2018, at 6:21 pm, 'Jon Hough' via Programming <programming at jsoftware.com> wrote:
>
> I have a 3d matrix of shape a b c say. But I want to reshape it to have shape b a c, while still keeping data positional integrity.
> So doing (b,a,c) $, myMatrix
> will not work, as it destroys the relative positional relations between items.
> e.g.
>
> mat =: ? 3 10 20 $ 0 NB. shape 3x10x20
>
> I can reshape it using
> |:"2|:"3|:"2 mat
>
> But this seems ugly, and based on past experience there is usually an obvious / simple / elegant / in-built way to
> do it. It seems like there is a nicer way to do it.
>
> Any ideas?
>
> Thanks,
> Jon
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list