Outer Product: Difference between revisions

Jump to navigation Jump to search
811 bytes removed ,  09:33, 26 August 2023
m
→‎Differences between dialects: Take out hypothetical
m (→‎Differences between dialects: Take out hypothetical)
Line 135: Line 135:
{{Works in|[[J]]}}
{{Works in|[[J]]}}


In APL one can accomplish this behavior 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_(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]].


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.
Line 147: Line 147:
</syntaxhighlight>
</syntaxhighlight>
{{Works in|[[J]]}}
{{Works in|[[J]]}}
Given the <syntaxhighlight lang=j inline>u"(lu, _)</syntaxhighlight> definition of Table, even in a hypothetical J dialect in which assignment of negative rank is visible as such to modifiers, a left negative rank L used with Table would be applied twice (once by the ranks added by Table, and once by the operand itself). This would result in the L-cells ''of each of the left argument's L-cells'' being paired ''1-to-1'' with the specified cells of the right argument—not a Cartesian pairing. If a J dialect both allowed externally visible negative rank and defined Table to instead be <syntaxhighlight lang=j inline>u"lu _"_ ru</syntaxhighlight>, one could express e.g. the Cartesian pairing of the [[major cells]] of the left and right arguments as <syntaxhighlight lang=j inline>u"_1/</syntaxhighlight>.


== External links ==
== External links ==
trusted
83

edits

Navigation menu