Another question about Compile[]:
- To: mathgroup at smc.vnet.net
- Subject: [mg49950] Another question about Compile[]:
- From: gilmar.rodriguez at nwfwmd.state.fl.us (Gilmar Rodr?guez Pierluissi)
- Date: Sat, 7 Aug 2004 03:51:48 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Dear Mathematica Web Group: I'm attempting to build a Compiled version of the following function: In[1]: MGPPP[n_] := Module[{p, q}, {m = n/2; If[Element[m, Primes], {p = m, q = m}, {k = PrimePi[m]; Do[If[Element[n - Prime[i], Primes], hit = i; Break[]], {i, k, 1, -1}], p = Prime[hit], q = n - p}]}; {p, q}] which works as follows: In[2]: MGPPP[400] Out[2]: {173, 227} Unfortunately, my attempt fails: In[3]: mgppp = Compile[{{p, _Integer, 1}, {q, _Integer, 1}, {n, _Integer, 1}}, Module[{p, q}, {m = n/2; If[Element[m, Primes], {p = m, q = m}, { k = PrimePi[m]; Do[If[Element[n - Prime[i], Primes], hit = i; Break[]], {i, k, 1, -1}], p = Prime[hit], q = n - p}]}; {p, q}]] Out[3]: Compile::initvar: The variable p has not been initialized or has been \ initialized to Null. Compile::cptype: List not supported for type Void; evaluation will use the \ uncompiled function. Thank you for your help!
- Follow-Ups:
- Re: Another question about Compile[]:
- From: DrBob <drbob@bigfoot.com>
- Re: Another question about Compile[]: