Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

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

Search the Archive

Re: Help on compiling a function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg115709] Re: Help on compiling a function
  • From: Ramiro <ramiro.barrantes at gmail.com>
  • Date: Wed, 19 Jan 2011 05:24:06 -0500 (EST)
  • References: <iguiqe$8sv$1@smc.vnet.net> <ih16da$jkp$1@smc.vnet.net>

Thanks so much, this was the answer exactly.  Just a small
clarification:

I have been going through the compiler documenttaion.  If I do
On[ Compile::noinfo]

I get the following:

example1 =
 Compile[{{n, _Real, 1}, {a, _Real}, {b, _Real}, {t, _Real, 1}},
  Block[{tn = Total[n]},
   b^a*Exp[LogGamma[tn + a] - (Total[LogGamma[n + 1]] + LogGamma[a]) +
       Total[n*Log[t]] - (tn + a)*Log[Total[t] + b]]]];
example1[{97.6203, 8.4788, 21.4204, 46.1755}, 1,
  1, {39.9342, 7.5820, 5.8656, 10.0553}] // AbsoluteTiming

Compile::noinfo: No information is available for compilation of
LogGamma[Compile`$3]. The compiler will use an external evaluation and
make assumptions about the return type. >>

Compile::noinfo: No information is available for compilation of
LogGamma[n+1]. The compiler will use an external evaluation and make
assumptions about the return type. >>

Compile::noinfo: No information is available for compilation of
LogGamma[a]. The compiler will use an external evaluation and make
assumptions about the return type. >>
{0.000087, 1.06265*10^-11}

But if I add the corresponding information about LogGamma and Total,
the function performs a bit slower:

In[109]:= Clear[example1];
example1 =
 Compile[{{n, _Real, 1}, {a, _Real}, {b, _Real}, {t, _Real, 1}},
  Block[{tn = Total[n]},
   b^a*Exp[LogGamma[tn + a] - (Total[LogGamma[n + 1]] + LogGamma[a]) +
       Total[n*Log[t]] - (tn + a)*
       Log[Total[t] +
         b]]], {{LogGamma[_], _Real}, {Total[_], _Real}}];
example1[{97.6203, 8.4788, 21.4204, 46.1755}, 1,
  1, {39.9342, 7.5820, 5.8656, 10.0553}] // AbsoluteTiming

Out[110]= {0.000141, 1.06265*10^-11}

Why is this?

Thanks to everyone for their help again,

Ramiro


  • Prev by Date: Re: clip
  • Next by Date: Re: InterpolatingPolynomial error message
  • Previous by thread: Re: Help on compiling a function
  • Next by thread: Re: Help on compiling a function