Re: On the built-in function "Compile"
- To: mathgroup at smc.vnet.net
- Subject: [mg90223] Re: On the built-in function "Compile"
- From: Szabolcs Horvát <szhorvat at gmail.com>
- Date: Wed, 2 Jul 2008 05:33:53 -0400 (EDT)
- References: <g4d2ui$eqv$1@smc.vnet.net>
shingo wrote:
> Hi guys, I worked on the mathematica built-in function "Compile" and
> found some trobles. If u have some ideas, plz help me.
>
> Following code works well:
>
> In[1]:=
> testA = Compile[{{i, _Integer}}, # & /@ Range[1, i, 1]]
>
> Out[1]:=
> CompiledFunction[{i},(#1&)/@Range[1,i,1],-CompiledCode-]
>
> However, in the case of nested list, it doesnt.
>
> In[2]:=
> testB = Compile[{{i, _Integer}},
> Outer[{#1, #2} &, Range[1, i, 1], Range[1, i, 1]]]
>
> Out[2]:=
> Compile::cpapot: Compilation of \
> Outer[{#1,#2}&,Range[1,i,1],Range[1,i,1]] is not supported for the \
> function argument {#1,#2}&. The only function arguments supported are
> \
> Times, Plus, or List. Evaluation will use the uncompiled function. >>
> CompiledFunction[{i},Outer[{#1,#2}&,Range[1,i,1],Range[1,i,1]],-
> CompiledCode-]
Well, the error message tells you what to do. Just use
testB = Compile[{{i, _Integer}}, Outer[List, Range[i], Range[i]]]