File: maxima_24.html

package info (click to toggle)
maxima 5.47.0-9
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 193,104 kB
  • sloc: lisp: 434,678; fortran: 14,665; tcl: 10,990; sh: 4,577; makefile: 2,763; ansic: 447; java: 328; python: 262; perl: 201; xml: 60; awk: 28; sed: 15; javascript: 2
file content (703 lines) | stat: -rw-r--r-- 33,568 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
<head>
<title>Maxima 5.47.0 Manual: Functions and Variables for Arrays</title>

<meta name="description" content="Maxima 5.47.0 Manual: Functions and Variables for Arrays">
<meta name="keywords" content="Maxima 5.47.0 Manual: Functions and Variables for Arrays">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="maxima_toc.html#Top" rel="start" title="Top">
<link href="maxima_423.html#Function-and-Variable-Index" rel="index" title="Function and Variable Index">
<link href="maxima_toc.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="maxima_23.html#Arrays" rel="up" title="Arrays">
<link href="maxima_25.html#Structures" rel="next" title="Structures">
<link href="maxima_23.html#Arrays" rel="previous" title="Arrays">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
body {color: black; background: white;  margin-left: 8%; margin-right: 13%;
      font-family: "FreeSans", sans-serif}
h1 {font-size: 150%; font-family: "FreeSans", sans-serif}
h2 {font-size: 125%; font-family: "FreeSans", sans-serif}
h3 {font-size: 100%; font-family: "FreeSans", sans-serif}
a[href] {color: rgb(0,0,255); text-decoration: none;}
a[href]:hover {background: rgb(220,220,220);}
div.textbox {border: solid; border-width: thin; padding-top: 1em;
    padding-bottom: 1em; padding-left: 2em; padding-right: 2em}
div.titlebox {border: none; padding-top: 1em; padding-bottom: 1em;
    padding-left: 2em; padding-right: 2em; background: rgb(200,255,255);
    font-family: sans-serif}
div.synopsisbox {
    border: none; padding-top: 1em; padding-bottom: 1em; padding-left: 2em;
    padding-right: 2em; background: rgb(255,220,255);}
pre.example {border: 1px solid rgb(180,180,180); padding-top: 1em;
    padding-bottom: 1em; padding-left: 1em; padding-right: 1em;
    background-color: rgb(238,238,255)}
div.spacerbox {border: none; padding-top: 2em; padding-bottom: 2em}
div.image {margin: 0; padding: 1em; text-align: center}
div.categorybox {border: 1px solid gray; padding-top: 1em; padding-bottom: 1em;
    padding-left: 1em; padding-right: 1em; background: rgb(247,242,220)}
img {max-width:80%; max-height: 80%; display: block; margin-left: auto; margin-right: auto}

-->
</style>

<link rel="icon" href="figures/favicon.ico">
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6>"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
</head>

<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Functions-and-Variables-for-Arrays"></a>
<div class="header">
<p>
Previous: <a href="maxima_23.html#Arrays" accesskey="p" rel="previous">Arrays</a>, Up: <a href="maxima_23.html#Arrays" accesskey="u" rel="up">Arrays</a> &nbsp; [<a href="maxima_toc.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="maxima_423.html#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Functions-and-Variables-for-Arrays-1"></a>
<h4 class="subsection">5.5.1 Functions and Variables for Arrays</h4>

<a name="array"></a><a name="Item_003a-Arrays_002fdeffn_002farray"></a><dl>
<dt><a name="index-array"></a>Function: <strong>array</strong> <em><br>&nbsp;&nbsp;&nbsp;&nbsp;<tt>array</tt> (<var>name</var>, <var>dim_1</var>, &hellip;, <var>dim_n</var>) <br>&nbsp;&nbsp;&nbsp;&nbsp;<tt>array</tt> (<var>name</var>, <var>type</var>, <var>dim_1</var>, &hellip;, <var>dim_n</var>) <br>&nbsp;&nbsp;&nbsp;&nbsp;<tt>array</tt> ([<var>name_1</var>, &hellip;, <var>name_m</var>], <var>dim_1</var>, &hellip;, <var>dim_n</var>)</em></dt>
<dd>
<p>Creates an <em>n</em>-dimensional array.  <em>n</em> may be less than or equal to 5.
The subscripts for the <em>i</em>&rsquo;th dimension are the integers running from 0 to
<var>dim_i</var>.
</p>
<p><code>array (<var>name</var>, <var>dim_1</var>, ..., <var>dim_n</var>)</code> creates a general
array.
</p>
<p><code>array (<var>name</var>, <var>type</var>, <var>dim_1</var>, ..., <var>dim_n</var>)</code> creates
an array, with elements of a specified type.  <var>type</var> can be <code>fixnum</code>
for integers of limited size or <code>flonum</code> for floating-point numbers.
</p>
<p><code>array ([<var>name_1</var>, ..., <var>name_m</var>], <var>dim_1</var>, ..., <var>dim_n</var>)</code>
creates <em>m</em> arrays, all of the same dimensions.
</p>
<p>See also <code><a href="#arraymake">arraymake</a></code>, <code><a href="#arrayinfo">arrayinfo</a></code> and <code><a href="#make_005farray">make_array</a></code>.
</p>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-Arrays">Arrays</a>
&middot;</div></dd></dl>

<a name="arrayapply"></a><a name="Item_003a-Arrays_002fdeffn_002farrayapply"></a><dl>
<dt><a name="index-arrayapply"></a>Function: <strong>arrayapply</strong> <em>(<var>A</var>, [<var>i_1</var>, &hellip;, <var>i_n</var>])</em></dt>
<dd>
<p>Evaluates <code><var>A</var> [<var>i_1</var>, ..., <var>i_n</var>]</code>,
where <var>A</var> is an array and <var>i_1</var>, &hellip;, <var>i_n</var> are integers.
</p>
<p>This is reminiscent of <code><a href="maxima_170.html#apply">apply</a></code>, except the first argument is an array
instead of a function.
</p>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-Expressions">Expressions</a>
&middot;<a href="maxima_424.html#Category_003a-Arrays">Arrays</a>
&middot;</div></dd></dl>

<a name="arrayinfo"></a><a name="Item_003a-Arrays_002fdeffn_002farrayinfo"></a><dl>
<dt><a name="index-arrayinfo"></a>Function: <strong>arrayinfo</strong> <em>(<var>A</var>)</em></dt>
<dd>
<p>Returns information about the array <var>A</var>.
The argument <var>A</var> may be a declared array, a <code><a href="maxima_23.html#hashed-array">hashed array</a></code>,
a <code><a href="maxima_168.html#memoizing-function">memoizing function</a></code>, or a subscripted function.
</p>
<p>For declared arrays, <code>arrayinfo</code> returns a list comprising the atom
<code>declared</code>, the number of dimensions, and the size of each dimension.
The elements of the array, both bound and unbound, are returned by
<code><a href="#listarray">listarray</a></code>.
</p>
<p>For undeclared arrays (hashed arrays), <code>arrayinfo</code> returns a list
comprising the atom <code>hashed</code>, the number of subscripts,
and the subscripts of every element which has a value.
The values are returned by <code><a href="#listarray">listarray</a></code>.
</p>
<p>For <code><a href="maxima_168.html#memoizing-functions">memoizing functions</a></code>, <code>arrayinfo</code> returns a list comprising the atom
<code>hashed</code>, the number of subscripts,
and any subscript values for which there are stored function values.
The stored function values are returned by <code><a href="#listarray">listarray</a></code>.
</p>
<p>For subscripted functions, <code>arrayinfo</code> returns a list comprising the atom
<code>hashed</code>, the number of subscripts,
and any subscript values for which there are lambda expressions.
The lambda expressions are returned by <code><a href="#listarray">listarray</a></code>.
</p>
<p>See also <code><a href="#listarray">listarray</a></code>.
</p>
<p>Examples:
</p>
<p><code>arrayinfo</code> and <code><a href="#listarray">listarray</a></code> applied to a declared array.
</p>
<div class="example">
<pre class="example">(%i1) array (aa, 2, 3);
(%o1)                          aa
</pre><pre class="example">(%i2) aa [2, 3] : %pi;
(%o2)                          %pi
</pre><pre class="example">(%i3) aa [1, 2] : %e;
(%o3)                          %e
</pre><pre class="example">(%i4) arrayinfo (aa);
(%o4)                 [declared, 2, [2, 3]]
</pre><pre class="example">(%i5) listarray (aa);
(%o5) [#####, #####, #####, #####, #####, #####, %e, #####, 
                                        #####, #####, #####, %pi]
</pre></div>

<p><code>arrayinfo</code> and <code><a href="#listarray">listarray</a></code> applied to an undeclared array (<code><a href="maxima_23.html#hashed-array">hashed array</a></code>.).
</p>
<div class="example">
<pre class="example">(%i1) bb [FOO] : (a + b)^2;
                                   2
(%o1)                       (b + a)
</pre><pre class="example">(%i2) bb [BAR] : (c - d)^3;
                                   3
(%o2)                       (c - d)
</pre><pre class="example">(%i3) arrayinfo (bb);
(%o3)               [hashed, 1, [BAR], [FOO]]
</pre><pre class="example">(%i4) listarray (bb);
                              3         2
(%o4)                 [(c - d) , (b + a) ]
</pre></div>

<p><code>arrayinfo</code> and <code><a href="#listarray">listarray</a></code> applied to a <code><a href="maxima_168.html#memoizing-function">memoizing function</a></code>.
</p>
<div class="example">
<pre class="example">(%i1) cc [x, y] := y / x;
                                     y
(%o1)                      cc     := -
                             x, y    x
</pre><pre class="example">(%i2) cc [u, v];
                                v
(%o2)                           -
                                u
</pre><pre class="example">(%i3) cc [4, z];
                                z
(%o3)                           -
                                4
</pre><pre class="example">(%i4) arrayinfo (cc);
(%o4)              [hashed, 2, [4, z], [u, v]]
</pre><pre class="example">(%i5) listarray (cc);
                              z  v
(%o5)                        [-, -]
                              4  u
</pre></div>


<p>Using <code>arrayinfo</code> in order to convert an undeclared array to a declared array:
</p>
<div class="example">
<pre class="example">(%i1) for i:0 thru 10 do a[i]:i^2$
</pre><pre class="example">(%i2) indices:map(first,rest(rest(arrayinfo(a))));
(%o2)          [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
</pre><pre class="example">(%i3) array(A,fixnum,length(indices)-1)$
(%i4) fillarray(A,map(lambda([x],a[x]),indices))$
</pre><pre class="example">(%i5) listarray(A);
(%o5)       [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
</pre></div>

<p><code>arrayinfo</code> and <code><a href="#listarray">listarray</a></code> applied to a subscripted function.
</p>
<div class="example">
<pre class="example">(%i1) dd [x] (y) := y ^ x;
                                     x
(%o1)                     dd (y) := y
                            x
</pre><pre class="example">(%i2) dd [a + b];
                                    b + a
(%o2)                  lambda([y], y     )
</pre><pre class="example">(%i3) dd [v - u];
                                    v - u
(%o3)                  lambda([y], y     )
</pre><pre class="example">(%i4) arrayinfo (dd);
(%o4)             [hashed, 1, [b + a], [v - u]]
</pre><pre class="example">(%i5) listarray (dd);
                         b + a                v - u
(%o5)      [lambda([y], y     ), lambda([y], y     )]
</pre></div>

<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-Arrays">Arrays</a>
&middot;</div></dd></dl>

<a name="arraymake"></a><a name="Item_003a-Arrays_002fdeffn_002farraymake"></a><dl>
<dt><a name="index-arraymake"></a>Function: <strong>arraymake</strong> <em>(<var>A</var>, [<var>i_1</var>, &hellip;, <var>i_n</var>])</em></dt>
<dd>
<p>Returns the expression <code><var>A</var>[<var>i_1</var>, ..., <var>i_n</var>]</code>.
The result is an unevaluated array reference.
</p>
<p><code>arraymake</code> is reminiscent of <code><a href="maxima_170.html#funmake">funmake</a></code>, except the return value
is an unevaluated array reference instead of an unevaluated function call.
</p>
<p>Examples:
</p><div class="example">
<pre class="example">(%i1) arraymake (A, [1]);
(%o1)                          A
                                1
</pre><pre class="example">(%i2) arraymake (A, [k]);
(%o2)                          A
                                k
</pre><pre class="example">(%i3) arraymake (A, [i, j, 3]);
(%o3)                       A
                             i, j, 3
</pre><pre class="example">(%i4) array (A, fixnum, 10);
(%o4)                           A
</pre><pre class="example">(%i5) fillarray (A, makelist (i^2, i, 1, 11));
(%o5)                           A
</pre><pre class="example">(%i6) arraymake (A, [5]);
(%o6)                          A
                                5
</pre><pre class="example">(%i7) ''%;
(%o7)                          36
</pre><pre class="example">(%i8) L : [a, b, c, d, e];
(%o8)                    [a, b, c, d, e]
</pre><pre class="example">(%i9) arraymake ('L, [n]);
(%o9)                          L
                                n
</pre><pre class="example">(%i10) ''%, n = 3;
(%o10)                          c
</pre><pre class="example">(%i11) A2 : make_array (fixnum, 10);
(%o11)        {Lisp Array: #(0 0 0 0 0 0 0 0 0 0)}
</pre><pre class="example">(%i12) fillarray (A2, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
(%o12)        {Lisp Array: #(1 2 3 4 5 6 7 8 9 10)}
</pre><pre class="example">(%i13) arraymake ('A2, [8]);
(%o13)                         A2
                                 8
</pre><pre class="example">(%i14) ''%;
(%o14)                          9
</pre></div>

<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-Expressions">Expressions</a>
&middot;<a href="maxima_424.html#Category_003a-Arrays">Arrays</a>
&middot;</div></dd></dl>

<a name="arrays"></a><a name="Item_003a-Arrays_002fdefvr_002farrays"></a><dl>
<dt><a name="index-arrays"></a>System variable: <strong>arrays</strong></dt>
<dd><p>Default value: <code>[]</code>
</p>
<p><code>arrays</code> is a list of arrays that have been allocated.
These comprise arrays declared by <code><a href="#array">array</a></code>, <code><a href="maxima_23.html#hashed-arrays">hashed arrays</a></code> that can be
constructed by implicit definition (assigning something to an element that isn&rsquo;t yet
declared as a list or an array),
and <code><a href="maxima_168.html#memoizing-functions">memoizing functions</a></code> defined by <code>:=</code> and <code><a href="maxima_170.html#define">define</a></code>.
Arrays defined by <code><a href="#make_005farray">make_array</a></code> are not included.
</p>
<p>See also
<code><a href="#array">array</a></code>, <code><a href="#arrayapply">arrayapply</a></code>, <code><a href="#arrayinfo">arrayinfo</a></code>,<!-- /@w -->
<code><a href="#arraymake">arraymake</a></code>, <code><a href="#fillarray">fillarray</a></code>, <code><a href="#listarray">listarray</a></code>, and
<code><a href="#rearray">rearray</a></code>.
</p>
<p>Examples:
</p>
<div class="example">
<pre class="example">(%i1) array (aa, 5, 7);
(%o1)                          aa
</pre><pre class="example">(%i2) bb [FOO] : (a + b)^2;
                                   2
(%o2)                       (b + a)
</pre><pre class="example">(%i3) cc [x] := x/100;
                                   x
(%o3)                      cc  := ---
                             x    100
</pre><pre class="example">(%i4) dd : make_array ('any, 7);
(%o4)     {Lisp Array: #(NIL NIL NIL NIL NIL NIL NIL)}
</pre><pre class="example">(%i5) arrays;
(%o5)                     [aa, bb, cc]
</pre></div>

<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-Arrays">Arrays</a>
&middot;<a href="maxima_424.html#Category_003a-Global-variables">Global variables</a>
&middot;</div></dd></dl>

<a name="arraysetapply"></a><a name="Item_003a-Arrays_002fdeffn_002farraysetapply"></a><dl>
<dt><a name="index-arraysetapply"></a>Function: <strong>arraysetapply</strong> <em>(<var>A</var>, [<var>i_1</var>, &hellip;, <var>i_n</var>], <var>x</var>)</em></dt>
<dd>
<p>Assigns <var>x</var> to <code><var>A</var>[<var>i_1</var>, ..., <var>i_n</var>]</code>,
where <var>A</var> is an array and <var>i_1</var>, &hellip;, <var>i_n</var> are integers.
</p>
<p><code>arraysetapply</code> evaluates its arguments.
</p>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-Expressions">Expressions</a>
&middot;<a href="maxima_424.html#Category_003a-Arrays">Arrays</a>
&middot;</div></dd></dl>

<a name="fillarray"></a><a name="Item_003a-Arrays_002fdeffn_002ffillarray"></a><dl>
<dt><a name="index-fillarray"></a>Function: <strong>fillarray</strong> <em>(<var>A</var>, <var>B</var>)</em></dt>
<dd>
<p>Fills array <var>A</var> from <var>B</var>, which is a list or an array.
</p>
<p>If a specific type was declared for <var>A</var> when it was created,
it can only be filled with elements of that same type;
it is an error if an attempt is made to copy an element of a different type.
</p>
<p>If the dimensions of the arrays <var>A</var> and <var>B</var> are
different, <var>A</var> is filled in row-major order.  If there are not enough
elements in <var>B</var> the last element is used to fill out the
rest of <var>A</var>.  If there are too many, the remaining ones are ignored.
</p>
<p><code>fillarray</code> returns its first argument.
</p>
<p>Examples:
</p>
<p>Create an array of 9 elements and fill it from a list.
</p>
<div class="example">
<pre class="example">(%i1) array (a1, fixnum, 8);
(%o1)                          a1
</pre><pre class="example">(%i2) listarray (a1);
(%o2)              [0, 0, 0, 0, 0, 0, 0, 0, 0]
</pre><pre class="example">(%i3) fillarray (a1, [1, 2, 3, 4, 5, 6, 7, 8, 9]);
(%o3)                          a1
</pre><pre class="example">(%i4) listarray (a1);
(%o4)              [1, 2, 3, 4, 5, 6, 7, 8, 9]
</pre></div>

<p>When there are too few elements to fill the array,
the last element is repeated.
When there are too many elements,
the extra elements are ignored.
</p>
<div class="example">
<pre class="example">(%i1) a2 : make_array (fixnum, 8);
(%o1)           {Lisp Array: #(0 0 0 0 0 0 0 0)}
</pre><pre class="example">(%i2) fillarray (a2, [1, 2, 3, 4, 5]);
(%o2)           {Lisp Array: #(1 2 3 4 5 5 5 5)}
</pre><pre class="example">(%i3) fillarray (a2, [4]);
(%o3)           {Lisp Array: #(4 4 4 4 4 4 4 4)}
</pre><pre class="example">(%i4) fillarray (a2, makelist (i, i, 1, 100));
(%o4)           {Lisp Array: #(1 2 3 4 5 6 7 8)}
</pre></div>

<p>Multiple-dimension arrays are filled in row-major order.
</p>
<div class="example">
<pre class="example">(%i1) a3 : make_array (fixnum, 2, 5);
(%o1)      {Lisp Array: #2A((0 0 0 0 0) (0 0 0 0 0))}
</pre><pre class="example">(%i2) fillarray (a3, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
(%o2)      {Lisp Array: #2A((1 2 3 4 5) (6 7 8 9 10))}
</pre><pre class="example">(%i3) a4 : make_array (fixnum, 5, 2);
(%o3)   {Lisp Array: #2A((0 0) (0 0) (0 0) (0 0) (0 0))}
</pre><pre class="example">(%i4) fillarray (a4, a3);
(%o4)   {Lisp Array: #2A((1 2) (3 4) (5 6) (7 8) (9 10))}
</pre></div>

<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-Arrays">Arrays</a>
&middot;</div></dd></dl>

<a name="listarray"></a><a name="Item_003a-Arrays_002fdeffn_002flistarray"></a><dl>
<dt><a name="index-listarray"></a>Function: <strong>listarray</strong> <em>(<var>A</var>)</em></dt>
<dd>
<p>Returns a list of the elements of the array <var>A</var>.
The argument <var>A</var> may be an array, an undeclared array (<code><a href="maxima_23.html#hashed-array">hashed array</a></code>),
a <code><a href="maxima_168.html#memoizing-function">memoizing function</a></code>, or a subscripted function.
</p>
<p>Elements are listed in row-major order.
That is, elements are sorted according to the first index, then according to
the second index, and so on.  The sorting order of index values is the same as
the order established by <code><a href="maxima_33.html#orderless">orderless</a></code>.
</p>
<p>For undeclared arrays (<code><a href="maxima_23.html#hashed-arrays">hashed arrays</a></code>), <code><a href="maxima_168.html#memoizing-functions">memoizing functions</a></code>, and subscripted functions,
the elements correspond to the index values returned by <code><a href="#arrayinfo">arrayinfo</a></code>.
</p>
<p>Unbound elements of general arrays (that is, not <code>fixnum</code> and not
<code>flonum</code>) are returned as <code>#####</code>.
Unbound elements of <code>fixnum</code> or <code>flonum</code> arrays
are returned as 0 or 0.0, respectively.
Unbound elements of hashed arrays, <code><a href="maxima_168.html#memoizing-functions">memoizing functions</a></code>,
and subscripted functions are not returned.
</p>
<p>Examples:
</p>
<p><code>listarray</code> and <code><a href="#arrayinfo">arrayinfo</a></code> applied to a declared array.
</p>
<div class="example">
<pre class="example">(%i1) array (aa, 2, 3);
(%o1)                          aa
</pre><pre class="example">(%i2) aa [2, 3] : %pi;
(%o2)                          %pi
</pre><pre class="example">(%i3) aa [1, 2] : %e;
(%o3)                          %e
</pre><pre class="example">(%i4) listarray (aa);
(%o4) [#####, #####, #####, #####, #####, #####, %e, #####, 
                                        #####, #####, #####, %pi]
</pre><pre class="example">(%i5) arrayinfo (aa);
(%o5)                 [declared, 2, [2, 3]]
</pre></div>

<p><code>listarray</code> and <code><a href="#arrayinfo">arrayinfo</a></code> applied to an undeclared array (<code><a href="maxima_23.html#hashed-array">hashed array</a></code>).
</p>
<div class="example">
<pre class="example">(%i1) bb [FOO] : (a + b)^2;
                                   2
(%o1)                       (b + a)
</pre><pre class="example">(%i2) bb [BAR] : (c - d)^3;
                                   3
(%o2)                       (c - d)
</pre><pre class="example">(%i3) listarray (bb);
                              3         2
(%o3)                 [(c - d) , (b + a) ]
</pre><pre class="example">(%i4) arrayinfo (bb);
(%o4)               [hashed, 1, [BAR], [FOO]]
</pre></div>

<p><code>listarray</code> and <code><a href="#arrayinfo">arrayinfo</a></code> applied to a <code><a href="maxima_168.html#memoizing-function">memoizing function</a></code>.
</p>
<div class="example">
<pre class="example">(%i1) cc [x, y] := y / x;
                                     y
(%o1)                      cc     := -
                             x, y    x
</pre><pre class="example">(%i2) cc [u, v];
                                v
(%o2)                           -
                                u
</pre><pre class="example">(%i3) cc [4, z];
                                z
(%o3)                           -
                                4
</pre><pre class="example">(%i4) listarray (cc);
                              z  v
(%o4)                        [-, -]
                              4  u
</pre><pre class="example">(%i5) arrayinfo (cc);
(%o5)              [hashed, 2, [4, z], [u, v]]
</pre></div>

<p><code>listarray</code> and <code><a href="#arrayinfo">arrayinfo</a></code> applied to a subscripted function.
</p>
<div class="example">
<pre class="example">(%i1) dd [x] (y) := y ^ x;
                                     x
(%o1)                     dd (y) := y
                            x
</pre><pre class="example">(%i2) dd [a + b];
                                    b + a
(%o2)                  lambda([y], y     )
</pre><pre class="example">(%i3) dd [v - u];
                                    v - u
(%o3)                  lambda([y], y     )
</pre><pre class="example">(%i4) listarray (dd);
                         b + a                v - u
(%o4)      [lambda([y], y     ), lambda([y], y     )]
</pre><pre class="example">(%i5) arrayinfo (dd);
(%o5)             [hashed, 1, [b + a], [v - u]]
</pre></div>

<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-Arrays">Arrays</a>
&middot;</div></dd></dl>


<a name="make_005farray"></a><a name="Item_003a-Arrays_002fdeffn_002fmake_005farray"></a><dl>
<dt><a name="index-make_005farray"></a>Function: <strong>make_array</strong> <em>(<var>type</var>, <var>dim_1</var>, &hellip;, <var>dim_n</var>)</em></dt>
<dd>
<p>Creates and returns a Lisp array.  <var>type</var> may
be <code>any</code>, <code>flonum</code>, <code>fixnum</code>, <code>hashed</code> or 
<code>functional</code>.
There are <em>n</em> indices,
and the <em>i</em>&rsquo;th index runs from 0 to <em><var>dim_i</var> - 1</em>.
</p>
<p>The advantage of <code>make_array</code> over <code><a href="#array">array</a></code> is that the return value
doesn&rsquo;t have a name, and once a pointer to it goes away, it will also go away.
For example, if <code>y: make_array (...)</code> then <code>y</code> points to an object 
which takes up space, but after <code>y: false</code>, <code>y</code> no longer
points to that object, so the object can be garbage collected.
</p>

<p>Examples:
</p>
<div class="example">
<pre class="example">(%i1) A1 : make_array (fixnum, 10);
(%o1)         {Lisp Array: #(0 0 0 0 0 0 0 0 0 0)}
</pre><pre class="example">(%i2) A1 [8] : 1729;
(%o2)                         1729
</pre><pre class="example">(%i3) A1;
(%o3)        {Lisp Array: #(0 0 0 0 0 0 0 0 1729 0)}
</pre><pre class="example">(%i4) A2 : make_array (flonum, 10);
(%o4) {Lisp Array: #(0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0)}
</pre><pre class="example">(%i5) A2 [2] : 2.718281828;
(%o5)                      2.718281828
</pre><pre class="example">(%i6) A2;
(%o6) 
 {Lisp Array: #(0.0 0.0 2.718281828 0.0 0.0 0.0 0.0 0.0 0.0 0.0)}
</pre><pre class="example">(%i7) A3 : make_array (any, 10);
(%o7) {Lisp Array: #(NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)}
</pre><pre class="example">(%i8) A3 [4] : x - y - z;
(%o8)                     (- z) - y + x
</pre><pre class="example">(%i9) A3;
(%o9) {Lisp Array: #(NIL NIL NIL NIL
               ((MPLUS SIMP) $X ((MTIMES SIMP) -1 $Y) ((MTIMES S\
IMP) -1 $Z))
               NIL NIL NIL NIL NIL)}
</pre><pre class="example">(%i10) A4 : make_array (fixnum, 2, 3, 5);
(%o10) {Lisp Array: #3A(((0 0 0 0 0) (0 0 0 0 0) (0 0 0 0 0))
                 ((0 0 0 0 0) (0 0 0 0 0) (0 0 0 0 0)))}
</pre><pre class="example">(%i11) fillarray (A4, makelist (i, i, 1, 2*3*5));
(%o11) {Lisp Array: #3A(((1 2 3 4 5) (6 7 8 9 10) (11 12 13 14 1\
5))
                 ((16 17 18 19 20) (21 22 23 24 25) (26 27 28 29\
 30)))}
</pre><pre class="example">(%i12) A4 [0, 2, 1];
(%o12)                         12
</pre></div>

<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-Arrays">Arrays</a>
&middot;</div></dd></dl>


<a name="rearray"></a><a name="Item_003a-Arrays_002fdeffn_002frearray"></a><dl>
<dt><a name="index-rearray"></a>Function: <strong>rearray</strong> <em>(<var>A</var>, <var>dim_1</var>, &hellip;, <var>dim_n</var>)</em></dt>
<dd>
<p>Changes the dimensions of an array.
The new array will be filled with the elements of the old one in
row-major order.  If the old array was too small, 
the remaining elements are filled with
<code>false</code>, <code>0.0</code> or <code>0</code>,
depending on the type of the array.  The type of the array cannot be
changed.
</p>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-Arrays">Arrays</a>
&middot;</div></dd></dl>

<a name="remarray"></a><a name="Item_003a-Arrays_002fdeffn_002fremarray"></a><dl>
<dt><a name="index-remarray"></a>Function: <strong>remarray</strong> <em><br>&nbsp;&nbsp;&nbsp;&nbsp;<tt>remarray</tt> (<var>A_1</var>, &hellip;, <var>A_n</var>) <br>&nbsp;&nbsp;&nbsp;&nbsp;<tt>remarray</tt> (all)</em></dt>
<dd>
<p>Removes arrays and array associated functions and frees the storage occupied.
The arguments may be declared arrays, <code><a href="maxima_23.html#hashed-arrays">hashed arrays</a></code>, array
functions, and subscripted functions.
</p>
<p><code>remarray (all)</code> removes all items in the global list <code><a href="#arrays">arrays</a></code>.
</p>
<p>It may be necessary to use this function if it is
desired to clear the cache of a <code><a href="maxima_168.html#memoizing-function">memoizing function</a></code>.
</p>
<p><code>remarray</code> returns the list of arrays removed.
</p>
<p><code>remarray</code> quotes its arguments.
</p>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-Arrays">Arrays</a>
&middot;</div></dd></dl>

<a name="subvar"></a><a name="Item_003a-Arrays_002fdeffn_002fsubvar"></a><dl>
<dt><a name="index-subvar"></a>Function: <strong>subvar</strong> <em>(<var>x</var>, <var>i</var>)</em></dt>
<dd>
<p>Evaluates the subscripted expression <code><var>x</var>[<var>i</var>]</code>.
</p>
<p><code>subvar</code> evaluates its arguments.
</p>
<p><code>arraymake (<var>x</var>, [<var>i</var>])</code> constructs the expression
<code><var>x</var>[<var>i</var>]</code>, but does not evaluate it.
</p>
<p>Examples:
</p>
<div class="example">
<pre class="example">(%i1) x : foo $
(%i2) i : 3 $
</pre><pre class="example">(%i3) subvar (x, i);
(%o3)                         foo
                                 3
</pre><pre class="example">(%i4) foo : [aa, bb, cc, dd, ee]$
</pre><pre class="example">(%i5) subvar (x, i);
(%o5)                          cc
</pre><pre class="example">(%i6) arraymake (x, [i]);
(%o6)                         foo
                                 3
</pre><pre class="example">(%i7) ''%;
(%o7)                          cc
</pre></div>

<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-Expressions">Expressions</a>
&middot;<a href="maxima_424.html#Category_003a-Arrays">Arrays</a>
&middot;</div></dd></dl>


<a name="subvarp"></a><a name="Item_003a-Arrays_002fdeffn_002fsubvarp"></a><dl>
<dt><a name="index-subvarp"></a>Function: <strong>subvarp</strong> <em>(<var>expr</var>)</em></dt>
<dd>
<p>Returns <code>true</code> if <var>expr</var> is a subscripted variable, for example
<code>a[i]</code>.
</p>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-Predicate-functions">Predicate functions</a>
&middot;</div></dd></dl>

<a name="use_005ffast_005farrays"></a><a name="Item_003a-Arrays_002fdefvr_002fuse_005ffast_005farrays"></a><dl>
<dt><a name="index-use_005ffast_005farrays"></a>Option variable: <strong>use_fast_arrays</strong></dt>
<dd><p>Default value: <code>false</code>
</p>
<p>When <code>use_fast_arrays</code> is <code>true</code>,
arrays declared by <code>array</code> are values instead of properties,
and undeclared arrays (<code><a href="maxima_23.html#hashed-arrays">hashed arrays</a></code>) are implemented as Lisp hashed arrays.
</p>
<p>When <code>use_fast_arrays</code> is <code>false</code>,
arrays declared by <code>array</code> are properties,
and undeclared arrays are implemented with Maxima&rsquo;s own hashed array implementation.
</p>
<p>Note that the code <code>use_fast_arrays</code> switches to is not necessarily faster
than the default one; Arrays created by <code><a href="#make_005farray">make_array</a></code> are not affected by
<code>use_fast_arrays</code>.
</p>
<p>See also <code><a href="#translate_005ffast_005farrays">translate_fast_arrays</a></code>.
</p>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-Arrays">Arrays</a>
&middot;<a href="maxima_424.html#Category_003a-Global-flags">Global flags</a>
&middot;</div></dd></dl>

<a name="translate_005ffast_005farrays"></a><a name="Item_003a-Arrays_002fdefvr_002ftranslate_005ffast_005farrays"></a><dl>
<dt><a name="index-translate_005ffast_005farrays"></a>Option variable: <strong>translate_fast_arrays</strong></dt>
<dd><p>Default value: <code>false</code>
</p>
<p>When <code>translate_fast_arrays</code> is <code>true</code>,
the Maxima-to-Lisp translator generates code that assumes arrays are values instead of properties,
as if <code>use_fast_arrays</code> were <code>true</code>.
</p>
<p>When <code>translate_fast_arrays</code> is <code>false</code>,
the Maxima-to-Lisp translator generates code that assumes arrays are properties,
as if <code>use_fast_arrays</code> were <code>false</code>.
</p>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-Arrays">Arrays</a>
&middot;<a href="maxima_424.html#Category_003a-Translation-flags-and-variables">Translation flags and variables</a>
&middot;</div></dd></dl>
<a name="Item_003a-defstruct_002fnode_002fStructures"></a><hr>
<div class="header">
<p>
Previous: <a href="maxima_23.html#Arrays" accesskey="p" rel="previous">Arrays</a>, Up: <a href="maxima_23.html#Arrays" accesskey="u" rel="up">Arrays</a> &nbsp; [<a href="maxima_toc.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="maxima_423.html#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>