It's simple mathematically, because you've already learned that and
because you are willing to elide discussion of various mechanical
details.

Personally, I had to read your question a couple of times, and then
Henry's response and then your question again to resolve some of the
ambiguities.

The conjunction is incomprehensible to you because you haven't learned that.

That said, there are multiple ways of expressing this in J.

That said, you have specified an operation which -- at least from the
J perspective -- shuffles axes, so you're going to have to have an
operation which satisfies that to satisfy your request.

J's inner product (+/ .*) combines (sums) the last axis of the left
array with the first axis of the right array. This corresponds to the
treatment you have specified for your 'k' axis

So, for example:

   A=:i.2 3 4 5
   B=:i.6 4 7 8 9
   $A
2 3 4 5
   $B
6 4 7 8 9

Here, we would expect four distinct values for k in your implied indexing.

And, we can shuffle these axis so that they combine the way I think
you have specified:

   $(2|:A)
2 3 5 4
   $0 2 3 4|:B
4 6 7 8 9

And, we can multiply them and produce a result which I think
corresponds to what you have asked for:

   $C=: (2|:A)+/ .*(0 2 3 4|:B)
2 3 5 6 7 8 9

Now... is this the same notation that you used? No, it is not.

Is this significantly more verbose than the notation that you used?
Perhaps... but not if we recognize that your explanatory text was a
necessary part of that presentation.

That said, note also that people don't expect the language itself to
solve all problems -- you can define words to perform common
activities.

I hope this helps,

-- 
Raul

On Thu, Feb 6, 2020 at 4:44 PM <[email protected]> wrote:
>
> Henry Rich <[email protected]> writes:
>
> > It depends on what the '*' means in the definition of the product.
>
> >> C_ijlmnop = sum_k A_ijkl * B_mknop
>
> I really mean the usual multiplication (of numbers).
>
>
> > Have a look at
> >
> > a =. i. 2 3 4 5
> > b =. i. 2 4 3 5 6
> > $ (2 |: a) +/ . * ((|:~ 1 -.~ i.@(#@$)) b)
> > 2 3 5 2 3 5 6
>
> Well, I hoped for seeing something simpler. :)
>
> If I understand your example a bit, you sum along the 4-long axis, and
> you make this axis the last in the case of 'a', ie. by (2 |: a), then
> use the so called dot product (+/ . *), and then something I cannot
> easily decipher, but I guess it must, among other things, make the
> 4-long axis (number 1) the first.
>
> Does one really has to shuffle with the axes?
> Does one really need to use the for me almost incomprehensible
> conjunction . (which no one dares to explain simply enough...)?
>
> Why is it so simple to say what I want mathematically, and so awkward
> to do it programmatically?
>
> Thanks!
> Ruda
>
>
> > On 2/6/2020 2:46 PM, [email protected] wrote:
> >> having two multidimensional matrices A and B,
> >> with some indices, say, A_ijkl and B_mknop,
> >> how can I obtain a matrix C, where
> >>
> >> C_ijlmnop = sum_k A_ijkl * B_mknop
> >>
> >> ie., C has all indices of A and B but for the index k,
> >> which was summed over.
> >>
> >> Thanks for your suggestions.
> >>
> >> Best regards
> >> Ruda
> >> ----------------------------------------------------------------------
> >> 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

Reply via email to