Prefix and suffix vectors: Difference between revisions

Jump to navigation Jump to search
m
Text replacement - "Direct definition (Iverson)" to "Direct definition (notation)"
mNo edit summary
m (Text replacement - "Direct definition (Iverson)" to "Direct definition (notation)")
 
Line 6: Line 6:
The prefix vector <math>\alpha^j(n)</math> is defined to be the length-<math>n</math> [[vector]] where the first <math>j</math> elements (or <math>n</math>, if smaller) are 1 and the rest are 0. Likewise, the suffix vector has that many 1s at the end. In 1-indexed APL, <code>N⍺J</code> was defined to be <syntaxhighlight lang=apl inline>J≥⍳N</syntaxhighlight> and <code>N⍵J</code> to be <syntaxhighlight lang=apl inline>(1+N-J)≤⍳N</syntaxhighlight>. Because Iverson notation allows the length of a vector to be inferred from context, the first <math>j</math> elements of vector <math>v</math> can be taken with <math>\alpha^j/v</math>, and similarly <math>\alpha^j/M</math> and <math>\alpha^j/\!\!/M</math> take the first <math>j</math> columns or rows of a matrix. In APL, what is now <syntaxhighlight lang=apl inline>J↑V</syntaxhighlight> (for <syntaxhighlight lang=apl inline>J≥0</syntaxhighlight> and <syntaxhighlight lang=apl inline>J≤N</syntaxhighlight>) was written <syntaxhighlight lang=apl inline>((⍴V)⍺J)/V</syntaxhighlight>, and <syntaxhighlight lang=apl inline>(-J)↑V</syntaxhighlight> was <syntaxhighlight lang=apl inline>((⍴V)⍵J)/V</syntaxhighlight> (although most likely the shape <syntaxhighlight lang=apl inline>⍴V</syntaxhighlight> would have been saved elsewhere in the program rather than being written out). An instance of [[Drop]] such as <syntaxhighlight lang=apl inline>J↓V</syntaxhighlight> was written <syntaxhighlight lang=apl inline>(~(⍴V)⍺J)/V</syntaxhighlight>.
The prefix vector <math>\alpha^j(n)</math> is defined to be the length-<math>n</math> [[vector]] where the first <math>j</math> elements (or <math>n</math>, if smaller) are 1 and the rest are 0. Likewise, the suffix vector has that many 1s at the end. In 1-indexed APL, <code>N⍺J</code> was defined to be <syntaxhighlight lang=apl inline>J≥⍳N</syntaxhighlight> and <code>N⍵J</code> to be <syntaxhighlight lang=apl inline>(1+N-J)≤⍳N</syntaxhighlight>. Because Iverson notation allows the length of a vector to be inferred from context, the first <math>j</math> elements of vector <math>v</math> can be taken with <math>\alpha^j/v</math>, and similarly <math>\alpha^j/M</math> and <math>\alpha^j/\!\!/M</math> take the first <math>j</math> columns or rows of a matrix. In APL, what is now <syntaxhighlight lang=apl inline>J↑V</syntaxhighlight> (for <syntaxhighlight lang=apl inline>J≥0</syntaxhighlight> and <syntaxhighlight lang=apl inline>J≤N</syntaxhighlight>) was written <syntaxhighlight lang=apl inline>((⍴V)⍺J)/V</syntaxhighlight>, and <syntaxhighlight lang=apl inline>(-J)↑V</syntaxhighlight> was <syntaxhighlight lang=apl inline>((⍴V)⍵J)/V</syntaxhighlight> (although most likely the shape <syntaxhighlight lang=apl inline>⍴V</syntaxhighlight> would have been saved elsewhere in the program rather than being written out). An instance of [[Drop]] such as <syntaxhighlight lang=apl inline>J↓V</syntaxhighlight> was written <syntaxhighlight lang=apl inline>(~(⍴V)⍺J)/V</syntaxhighlight>.


The prefix and suffix vectors were considered two out of a class of "special vectors", with the others being the [[interval vector]] <math>\iota(n)</math>, now <syntaxhighlight lang=apl inline>⍳</syntaxhighlight>, and the "full vector" <math>\epsilon(n)</math> of all 1s and "unit vector" <math>\epsilon^j(n)</math>, where the value at index <math>j</math> is set to 1. However, <math>\epsilon</math> was also used for [[Membership]] (the "characteristic vector"), which is closely related in that <math>\epsilon^j(n)</math> is <syntaxhighlight lang=apl inline>(⍳N)∊J</syntaxhighlight>; only this meaning was defined in APL. The [[glyph]]s <code>⍺</code> and <code>⍵</code> came to be used as argument names in [[Direct definition (Iverson)|direct definition]] and later [[dfn]]s.
The prefix and suffix vectors were considered two out of a class of "special vectors", with the others being the [[interval vector]] <math>\iota(n)</math>, now <syntaxhighlight lang=apl inline>⍳</syntaxhighlight>, and the "full vector" <math>\epsilon(n)</math> of all 1s and "unit vector" <math>\epsilon^j(n)</math>, where the value at index <math>j</math> is set to 1. However, <math>\epsilon</math> was also used for [[Membership]] (the "characteristic vector"), which is closely related in that <math>\epsilon^j(n)</math> is <syntaxhighlight lang=apl inline>(⍳N)∊J</syntaxhighlight>; only this meaning was defined in APL. The [[glyph]]s <code>⍺</code> and <code>⍵</code> came to be used as argument names in [[Direct definition (notation)|direct definition]] and later [[dfn]]s.


{{quote|Very little has been rendered obsolete in the course of this. One thing that has been, and gave us some pain, (I don’t know if it gives you any pain) and that was the removal of the alpha and omega from the list of operators; but I don’t think the released systems had those, so you never missed them. We had them and it was a bit of a jar to lose them. But they are gone now.|—[[Adin Falkoff]]<ref>[[Adin Falkoff]]. [https://www.jsoftware.com/papers/apl360history.htm APL\360 History] at [[APL69]].</ref>}}
{{quote|Very little has been rendered obsolete in the course of this. One thing that has been, and gave us some pain, (I don’t know if it gives you any pain) and that was the removal of the alpha and omega from the list of operators; but I don’t think the released systems had those, so you never missed them. We had them and it was a bit of a jar to lose them. But they are gone now.|—[[Adin Falkoff]]<ref>[[Adin Falkoff]]. [https://www.jsoftware.com/papers/apl360history.htm APL\360 History] at [[APL69]].</ref>}}

Navigation menu