Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

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!


  • Prev by Date: Re: identity matrix
  • Next by Date: First day with Mathematica 5, and now all I get is MakeExpression[ ... ]
  • Previous by thread: Turing machines anyone?
  • Next by thread: Re: Another question about Compile[]: