Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

Re: Strange Compile runtime error

  • To: mathgroup at smc.vnet.net
  • Subject: [mg127542] Re: Strange Compile runtime error
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Fri, 3 Aug 2012 04:15:00 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net

On 8/2/12 at 4:50 AM, axel.kowald at gmail.com (Axel) wrote:

>I'm using Mathematica 8.0.1 on 32bit Win7 and I have a strange
>problem with Compile. Here my example that demonstrates the problem.

>compileTestC = Compile[{{paramList, _Integer, 1}},
>Module[{a, b},
>Print[paramList[[1]]];
>a = paramList[[1]];
>
>If[False,
>b = 1,
>b = 0
>] ;
>Return[5]
>] ] ;

>The first call to the compiled function works as expected and gives:
>compileTestC[{100}] 100 5

>However, all following calls to the function give this error
>message: compileTestC[{100}] 100 CompiledFunction::cflist: Nontensor
>object generated; proceeding with uncompiled evaluation. >> 100 5

I cannot reproduce the error you indicate. If I paste your
function into a fresh kernel every execution produces the
expected result with no error message.

But what are you expecting to achieve with this code?

The If will always test False and consequently always does b = 0.

So, your code is will do exactly the same as

f[x_List]:= (Print[a=x[[1]];b=0;5)

and Compile cannot speed this up.




  • Prev by Date: Re: Mathematica as a New Approach to Teaching Maths
  • Next by Date: Ordering an algebraic expression in Mathematica
  • Previous by thread: Strange Compile runtime error
  • Next by thread: Using Mathematica Workbench to debug compiled functions ??