MathGroup Archive 2005

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

Search the Archive

Re: Compile nested loops with depending index variables...

  • To: mathgroup at smc.vnet.net
  • Subject: [mg61298] Re: Compile nested loops with depending index variables...
  • From: Peter Pein <petsie at dordos.net>
  • Date: Fri, 14 Oct 2005 22:22:28 -0400 (EDT)
  • References: <dikso7$4nr$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Christoph Lhotka schrieb:
> First of all try this:
> 
> f[n_]:=Table[{i,j},{i,0,n},{j,0,i}]
> fc=Compile[{n},Block[{i=0},Table[{i,j},{i,0,n},{j,0,i}]]]
> 
> In[..]:=f[2]==fc[2]
> Out[..]:=False
> 
> Second, don´t tell us, what is nonsense and what is not before you understand
> the question.
> 
> Regards
> Christoph
> 
> 
> On Tue, 11 Oct 2005 06:19:11 -0400 (EDT)
>  "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de> wrote:
> 
>>Hi,
>>f = Compile[{n}, Block[{i = 0}, Do[g[i, j], {i, 0, 
>>n}, {j, 0, i}]]]
>>
>>compile fine, and evaluate fine, even when it is 
>>nonsense to use a compiled function here.
>>
>>Regards
>>
>>  Jens
>>
>>"Christoph Lhotka" <lhotka at astro.univie.ac.at> 
>>schrieb im Newsbeitrag 
>>news:difpn1$f0m$1 at smc.vnet.net...
>>| How is it possible to compile the following code 
>>structures in Mathematica:
>>|
>>| Do|Table[exp[i,j,...],{i,0,n},{j,0,i},...],
>>|
>>| for example in
>>|
>>| In[..]:=f=Compile[{n},Do[g[i,j],{i,0,n},{j,0,i}]
>>| Out[..]:= CompiledFunction[...]
>>|
>>| ?
>>|
>>| It does not work, when you use the compiled 
>>function, since the compiler
>>| expects a integer expression for i...
>>|
>>| Do[Do[Do ...  does not work either!
>>|
>>| This is such a basic construct!
>>|
>>| -- Mag. Christoph Lhotka --
>>| University of Vienna / Institute for Astronomy
>>| mail. lhotka at astro.univie.ac.at
>>| 
>>
>>
> 
> 
> -- Mag. Christoph Lhotka --
> University of Vienna / Institute for Astronomy
> mail. lhotka at astro.univie.ac.at
> 

0.) Me too, I don't get this nested list construction compiled.
1.) I've found a way to construct the list you mention about 2.4 times 
faster than Table[{i,j},....].
2.) I'm afraid I'm not allowed to post it before I understand, how to 
deduce Table[{i,j},...] from Do[g[i,j],...].

Peter


  • Prev by Date: Re: Re: SingularValueDecomposition bug: fifty examples
  • Next by Date: Re: big integer for Range
  • Previous by thread: Re: Re: Compile nested loops with depending index variables...
  • Next by thread: Re: Re: Compile nested loops with depending index variables...