Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

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]] ?


  • Prev by Date: Re: Google's aptitude test equation
  • Next by Date: Re: InitializationCell
  • Previous by thread: Re: Nested iterators in Compile
  • Next by thread: Re: Re: Nested iterators in Compile