Index Generator: Difference between revisions
Sudleyplace (talk | contribs) No edit summary |
No edit summary |
||
(5 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
< | <table border="1" cellpadding="5" cellspacing="0" rules="none" summary=""> | ||
< | <tr> | ||
<td> | |||
<table border="0" cellpadding="5" cellspacing="0" summary=""> | |||
<tr> | |||
<td valign="top"><apll>Z←⍳R</apll></td> | |||
<td></td> | |||
<td></td> | |||
<td>returns a vector of consecutive ascending integers.</td> | |||
</tr> | |||
</table> | |||
</td> | |||
</tr> | |||
<tr> | |||
<td><apll>R</apll> is a negative integer scalar or one-element vector.</td> | |||
</tr> | |||
<tr> | |||
<td><apll>Z</apll> is an integer vector of length <apll>|R</apll> whose values range from <apll>⎕IO+R</apll> to <apll>⎕IO-1</apll>.</td> | |||
</tr> | |||
<tr> | |||
<td>This feature extends monadic iota to negative arguments.</td> | |||
</tr> | |||
<tr> | |||
<td>This function is sensitive to <apll>⎕IO</apll> and <apll>⎕FEATURE</apll>. In particular, <apll>⎕FEATURE[⎕IO]</apll> must be <apll>1</apll> in order for negative values in <apll>R</apll> to be accepted; otherwise a <apll>DOMAIN ERROR</apll> is signalled.</td> | |||
</tr> | |||
</table> | |||
<br /> | |||
<p>For example, in origin-0</p> | <p>For example, in origin-0</p> | ||
Line 16: | Line 40: | ||
<apll> ⍳¯3</apll><br /> | <apll> ⍳¯3</apll><br /> | ||
<apll>¯2 ¯1 0</apll></ | <apll>¯2 ¯1 0</apll> | ||
<p>This function is used to create [[APA|Arithmetic Progression Arrays (APAs)]]. For example, <apll>2 3 4⍴⍳24</apll> has a very compact storage consisting of the array shape (<apll>2 3 4</apll>), the starting offset (<apll>⎕IO</apll>) and multiplier (<apll>1</apll>), plus the normal array overhead (which includes the number of elements (<apll>24</apll>)).</p> | |||
<table border="1" cellpadding="5" cellspacing="0" rules="none" summary=""> | |||
<tr> | |||
<td> | |||
<table border="0" cellpadding="5" cellspacing="0" summary=""> | |||
<tr> | |||
<td valign="top"><apll>Z←⍳R</apll></td> | |||
<td></td> | |||
<td></td> | |||
<td>returns an array of integer indices suitable for indexing all the elements of an array of shape <apll>|R</apll>.</td> | |||
</tr> | |||
</table> | |||
</td> | |||
</tr> | |||
<tr> | |||
<td><apll>R</apll> is an integer vector of length > 1.</td> | |||
</tr> | |||
<tr> | |||
<td><apll>Z</apll> is a nested array of shape <apll>|R</apll> whose items are each integer vectors of length <apll>⍴⍴R</apll> and whose values range from <apll>⎕IO+R</apll> to <apll>(⍴R)⍴⎕IO-1</apll>.</td> | |||
</tr> | |||
<tr> | |||
<td>This feature extends monadic iota to multi-element vector arguments.</td> | |||
</tr> | |||
<tr> | |||
<td>This function is sensitive to <apll>⎕IO</apll> and <apll>⎕FEATURE</apll>. In particular, <apll>⎕FEATURE[⎕IO]</apll> must be <apll>1</apll> in order for negative values in <apll>R</apll> to be accepted; otherwise a <apll>DOMAIN ERROR</apll> is signalled.</td> | |||
</tr> | |||
</table> | |||
<br /> | |||
<p>For example, in origin-0</p> | <p>For example, in origin-0</p> | ||
Line 40: | Line 93: | ||
<apll> 2 ¯2 2 ¯1 2 0</apll> | <apll> 2 ¯2 2 ¯1 2 0</apll> | ||
<p>This extension is implemented via an internal magic function due to Carl M. Cheney:</p> | <br /> | ||
<br /> | |||
<p>For example, taking into account both of the above extensions, <apll>A</apll>, <apll>A[⍳⍴A]</apll>, <apll>A[⍳-⍴A]</apll>, and even <apll>A[⍳¯1 1[?(⍴⍴A)⍴2]×⍴A]</apll> are all identical for any array <apll>A</apll> in either origin.</p> | |||
<p>This last extension is implemented via an internal magic function due to Carl M. Cheney:</p> | |||
<apll> ∇ Z←#MonIota V</apll><br /> | <apll> ∇ Z←#MonIota V</apll><br /> | ||
<apll>[1] Z←⊃∘.,/⍳¨V</apll><br /> | <apll>[1] Z←⊃∘.,/⍳¨V</apll><br /> | ||
<apll> ∇</apll | <apll> ∇</apll> | ||
Latest revision as of 10:34, 26 May 2013
|
||||
R is a negative integer scalar or one-element vector. | ||||
Z is an integer vector of length |R whose values range from ⎕IO+R to ⎕IO-1. | ||||
This feature extends monadic iota to negative arguments. | ||||
This function is sensitive to ⎕IO and ⎕FEATURE. In particular, ⎕FEATURE[⎕IO] must be 1 in order for negative values in R to be accepted; otherwise a DOMAIN ERROR is signalled. |
For example, in origin-0
⍳3
0 1 2
⍳¯3
¯3 ¯2 ¯1
and in origin-1
⍳3
1 2 3
⍳¯3
¯2 ¯1 0
This function is used to create Arithmetic Progression Arrays (APAs). For example, 2 3 4⍴⍳24 has a very compact storage consisting of the array shape (2 3 4), the starting offset (⎕IO) and multiplier (1), plus the normal array overhead (which includes the number of elements (24)).
|
||||
R is an integer vector of length > 1. | ||||
Z is a nested array of shape |R whose items are each integer vectors of length ⍴⍴R and whose values range from ⎕IO+R to (⍴R)⍴⎕IO-1. | ||||
This feature extends monadic iota to multi-element vector arguments. | ||||
This function is sensitive to ⎕IO and ⎕FEATURE. In particular, ⎕FEATURE[⎕IO] must be 1 in order for negative values in R to be accepted; otherwise a DOMAIN ERROR is signalled. |
For example, in origin-0
⍳2 3
0 0 0 1 0 2
1 0 1 1 1 2
⍳2 ¯3
0 ¯3 0 ¯2 0 ¯1
1 ¯3 1 ¯2 1 ¯1
and in origin-1
⍳2 3
1 1 1 2 1 3
2 1 2 2 2 3
⍳2 ¯3
1 ¯2 1 ¯1 1 0
2 ¯2 2 ¯1 2 0
For example, taking into account both of the above extensions, A, A[⍳⍴A], A[⍳-⍴A], and even A[⍳¯1 1[?(⍴⍴A)⍴2]×⍴A] are all identical for any array A in either origin.
This last extension is implemented via an internal magic function due to Carl M. Cheney:
∇ Z←#MonIota V
[1] Z←⊃∘.,/⍳¨V
∇