MathGroup Archive 2010

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

Search the Archive

Question: Compile in Mathematica 8.0

  • To: mathgroup at
  • Subject: [mg114631] Question: Compile in Mathematica 8.0
  • From: Asim <maa48 at>
  • Date: Sat, 11 Dec 2010 01:52:46 -0500 (EST)


I am not sure why the first function named v works and why the second
function named v1 does not compile. The only difference between the
two functions is in the variable called len which controls the number
of random numbers that are generated.

I am using Mathematica 8.0 on Windows Vista machine.



First function:

v = Compile[{{n, _Integer}},
   {g, len},
   len = n*(n - 1);
   g = RandomVariate[NormalDistribution[0., 1.], len]

Output is




Second Function:

v1 = Compile[{{n, _Integer}},
   {g, len},
   len = n*(n - 1)/2;
   g = RandomVariate[NormalDistribution[0., 1.], len]

CompiledFunction[{n},Module[{g,len},len=1/2 n


During evaluation of In[42]:= CompiledFunction::cfse: Compiled
expression {-0.325949,1.72381,0.368231} should be a machine-size
integer. >>

During evaluation of In[42]:= CompiledFunction::cfex: Could not
complete external evaluation at instruction 8; proceeding with
uncompiled evaluation. >>

Out[42]= {0.295626, 0.664446, 0.654626}

  • Prev by Date: Re: Puzzled by IntegerPart
  • Next by Date: Re: ErrorListPlot
  • Previous by thread: Re: non working CUDA x86_64 with Home Edition x86
  • Next by thread: Re: Question: Compile in Mathematica 8.0