Problem with compiled function (is this a bug?)
- To: mathgroup at smc.vnet.net
- Subject: [mg65570] Problem with compiled function (is this a bug?)
- From: szhorvat at gmail.com
- Date: Sat, 8 Apr 2006 00:45:13 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
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
- Follow-Ups:
- Re: Problem with compiled function (is this a bug?)
- From: "Carl K. Woll" <carlw@wolfram.com>
- Re: Problem with compiled function (is this a bug?)
- From: "Carl K. Woll" <carlw@wolfram.com>
- Re: Problem with compiled function (is this a bug?)