Extended Inner Product
Posted: Wed Jan 22, 2020 4:06 pm
I need some help with what I call an extension to inner product. It goes like
this.
xip is an operator taking a number n of axes as its left argument. It produces
a dyadic function which behaves like an inner product, but rather than acting on
vectors, it acts on arrays of greater rank n. For example:
a←?3 2 4⍴9
b←?2 4 5 6⍴9
⍴a(2 xip)b
3 5 6
One way I'm familiar with is to do a full outer product followed by appropriate
tensor contractions. That's a bit wasteful. An approach I'd prefer is to ravel on
the last n axes of a and the first n axes of b, followed by a regular matrix
multiplication. Something like:
xip←{(,⍤⍺⍺⊢⍺)+.×,[⍺⍺↑⍳⍴⍴⍵]⍵}
Is there a way I can avoid the ravel with axis specification and instead use the
rank operator?
Mike
this.
xip is an operator taking a number n of axes as its left argument. It produces
a dyadic function which behaves like an inner product, but rather than acting on
vectors, it acts on arrays of greater rank n. For example:
a←?3 2 4⍴9
b←?2 4 5 6⍴9
⍴a(2 xip)b
3 5 6
One way I'm familiar with is to do a full outer product followed by appropriate
tensor contractions. That's a bit wasteful. An approach I'd prefer is to ravel on
the last n axes of a and the first n axes of b, followed by a regular matrix
multiplication. Something like:
xip←{(,⍤⍺⍺⊢⍺)+.×,[⍺⍺↑⍳⍴⍴⍵]⍵}
Is there a way I can avoid the ravel with axis specification and instead use the
rank operator?
Mike