Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Help on compiling a function
Replies: 6   Last Post: Jan 19, 2011 5:24 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Ramiro

Posts: 26
Registered: 9/18/07
Re: Help on compiling a function
Posted: Jan 19, 2011 5:24 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.