Function return type in Compile
- To: mathgroup at smc.vnet.net
- Subject: [mg124231] Function return type in Compile
- From: Ashwini <aksingh21 at gmail.com>
- Date: Sat, 14 Jan 2012 02:58:19 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
Hi, I have large number of small functions whose return type is Boolean or Integer. How can I declare the function return type in a global way so that I don't have to write it down in every Compile: Example: TestQ[x_Integer] := If[EvenQ[x], True, False]; (*Just a wrapper on EvenQ*) cf2 = Compile[{{y, _Integer}}, If[TestQ[y], 1, 2]]; cf2[2] CompiledFunction::cfex: Could not complete external evaluation at instruction 1; proceeding with uncompiled evaluation. After including the return type of TestQ, It works fine cf3 = Compile[{{y, _Integer}}, If[TestQ[y], 1, 2], {{TestQ[_], True | False}}]; cf3[2] works fine. But if I replace TestQ with EvenQ I don't have to specify the the return type cf4 = Compile[{{y, _Integer}}, If[EvenQ[y], 1, 2]]; How can this be done for TestQ? regards, Ashwini