       Re: Compile problem

• To: mathgroup at smc.vnet.net
• Subject: [mg52407] Re: [mg52369] Compile problem
• From: DrBob <drbob at bigfoot.com>
• Date: Fri, 26 Nov 2004 01:04:36 -0500 (EST)
• References: <200411251049.FAA21438@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```You like semicolons too well. This works:

SRSort = Compile[
{{f, _Real, 1}}, Module[{lambda, i},
lambda = Length[f]; Index = Table[0,
{lambda}]; For[i = 1, i <= lambda, i++,
Index[[i]] = f[[i]]; ];
Index]];
data = RandomArray[BinomialDistribution[12, 0.3], 12]
copy=SRSort[data]
{5, 3, 2, 3, 4, 3, 6, 6, 2, 6, 2, 3}
{5, 3, 2, 3, 4, 3, 6, 6, 2, 6, 2, 3}

But this works a lot better:

copy=data

Bobby

On Thu, 25 Nov 2004 05:49:39 -0500 (EST), Joerg Schaber <schaber at molgen.mpg.de> wrote:

>
>
> Hi,
>
> here I provide a simple test code (just copies a vector) which denies to
> compile but gives the error message "The type of return values in ...
> are different".
> I am using Mathematica 5.0.
>
> SRSort = Compile[{{f, _Real, 1}}, Module[{lambda,i},
>          lambda=Length[f];
> 	Index = Table[0, {lambda}];
>            For[i = 1, i <= lambda, i++,
>              Index[[i]] = f[[i]];
>              ];
>            Return[Index];
>            ];
>        ];
>
> When I just put "Index" at the end of the loop, the function compiles
> but does not deliver any output.
> Any idea what's the problem here?
>
> Thanks,
>
> joerg
>
>
>
>

--
DrBob at bigfoot.com
www.eclecticdreams.net

```

• Prev by Date: Re: Re: Integral: Exp[-(x-m)^2/(2 s^2)] x^3 (1+x^2)^-1
• Next by Date: Re: Re: Newly Released Mathematica 5.1 Delivers Unmatched Performance for Handling Data
• Previous by thread: Compile problem
• Next by thread: Re: Compile problem