Leading axis agreement: Difference between revisions

Jump to navigation Jump to search
Line 49: Line 49:


In this case, <source lang=j inline>x</source> has shape <source lang=j inline>2</source> and <source lang=j inline>y</source> has shape <source lang=j inline>2 3</source>. Since the leading axes agree and the rank difference is 1, each atom (or 0-[[cell]]) of <source lang=j inline>x</source> is matched with each row (or 1-cell) of <source lang=j inline>y</source>, and the two rows in the result are the results of <source lang=j inline>10 + 0 1 2</source> and <source lang=j inline>20 + 3 4 5</source>, respectively.
In this case, <source lang=j inline>x</source> has shape <source lang=j inline>2</source> and <source lang=j inline>y</source> has shape <source lang=j inline>2 3</source>. Since the leading axes agree and the rank difference is 1, each atom (or 0-[[cell]]) of <source lang=j inline>x</source> is matched with each row (or 1-cell) of <source lang=j inline>y</source>, and the two rows in the result are the results of <source lang=j inline>10 + 0 1 2</source> and <source lang=j inline>20 + 3 4 5</source>, respectively.
== Model ==
In dialects that do not feature leading axis agreement, it can nevertheless be utilised by the introduction of an explicit operator:
<source lang=apl>
      _LA←{⍺ ⍺⍺⍤(-⍺⌊⍥(≢⍴)⍵)⊢⍵}
      ⊢x ← 10 20
10 20
      ⊢y ← 2 3 ⍴ ⍳ 6
0 1 2
3 4 5
      x +_LA y
10 11 12
23 24 25
</source>
{{Works in|Dyalog APL}}


== Aligning axes using the Rank operator ==
== Aligning axes using the Rank operator ==
Line 75: Line 91:
65 66
65 66
</source>
</source>
{{Works in|[[J]]}}
{{Works in|[[J]]}}
[[Category:Leading axis theory]][[Category:Function characteristics]][[Category:Conformability]]{{APL features}}
[[Category:Leading axis theory]][[Category:Function characteristics]][[Category:Conformability]]{{APL features}}

Navigation menu