|
SOLUTIONS
|
BUILT-IN MATHEMATICA SYMBOL
RuntimeAttributes
RuntimeAttributes
is an option for Compile that specifies attributes for the compiled function it creates.
DetailsDetails
- RuntimeAttributes applies to the execution of the compiled function.
- A possible setting for RuntimeAttributes is Listable.
- RuntimeAttributes->Listable is effectively equivalent to the Listable attribute of the built-in function.
- 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.
ExamplesExamplesopen allclose all
Basic Examples (3)Basic Examples (3)
This creates a compiled function that is listable:
| In[1]:= |
| Out[1]= |
It operates on a single input in normal fashion:
| In[2]:= |
| Out[2]= |
When the arguments include a list that does not match the input specification, it threads the function over that argument:
| In[3]:= |
| Out[3]= |
This compiled function is not listable:
| In[4]:= |
| Out[4]= |
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:
| In[1]:= |
| Out[1]= |
A listable compiled function does the same thing much faster:
| In[2]:= |
| Out[2]= |
A listable compiled function can run in parallel, giving an acceleration on multicore machines:
| In[1]:= |
| Out[1]= |
New in 8
Mathematica 9 is now available!
New to Mathematica?
Find your learning path »
Have a question?
Ask support »


