APA

From NARS2000
Revision as of 00:20, 16 April 2018 by Sudleyplace (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

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]).