> For example, if an array has shape 2 3 4, then Matlab treats this as 4
> matrices, each 2x3, while J treats it as 2 matrices, each 3x4.

This leads me to the conjecture that Matlab stores arrays in column-major
order, like FORTRAN.  J and APL stores arrays in row-major order.




On Fri, Sep 12, 2014 at 9:28 AM, chris burke <[email protected]> wrote:

> Matlab has a different notion of multidimensional array than J.
>
> For example, if an array has shape 2 3 4, then Matlab treats this as 4
> matrices, each 2x3, while J treats it as 2 matrices, each 3x4.
>
> I don't think it helps to try to enforce Matlab thinking on J.
>
> Also, you should try to set up data and calculations so that you don't have
> to worry about the shape. In your last post, you want a result of shape 2
> by 1 when summing the rows of a 2-row matrix, but this suggests that you
> are making a mistake, since the natural structure is a 2 element vector,
> not a 1 column matrix.
>
>
> On Fri, Sep 12, 2014 at 7:38 AM, George Dallas <[email protected]>
> wrote:
>
> > Thank you all for your responses. I think I found a solution that helps
> me
> > get the shape of the result I expect by specifying at the beginning of
> the
> > J sentence the shape of the result I want. For example, if I want to add
> > the columns of the expression below and I expect a 2 by 1 vector as a
> > result I can specify that requirement at the beginning, like so:
> >
> > 2 7 $1
> > 1 1 1 1 1 1 1
> > 1 1 1 1 1 1 1
> >
> > 2 1$(+/"1(2 7 $1))
> > 7
> > 7
> > ----------------------------------------------------------------------
> > 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