Compiling functions
- To: mathgroup at smc.vnet.net
- Subject: [mg31720] Compiling functions
- From: Cyril Fischer <fischerc at itam.cas.cz>
- Date: Thu, 29 Nov 2001 00:13:38 -0500 (EST)
- Organization: Inst. of Theoretical and Applied Mechanics
- Sender: owner-wri-mathgroup at wolfram.com
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.