[Date Index]
[Thread Index]
[Author Index]
Re: Change Rank in Compile
*To*: mathgroup at smc.vnet.net
*Subject*: [mg16114] Re: [mg16046] Change Rank in Compile
*From*: David Withoff <withoff>
*Date*: Thu, 25 Feb 1999 08:25:05 -0500
*Sender*: owner-wri-mathgroup at wolfram.com
> Can someone tell me please who I can use a bigger array in a compiled module:
>
> sum$compiled=
> Compile[{{v,_Real,120}},
> Block[{i=1,s=0.0,x=0.0},s=0.0;Do[x=Take[v,i];s=s+x 2,{i,10}]]]
>
> With the Value of 120 I get the message:
>
> Compile::"maxrank":
> "Rank specification \!\(120\) in \!\({v, _Real, 120}\) exceeds the rank \
> limit (\!\(100\))."
Rank is the number of dimensions. Your example indicates that the argument
is a vector (a tensor of rank 1). My guess is that you don't really need
to change the rank. Tensors with 120 dimensions aren't very common in
applied mathematics.
Here is an example of a compiled procedural program for adding up the
squares of the elements in a list with 120 elements.
In[2]:= sum$compiled = Compile[{{v,_Real,1}},
Block[{s,x},s=0.0; Do[x=Part[v,i];s=s+x^2,{i,Length[v]}]; s]] ;
In[3]:= data = Table[Random[], {120}] ;
In[4]:= sum$compiled[data]
Out[4]= 42.1878
In your second example, the warning message from
> sum$compiled=
> Compile[{{v,_Real,10}},
> Block[{i=1,s=0.0,x=0.0},s=0.0;Do[x=Take[v,i];s=s+x 2,{i,10}]]]
>
> gives the error message
>
> Compile::"cset":
> "Variable \!\(x\) of type \!\({\"_Real\", 0}\) encountered in assignment \
> of type \!\({\"_Real\", 10}\)."
occurs because x is first assigned a scalar value (0.0) and later assigned
a value which is in principle a tensor with 10 dimensions (Take[v,i]).
> Yours sincerely Peter Klamser
Dave Withoff
Wolfram Research
Prev by Date:
**Lock up**
Next by Date:
**MathLink & Metrowerks CodeWarrior**
Previous by thread:
**Re: Change Rank in Compile**
Next by thread:
**RE: Forms Interface?**
| |