Outer Product: Difference between revisions

Jump to navigation Jump to search
78 bytes added ,  05:38, 4 September 2023
m
→‎Differences between dialects: clarify that double-quote means Rank in J
m (→‎Differences between dialects: clarify that double-quote means Rank in J)
Tags: Mobile edit Mobile web edit
Line 86: Line 86:


=== Differences between dialects ===
=== Differences between dialects ===
[[J]]'s Table differs from APL's Outer Product by enabling Cartesian pairing between [[cell]]s of [[rank]]s other than 0, and between cells of different rank for the left vs. right arguments, without needing to first [[enclose]] the relevant cells. It is defined as <syntaxhighlight lang=j inline>u"(lu, _)</syntaxhighlight>, where <syntaxhighlight lang=j inline>lu</syntaxhighlight> is the left rank of operand <syntaxhighlight lang=j inline>u</syntaxhighlight> (<syntaxhighlight lang=j inline>_</syntaxhighlight> denotes infinity in J). The results of the individual applications of u are collectively [[frame]]d by the catenation of the frames of the left and right arguments relative to their lu- and ru-cells respectively, where lu and ru are the dyadic ranks of the operand u. Unlike APL's Outer Product, J's Table does not use an implicit [[Each]], so the results of the individual applications of its operand are not boxed (unless the given operand itself does so).
[[J]]'s Table differs from APL's Outer Product by enabling Cartesian pairing between [[cell]]s of [[rank]]s other than 0, and between cells of different rank for the left vs. right arguments, without needing to first [[enclose]] the relevant cells. It is defined as <syntaxhighlight lang=j inline>u"(lu, _)</syntaxhighlight>, where <syntaxhighlight lang=j inline>lu</syntaxhighlight> is the left rank of operand <syntaxhighlight lang=j inline>u</syntaxhighlight> (<syntaxhighlight lang=j inline>"</syntaxhighlight> and <syntaxhighlight lang=j inline>_</syntaxhighlight> denote [[rank_(operator)|Rank]] and infinity, respectively, in J). The results of the individual applications of u are collectively [[frame]]d by the catenation of the frames of the left and right arguments relative to their lu- and ru-cells respectively, where lu and ru are the dyadic ranks of the operand u. Unlike APL's Outer Product, J's Table does not use an implicit [[Each]], so the results of the individual applications of its operand are not boxed (unless the given operand itself does so).


<syntaxhighlight lang=j>
<syntaxhighlight lang=j>
Line 135: Line 135:
{{Works in|[[J]]}}
{{Works in|[[J]]}}


In APL this behavior can be accomplished by enclosing the relevant cells of each argument before applying the outer product operation (or by successive applications of [[rank_(operator)|Rank]], e.g. <syntaxhighlight lang=apl inline>f⍤2 99⍤99 1</syntaxhighlight>). Conversely, the behavior of APL's Outer Product can be accomplished in terms of J's Table by adding the Each modifier, as in <syntaxhighlight lang=j inline>u&.>/</syntaxhighlight> or <syntaxhighlight lang=j inline>u&>/</syntaxhighlight>, depending on whether the given operand is a [[scalar function]].
In APL this behavior can be accomplished by enclosing the relevant cells of each argument before applying the outer product operation (or by successive applications of Rank, e.g. <syntaxhighlight lang=apl inline>f⍤2 99⍤99 1</syntaxhighlight>). Conversely, the behavior of APL's Outer Product can be accomplished in terms of J's Table by adding the Each modifier, as in <syntaxhighlight lang=j inline>u&.>/</syntaxhighlight> or <syntaxhighlight lang=j inline>u&>/</syntaxhighlight>, depending on whether the given operand is a [[scalar function]].


The Cartesian pairing behavior of J's Table results from each <syntaxhighlight lang=j inline>"(lu, _)</syntaxhighlight> cell-pairing being processed by <syntaxhighlight lang=j inline>u</syntaxhighlight>, which applies its own ranks to divide up the right argument into cells.
The Cartesian pairing behavior of J's Table results from each <syntaxhighlight lang=j inline>"(lu, _)</syntaxhighlight> cell-pairing being processed by <syntaxhighlight lang=j inline>u</syntaxhighlight>, which applies its own ranks to divide up the right argument into cells.
trusted
83

edits

Navigation menu