APA: Difference between revisions
No edit summary |
Sudleyplace (talk | contribs) No edit summary |
||
Line 2: | Line 2: | ||
<p>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>)), for a total of <apll>96</apll> bytes. This datatype is also used to store reshaped Boolean or integer scalars, as in <apll>1e6⍴12</apll> or <apll>1e6/12</apll> both of which use <apll>80</apll> bytes (<apll>16</apll> bytes less than the preceding example because it has two fewer shape elements at eight bytes per).</p> | <p>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>)), for a total of <apll>96</apll> bytes. This datatype is also used to store reshaped Boolean or integer scalars, as in <apll>1e6⍴12</apll> or <apll>1e6/12</apll> both of which use <apll>80</apll> bytes (<apll>16</apll> bytes less than the preceding example because it has two fewer shape elements at eight bytes per).</p> | ||
<p>Within the implementation, this datatype is used to avoid treating elided coordinates for indexing (as in <apll>M[;1]</apll>) as a special case by substituting an APA for the elided coordinate (as in <apll>M[⍳(⍴M)[1];1]</apll>).</p> |
Latest revision as of 19:20, 15 April 2018
So as to more efficiently represent this commonly occurring array, a new datatype — Arithmetic Progression Arrays (APAs) — are created by the Index Generator function and may be reshaped arbitrarily (as long as no replication occurs) and still retain the datatype.
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)), for a total of 96 bytes. This datatype is also used to store reshaped Boolean or integer scalars, as in 1e6⍴12 or 1e6/12 both of which use 80 bytes (16 bytes less than the preceding example because it has two fewer shape elements at eight bytes per).
Within the implementation, this datatype is used to avoid treating elided coordinates for indexing (as in M[;1]) as a special case by substituting an APA for the elided coordinate (as in M[⍳(⍴M)[1];1]).