MathGroup Archive 2006

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

Search the Archive

Re: Problem with compiled function (is this a bug?)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65584] Re: Problem with compiled function (is this a bug?)
  • From: tt at tt.com
  • Date: Sun, 9 Apr 2006 04:32:09 -0400 (EDT)
  • Organization: National Research Council, Ottawa, Canada
  • References: <e17ffs$olg$1@smc.vnet.net>
  • Reply-to: tt at tt.com
  • Sender: owner-wri-mathgroup at wolfram.com

On version 5.2 Windows, your code works fine if the iterator initial
values are explicitely set as Real (1->1.):

cpl = Compile[{x, y}, 
    Table[Ceiling[Norm[{i, j} - Ceiling[{x, y}/2]]], {i, 1., x}, {j,
1., y}]]

Above the two iterator initial values are changed to "1.", but it does
work if only one of them is changed like in:

cpl = Compile[{x, y}, 
    Table[Ceiling[Norm[{i, j} - Ceiling[{x, y}/2]]], {i, 1., x}, {j,
1, y}]]

Why? I will leave that answer to others...

Cordially.

GL



On Sat, 8 Apr 2006 04:51:08 +0000 (UTC), szhorvat at gmail.com wrote:

>I have a problem with the following compiled function:
>
>cpl = Compile[{x,y}, Table[Ceiling[Norm[{i, j} - Ceiling[{
>    x, y}/2]]], {i, 1, x}, {j, 1, y}]]
>
>When trying to use this function (for example, as idx = cpl[100,100]),
>I get the following error:
>
>CompiledFunction::"cfte" :
>Compiled expression 49 Sqrt[2] should be a rank 1 tensor of
>machine-size integers.
>
>CompiledFunction::cfex: External evaluation error at instruction 23;
>proceeding with uncompiled evaluation.
>
>I get the same error even if I try to specify that all variables are
>Reals:
>
>cpl = Compile[{{x, _Real}, {y, _Real}}, Table[Ceiling[Norm[{i, j} -
>Ceiling[{
>    x, y}/2]]], {i, 1, x}, {j, 1, y}], {{i, _Real}, {j, _Real}}]
>
>Is this a bug in Mathematica? If not, what is the right way to compile
>this function? Does this error occur with earlier versions than 5.2?
>
>I'd like to use this function to generate indices for a matrix whose
>values I want to average radially (ie. I'd like to compute the mean
>values in the ring around the center of the matrix). Unofrtunately this
>function takes more than 16 seconds on an 500x500 matrix on my machine
>which seems unrealistically long for such a simple function. I need to
>use the function interactively on many datasets, often much larger than
>500x500.
>
>Szabolcs Horvat


  • Prev by Date: Re: Problem with compiled function (is this a bug?)
  • Next by Date: Re: Problem with compiled function (is this a bug?)
  • Previous by thread: Re: Problem with compiled function (is this a bug?)
  • Next by thread: Code problem