MathGroup Archive 2003

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

Search the Archive

Re: Compile

  • To: mathgroup at smc.vnet.net
  • Subject: [mg45280] Re: Compile
  • From: Maxim <dontsendhere@.>
  • Date: Sat, 27 Dec 2003 05:00:18 -0500 (EST)
  • References: <bsd5h7$rb0$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com


Bill Rowe wrote:

> On 12/24/03 at 4:35 AM, dontsendhere@. (Maxim) wrote:
>
> > Not exactly. An elementary test shows that with both settings for Compiled the first
> > argument of Plot is evaluated in a non-standard way, as it should be (Mathematica Book,
> > A.4.2):
>
> > In[1]:=
> > Plot[Random[], {x, 0, 1}, Compiled -> True]
> > Plot[Random[], {x, 0, 1}, Compiled -> False]
>
> > (plots an irregular curve, not a straight line for one pre-evaluated value of Random[]).
>
> I don't see how this demonstrates your point. If you Compile an elementary (one pre-defined by Mathematica, i.e., not defined with Mathematica code) function I would expect no difference between the compiled and un-compiled versions. That is, I would expect the Mathematica interpreter to execucte some compiled code when it sees the token Random. And I would expect Compile to simply point to this compiled code.
>
> I would expect the only cases where Compile would make a difference is when the expression to be compiled is a sequence of operations defined by Mathematica code.
> --
> To reply via email subtract one hundred and four

My claim was: the first argument of Plot is evaluated in a non-standard way, that is, wrapping it in Evaluate would change the outcome. Do you not see how the example Plot[Random[],{x,0,1}] demonstrates this point? The argument that the effect of Compiled might change for some more complicated expressions is just speculation. I can make up a more complicated construct, like

Module[{y},
  y[arg_] := Module[{ans}, ans = arg; ans += Random[]];
  Plot[y[x], {x, 0, 1}]
]

How should Compiled 'make a difference' here? If you think that y[x] will be pre-evaluated, you're wrong.

Maxim Rytin
m.r at prontomail.com



  • Prev by Date: [RE] Can someone tell me why NDsolve isn't working here?
  • Next by Date: Re: bug???
  • Previous by thread: Re: Compile
  • Next by thread: Re: Compile