Well, first of all, the syntax (a;b) won't work for a sequence of
operations in Maxima; you need to write (a,b). Secondly, to have multiple
conditions in "if", you need to write if(a>0 and b>0 ...) and not
if(a>0,b>0, ...). Third, (just a stylistic issue), you don't need "return"
all over the place; instead of << if x then return(y) else if z then
return(a) ... >>, just write << if x then y else if z then a ... >>.
Finally, it looks as though a sparse hasharray may be exactly what you
need... except for one problem: that there is no easy way that I can think
of to determine whether a given element is 'undefined'.
-s
On Thu, Nov 22, 2012 at 11:11 PM, Jianrong Li <lijr07 at gmail.com> wrote:
> Dear Stavros,
>
> Thank you very much. The array can be small. For example, 20^4.
>
> I am trying to define a recursive function Character(m, k, n, l) to
> compute characters (the codes are in the following). But it has errors when
> I define Character[m][k][n][l].
>
> Best wishes,
> Jianrong.
>
>
> for m:0 thru 100 step 1 do
> for k:0 thru 100 step 1 do
> for n:0 thru 100 step 1 do
> for l:0 thru 100 step 1 do
> Character[m][k][n][l]:0;
>
> Character(m, k, n, l):= block([],
> if (Character[m][k][n][l] > 0 ) then
> (Character[n][k][m][l]:Character[m][k][n][l];
> Character[m][l][n][k]:Character[m][k][n][l];
> Character[n][l][m][k]:Character[m][k][n][l]; return Character[m][k][n][l] )
> else if (m=0, k=0, n=0, l=0) then return 1
> else if ((m=1, k=0, n=0, l=0) or ((m=0, k=0, n=1, l=0)) ) then return
> Fundamental1
> else if ((m=0, k=1, n=0, l=0) or ((m=0, k=0, n=0, l=1)) ) then return
> Fundamental2
> else if (m>0, k>0, n>0, l>0) then return (Character(m-1, k, n,
> l)*Character(m, k, n, l-1)-Character(0, 2*m-1, floor(k/2),
> 0)*Character(floor(k/2), 2*n, 0, 0))/(Character(m-1, k, n, l-1))
> else if (m>0, k>0, n>0, l=0) then return (Character(m-1, k, n,
> 0)*Character(m, k, n-1, 0)-Character(0, 2*m-1, floor(k/2),
> 0)*Character(floor(k/2), 2*n-1, 0, 0))/(Character(m-1, k, n-1, 0))
> else if (m>0, k>0, n=0, l=0) then return (Character(m-1, k, 0,
> 0)*Character(m, k-1, 0, 0)-Character(floor(k/2), 2*m-1, 0,
> 0)*Character(floor((k-1)/2), 0, 0, 0))/(Character(m-1, k-1, 0, 0))
> else if (m>0, k=0, n=0, l=0) then return (Character(m-1, 0, 0,
> 0)*Character(m-1, 0, 0, 0)-Character(0, 2*(m-1), 0, 0))/(Character(m-2, 0,
> 0, 0))
> else if (m=0, k>0, n=0, l=0) then return (Character(0, k-1, 0,
> 0)*Character(0, k-1, 0, 0)-Character(floor((k-1)/2), 0, 0,
> 0)*Character(floor(k/2), 0, 0, 0))/(Character(0, k-2, 0, 0))
> );
>
>
>
>
>
>
> 2012/11/23 Stavros Macrakis <macrakis at alum.mit.edu>
>
>> for i thru 100 do for j thru 100 do for k thru 100 do foo[i,j,k]: i+j+k;
>>
>> On my machine, this loop takes about 25 seconds, so another level of loop
>> will take about 40 minutes (and the array will be very large, maybe too
>> large).
>>
>> If you really want 100^4 elements, you will probably want to declare the
>> array (for both time and space efficiency -- undeclared arrays are
>> hasharrays) and compile any operations on it (for time efficiency). See ?
>> array, ? compile, and ? mode_declare.
>>
>> What are you trying to do? Do you really need a 100^4 dense array?
>>
>> -s
>>
>> On Thu, Nov 22, 2012 at 10:29 PM, Jianrong Li <lijr07 at gmail.com> wrote:
>>
>>> Dear all,
>>>
>>> I would like to define a multiple array:
>>>
>>> for m:0 thru 100 step 1 do
>>> for k:0 thru 100 step 1 do
>>> for n:0 thru 100 step 1 do
>>> for l:0 thru 100 step 1 do
>>> Character[m][k][n][l]:0;
>>>
>>> But it is not correct. How could I define the multiple array
>>> Character[m][k][n][l] in a correct way?
>>> Thank you very much.
>>>
>>> Best wishes,
>>> Jianrong.
>>>
>>> _______________________________________________
>>> Maxima mailing list
>>> Maxima at math.utexas.edu
>>> http://www.math.utexas.edu/mailman/listinfo/maxima
>>>
>>>
>>
>