Re: Nested iterators in Compile
- To: mathgroup at smc.vnet.net
- Subject: [mg55072] Re: Nested iterators in Compile
- From: "Ray Koopman" <koopman at sfu.ca>
- Date: Fri, 11 Mar 2005 04:20:54 -0500 (EST)
- References: <d0p91t$jcg$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Wolf, Hartmut wrote: > [...] > Also mistrust any compiled function f with > > In[3]:= FreeQ[f[[-2]], Function] > Out[3]= False > > > This case can be solved easily: > > In[4]:= f2 = Compile[{{n, _Integer}}, > Module[{s = 0}, Do[Do[s += j, {j, i}], {i, n}]; > s]]; > > In[5]:= f2[10] > Out[5]= 220 > > In[6]:= FreeQ[f2[[-2]], Function] > Out[6]= True > In[1]:= f1 = Compile[{n}, Module[{s = 0}, Do[s += j, {i, n}, {j, i}]; s]]; In[2]:= f2 = Compile[{{n, _Integer}},Module[{s = 0}, Do[Do[s += j, {j, i}], {i, n}]; s]]; In[3]:= FreeQ[f1[[#]],Function]& /@ Range@Length@f1 FreeQ[f2[[#]],Function]& /@ Range@Length@f2 Out[3]= {True,True,True,False,False,True} Out[4]= {True,True,True,True,False,True} Do you mean f[[-3]] ?