"PackedArray" (Compiled Type)

TypeSpecifier["PackedArray"][type,rank]

represents a packed array composite type with elements of specified type and rank.

Details

  • "PackedArray" can be used in Typed and related constructs to specify a type.

Properties

Expression Conversions

    From Expressions

  • List expressions of appropriate form can be converted into compiled code elements with types created with "PackedArray". They must be rectangular and contain uniform elements of machine integer, machine real or machine complex real.
  • To Expressions

  • Compiled code elements with types created with "PackedArray" can be converted into List expressions.

Runtime Errors

    ArrayPartError

  • Elements with types constructed from "PackedArray" can give a runtime error if used in an operation that extracts or sets parts.

Examples

Basic Examples  (3)

"PackedArray" can be used as an input and output from a CompiledCodeFunction:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Part access can cause an error while running the function. The computation is terminated, a message is issued and the Wolfram Engine is used to compute the result:

In[1]:=
Click for copyable input
Out[1]=

"MachineInteger" is useful for working with "PackedArray", since this takes integers of the native size for the architecture:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=