1

使用 MAXIMA 我想在最大值中创建 11 个数组。我正在尝试这样的事情:

for n:1 step 1 while n<=11 do( for j:1 while j<=21 do( if i<j then aa[n][i,j]:i+j+n));

这编译得很好,但我不能按照我的意愿使用它。例如说我想要第 5 个数组中的值 2,2,我尝试以下但它不起作用:

aa[5][2,2];

任何帮助表示赞赏,本

4

1 回答 1

2

您的代码片段缺少对 i 的任何循环或对 i 的其他分配。

您可以考虑使用 'genmatrix' 构造一个矩阵,然后在 n 上循环以生成多个矩阵。例如:

foo : lambda ([i, j], if i < j then i + j + n else 0);
for n:1 thru 11 do aa[n] : genmatrix (foo, 21, 21);

然后我得到

aa[5][2, 2];
 => 0
aa[5][2, 3];
 => 10
grind (aa[10]);
 => matrix([0,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32],
   [0,0,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33],
   [0,0,0,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34],
   [0,0,0,0,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35],
   [0,0,0,0,0,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],
   [0,0,0,0,0,0,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],
   [0,0,0,0,0,0,0,25,26,27,28,29,30,31,32,33,34,35,36,37,38],
   [0,0,0,0,0,0,0,0,27,28,29,30,31,32,33,34,35,36,37,38,39],
   [0,0,0,0,0,0,0,0,0,29,30,31,32,33,34,35,36,37,38,39,40],
   [0,0,0,0,0,0,0,0,0,0,31,32,33,34,35,36,37,38,39,40,41],
   [0,0,0,0,0,0,0,0,0,0,0,33,34,35,36,37,38,39,40,41,42],
   [0,0,0,0,0,0,0,0,0,0,0,0,35,36,37,38,39,40,41,42,43],
   [0,0,0,0,0,0,0,0,0,0,0,0,0,37,38,39,40,41,42,43,44],
   [0,0,0,0,0,0,0,0,0,0,0,0,0,0,39,40,41,42,43,44,45],
   [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,41,42,43,44,45,46],
   [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,43,44,45,46,47],
   [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,45,46,47,48],
   [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,47,48,49],
   [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,49,50],
   [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,51],
   [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])$
于 2013-04-15T19:43:55.640 回答