Re: Compiling functions
- To: mathgroup at smc.vnet.net
- Subject: [mg31751] Re: Compiling functions
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Sat, 1 Dec 2001 02:43:50 -0500 (EST)
- Organization: Universitaet Leipzig
- References: <9u4g5i$lhk$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, expr = (-b + Sqrt[b^2 - 4*a*c])/(2*a); tf = Compile[{{a, _Complex}, {b, _Complex}, {c, _Complex}}, Evaluate[expr]] Regards Jens Cyril Fischer wrote: > > Hello. I would like to ask you for help with compiling functions. > > Let's have > expr = (-b + Sqrt[b^2 - 4*a*c])/(2*a) > > Simple compile does not work for me: > tf = Compile[{a, b, c}, expr]; tf[1, 2, 3] > > in this case the the values are not substitued for symbols. > > Such a ugly construction works > tf = Compile[{a1, b1, c1}, > Evaluate[expr /. {a -> a1, b -> b1, c -> c1}]]; tf[1, 2, 3] > > however it failes to evaluate compiled expression as the sqrt result is > not real. > > 1. How can I compile (assigned) expressions without substitution for > each parameter? > > 2. How can I compile expressions, which (for real input) can give > complex output? > > Thanks, Cyril F.