Mathematica >

RuntimeAttributes

RuntimeAttributes
is an option for Compile that specifies attributes for the compiled function it creates.
  • If a compiled function with Listable attribute matches its argument specification, it will run in the normal way.
  • If a compiled function with Listable attribute receives any arguments with higher rank than specified, the function will thread over these arguments.
This creates a compiled function that is listable:
It operates on a single input in normal fashion:
When the arguments include a list that does not match the input specification, it threads the function over that argument:
This compiled function is not listable:
An error results when the argument specification does not match:
If there is a branch, listability needs a function to be defined, as shown below using Function:
A listable compiled function does the same thing much faster:
A listable compiled function can run in parallel, giving an acceleration on multicore machines:
This creates a compiled function that is listable:
In[1]:=
Click for copyable input
Out[1]=
It operates on a single input in normal fashion:
In[2]:=
Click for copyable input
Out[2]=
When the arguments include a list that does not match the input specification, it threads the function over that argument:
In[3]:=
Click for copyable input
Out[3]=
This compiled function is not listable:
In[4]:=
Click for copyable input
Out[4]=
An error results when the argument specification does not match:
In[5]:=
Click for copyable input
Out[5]=
 
If there is a branch, listability needs a function to be defined, as shown below using Function:
In[1]:=
Click for copyable input
Out[1]=
A listable compiled function does the same thing much faster:
In[2]:=
Click for copyable input
Out[2]=
 
A listable compiled function can run in parallel, giving an acceleration on multicore machines:
In[1]:=
Click for copyable input
Out[1]=
New in 8
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team
Format:   HTML  |  CDF