Pointer array: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
Miraheze>Marshall
mNo edit summary
m (Nested array model category)
 
(2 intermediate revisions by 2 users not shown)
Line 2: Line 2:


Pointer arrays take more space to store than flat arrays and are often slower to manipulate. The size of each pointer is the processor's [[wikipedia:Word_(computer_architecture)|machine word]] size—64 bits on a 64-bit machine. However, each element of a pointer array is itself an array, and is stored with an array header which may be several times the size of a pointer. When a simple array is converted to a pointer array, for instance, by appending a non-simple array as an element, the space used may be tens or even hundreds of times larger than it was before. If the type of the original array elements was smaller (in bits) than a pointer, [[structural function]]s on the array will be slower. Even if the original type was large, functions that need to read elements of the array, such as [[scalar function]]s, will be many times slower because of the need to follow a pointer to read every element.
Pointer arrays take more space to store than flat arrays and are often slower to manipulate. The size of each pointer is the processor's [[wikipedia:Word_(computer_architecture)|machine word]] size—64 bits on a 64-bit machine. However, each element of a pointer array is itself an array, and is stored with an array header which may be several times the size of a pointer. When a simple array is converted to a pointer array, for instance, by appending a non-simple array as an element, the space used may be tens or even hundreds of times larger than it was before. If the type of the original array elements was smaller (in bits) than a pointer, [[structural function]]s on the array will be slower. Even if the original type was large, functions that need to read elements of the array, such as [[scalar function]]s, will be many times slower because of the need to follow a pointer to read every element.
{{APL features}}[[Category:Kinds of array]][[Category:Nested array model]]

Latest revision as of 15:02, 30 April 2020

In nested array theory, a pointer array is an array which is mixed or nested. It corresponds to an array of boxes in flat array theory: pointer arrays are exactly those which require boxes to store in a flat APL. Every array is either a simple character, simple numeric, or pointer array (adding a new class of simple scalar would add a new possibility).

Pointer arrays take more space to store than flat arrays and are often slower to manipulate. The size of each pointer is the processor's machine word size—64 bits on a 64-bit machine. However, each element of a pointer array is itself an array, and is stored with an array header which may be several times the size of a pointer. When a simple array is converted to a pointer array, for instance, by appending a non-simple array as an element, the space used may be tens or even hundreds of times larger than it was before. If the type of the original array elements was smaller (in bits) than a pointer, structural functions on the array will be slower. Even if the original type was large, functions that need to read elements of the array, such as scalar functions, will be many times slower because of the need to follow a pointer to read every element.

APL features [edit]
Built-ins Primitives (functions, operators) ∙ Quad name
Array model ShapeRankDepthBoundIndex (Indexing) ∙ AxisRavelRavel orderElementScalarVectorMatrixSimple scalarSimple arrayNested arrayCellMajor cellSubarrayEmpty arrayPrototype
Data types Number (Boolean, Complex number) ∙ Character (String) ∙ BoxNamespaceFunction array
Concepts and paradigms Conformability (Scalar extension, Leading axis agreement) ∙ Scalar function (Pervasion) ∙ Identity elementComplex floorArray ordering (Total) ∙ Tacit programming (Function composition, Close composition) ∙ GlyphLeading axis theoryMajor cell searchFirst-class function
Errors LIMIT ERRORRANK ERRORSYNTAX ERRORDOMAIN ERRORLENGTH ERRORINDEX ERRORVALUE ERROREVOLUTION ERROR