MathGroup Archive 2002

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

Search the Archive

Re: Question regarding Compile

  • To: mathgroup at smc.vnet.net
  • Subject: [mg33752] Re: Question regarding Compile
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Thu, 11 Apr 2002 02:14:06 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <a8m33c$oaq$1@smc.vnet.net> <a8tt4m$fmg$1@smc.vnet.net> <a90hj5$kfv$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de
  • Sender: owner-wri-mathgroup at wolfram.com

Madhusudan Singh wrote:
> 
> Thanks for your response.
> 
> >
> > You can not do *what* ? and what may
> >
> > f5 = Compile[{{x, _Real}}, Sin[x]]
> >
> > f[x_] := x^2
> >
> > Plot[f[f5[x]], {x, 0, Pi}]
> >
> > do ?
> 
> This works. I was using a syntax like :
> Compile[{x}, expression] as the help stated that _Real was the default.
> However, it seems that I need to write it as ;
> Compile[{x,_Real},expression].
> 
> That said, the expressions that I am working with, are :
> 
> integrand := Compile[{{y, _Real}, {x1, _Real}, {x2, _Real}}, f1[pl[argument[y]] + x1, x2, c]];
> 
> pl[] is an array, f1 and argument are functions (fairly simple functions).
> c is a constant.
> 
> answer1[x1_, x2_] := Exp[-2 Integrate[integrand[y, x1, x2], {y, a, b}]];
> 
> a=0, b~1e-8
> 
> I get an error :
> 
> CompiledFunction::cfsa: Argument y at position should be a machine-size
> real number.


You can't symbolical integrate a compiled function !  and you can't pass
a
symbol like y (without a value) to a compiled function where you
declared
the argument as Real

> 
> when I try to use answer1 with
> 
> jt3=q NIntegrate[v[x1, 50, 0.2] g3[0.2, x1, 50] partjt3[x1]
> answer1[0.0, x1], {x1, 50, maxpl + dummyinfinity}, Method -> MonteCarlo, MaxPoints -> 10000];
> 
> v, g3, partjt3 are simple functions.
> 
> As you can see, this is quite complicated. However, since a and b are
> fixed numbers, and nowhere near machine precision, I do not not understand
> the error above.
> 
> This is leading to other errors later.
> 
> Any ideas ?

Use NIntegrate[] instead of Integrate[]. There is no need to compile the
argument of NIntegrate[] because Mathematica will do it by default.

Regards
  Jens


  • Prev by Date: Re: How to Return from within a Table[]-Command?
  • Next by Date: Re: Trouble with inverting matrices
  • Previous by thread: Re: Question regarding Compile
  • Next by thread: Re: Question regarding Compile