File: Arrays.texi

package info (click to toggle)
maxima 5.21.1-2squeeze
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 94,928 kB
  • ctags: 43,849
  • sloc: lisp: 298,974; fortran: 14,666; perl: 14,325; tcl: 10,494; sh: 4,052; makefile: 2,975; ansic: 471; awk: 24; sed: 7
file content (873 lines) | stat: -rw-r--r-- 23,947 bytes parent folder | download
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
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873

@menu
* Functions and Variables for Arrays::  
@end menu

@node Functions and Variables for Arrays,  , Arrays, Arrays
@section Functions and Variables for Arrays

@deffn {Function} array (@var{name}, @var{dim_1}, ..., @var{dim_n})
@deffnx {Function} array (@var{name}, @var{type}, @var{dim_1}, ..., @var{dim_n})
@deffnx {Function} array ([@var{name_1}, ..., @var{name_m}], @var{dim_1}, ..., @var{dim_n})

Creates an @math{n}-dimensional array.  
@math{n} may be less than or equal to 5.
The subscripts for
the @math{i}'th dimension are the integers running from 0 to @var{dim_i}.  

@code{array (@var{name}, @var{dim_1}, ..., @var{dim_n})} creates a general array.

@code{array (@var{name}, @var{type}, @var{dim_1}, ..., @var{dim_n})} creates
an array, with elements of a specified type.
@var{type} can be @code{fixnum} for
integers of limited size or @code{flonum} for floating-point numbers.

@code{array ([@var{name_1}, ..., @var{name_m}], @var{dim_1}, ..., @var{dim_n})}
creates @math{m} arrays, all of the same dimensions.
@c SAME TYPE AS WELL ??

@c THIS DISCUSSION OF UNDECLARED ARRAYS REALLY WANTS TO BE SOMEWHERE ELSE
If the user assigns to a subscripted variable before declaring the
corresponding array, an undeclared array is created.
Undeclared arrays, otherwise known as hashed arrays (because hash
coding is done on the subscripts), are more general than declared
arrays.  The user does not declare their maximum size, and they grow
dynamically by hashing as more elements are assigned values.  The
subscripts of undeclared arrays need not even be numbers.  However,
unless an array is rather sparse, it is probably more efficient to
declare it when possible than to leave it undeclared.  The @code{array}
function can be used to transform an undeclared array into a declared
array.
@c HOW DOES ONE CHANGE AN UNDECLARED ARRAY INTO A DECLARED ARRAY EXACTLY ??

@opencatbox
@category{Arrays}
@closecatbox
@end deffn

@deffn {Function} arrayapply (@var{A}, [@var{i_1}, ..., @var{i_n}])
Evaluates @code{@var{A} [@var{i_1}, ..., @var{i_n}]},
where @var{A} is an array and @var{i_1}, ..., @var{i_n} are integers.

This is reminiscent of @code{apply}, except the first argument is an array instead of a function.

@opencatbox
@category{Expressions} @category{Arrays}
@closecatbox
@end deffn

@deffn {Function} arrayinfo (@var{A})
Returns information about the array @var{A}.
The argument @var{A} may be a declared array, an undeclared (hashed) array,
an array function, or a subscripted function.

For declared arrays, @code{arrayinfo} returns a list
comprising the atom @code{declared}, the number of dimensions, and the size of each dimension.
The elements of the array, both bound and unbound, are returned by @code{listarray}.

For undeclared arrays (hashed arrays),
@code{arrayinfo} returns a list comprising the atom @code{hashed}, the number of subscripts,
and the subscripts of every element which has a value.
The values are returned by @code{listarray}.

For array functions,
@code{arrayinfo} returns a list comprising the atom @code{hashed}, the number of subscripts,
and any subscript values for which there are stored function values.
The stored function values are returned by @code{listarray}.

For subscripted functions,
@code{arrayinfo} returns a list comprising the atom @code{hashed}, the number of subscripts,
and any subscript values for which there are lambda expressions.
The lambda expressions are returned by @code{listarray}.

Examples:

@code{arrayinfo} and @code{listarray} applied to a declared array.

@c ===beg===
@c array (aa, 2, 3);
@c aa [2, 3] : %pi;
@c aa [1, 2] : %e;
@c arrayinfo (aa);
@c listarray (aa);
@c ===end===
@example
@group
(%i1) array (aa, 2, 3);
(%o1)                          aa
@end group
@group
(%i2) aa [2, 3] : %pi;
(%o2)                          %pi
@end group
@group
(%i3) aa [1, 2] : %e;
(%o3)                          %e
@end group
@group
(%i4) arrayinfo (aa);
(%o4)                 [declared, 2, [2, 3]]
@end group
@group
(%i5) listarray (aa);
(%o5) [#####, #####, #####, #####, #####, #####, %e, #####, 
                                        #####, #####, #####, %pi]
@end group
@end example

@code{arrayinfo} and @code{listarray} applied to an undeclared (hashed) array.

@c ===beg===
@c bb [FOO] : (a + b)^2;
@c bb [BAR] : (c - d)^3;
@c arrayinfo (bb);
@c listarray (bb);
@c ===end===
@example
@group
(%i1) bb [FOO] : (a + b)^2;
                                   2
(%o1)                       (b + a)
@end group
@group
(%i2) bb [BAR] : (c - d)^3;
                                   3
(%o2)                       (c - d)
@end group
@group
(%i3) arrayinfo (bb);
(%o3)               [hashed, 1, [BAR], [FOO]]
@end group
@group
(%i4) listarray (bb);
                              3         2
(%o4)                 [(c - d) , (b + a) ]
@end group
@end example

@code{arrayinfo} and @code{listarray} applied to an array function.

@c ===beg===
@c cc [x, y] := y / x;
@c cc [u, v];
@c cc [4, z];
@c arrayinfo (cc);
@c listarray (cc);
@c ===end===
@example
@group
(%i1) cc [x, y] := y / x;
                                     y
(%o1)                      cc     := -
                             x, y    x
@end group
@group
(%i2) cc [u, v];
                                v
(%o2)                           -
                                u
@end group
@group
(%i3) cc [4, z];
                                z
(%o3)                           -
                                4
@end group
@group
(%i4) arrayinfo (cc);
(%o4)              [hashed, 2, [4, z], [u, v]]
@end group
@group
(%i5) listarray (cc);
                              z  v
(%o5)                        [-, -]
                              4  u
@end group
@end example

@code{arrayinfo} and @code{listarray} applied to a subscripted function.

@c ===beg===
@c dd [x] (y) := y ^ x;
@c dd [a + b];
@c dd [v - u];
@c arrayinfo (dd);
@c listarray (dd);
@c ===end===
@example
@group
(%i1) dd [x] (y) := y ^ x;
                                     x
(%o1)                     dd (y) := y
                            x
@end group
@group
(%i2) dd [a + b];
                                    b + a
(%o2)                  lambda([y], y     )
@end group
@group
(%i3) dd [v - u];
                                    v - u
(%o3)                  lambda([y], y     )
@end group
@group
(%i4) arrayinfo (dd);
(%o4)             [hashed, 1, [b + a], [v - u]]
@end group
@group
(%i5) listarray (dd);
                         b + a                v - u
(%o5)      [lambda([y], y     ), lambda([y], y     )]
@end group
@end example

@opencatbox
@category{Arrays}
@closecatbox
@end deffn

@deffn {Function} arraymake (@var{A}, [@var{i_1}, ..., @var{i_n}])
Returns the expression @code{@var{A}[@var{i_1}, ..., @var{i_n}]}.
The result is an unevaluated array reference.

@code{arraymake} is reminiscent of @code{funmake},
except the return value is an unevaluated array reference
instead of an unevaluated function call.

Examples:
@c ===beg===
@c arraymake (A, [1]);
@c arraymake (A, [k]);
@c arraymake (A, [i, j, 3]);
@c array (A, fixnum, 10);
@c fillarray (A, makelist (i^2, i, 1, 11));
@c arraymake (A, [5]);
@c ''%;
@c L : [a, b, c, d, e];
@c arraymake ('L, [n]);
@c ''%, n = 3;
@c A2 : make_array (fixnum, 10);
@c fillarray (A2, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
@c arraymake ('A2, [8]);
@c ''%;
@c ===end===
@example
@group
(%i1) arraymake (A, [1]);
(%o1)                          A
                                1
@end group
@group
(%i2) arraymake (A, [k]);
(%o2)                          A
                                k
@end group
@group
(%i3) arraymake (A, [i, j, 3]);
(%o3)                       A
                             i, j, 3
@end group
@group
(%i4) array (A, fixnum, 10);
(%o4)                           A
@end group
@group
(%i5) fillarray (A, makelist (i^2, i, 1, 11));
(%o5)                           A
@end group
@group
(%i6) arraymake (A, [5]);
(%o6)                          A
                                5
@end group
@group
(%i7) ''%;
(%o7)                          36
@end group
@group
(%i8) L : [a, b, c, d, e];
(%o8)                    [a, b, c, d, e]
@end group
@group
(%i9) arraymake ('L, [n]);
(%o9)                          L
                                n
@end group
@group
(%i10) ''%, n = 3;
(%o10)                          c
@end group
@group
(%i11) A2 : make_array (fixnum, 10);
(%o11)          @{Array:  #(0 0 0 0 0 0 0 0 0 0)@}
@end group
@group
(%i12) fillarray (A2, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
(%o12)          @{Array:  #(1 2 3 4 5 6 7 8 9 10)@}
@end group
@group
(%i13) arraymake ('A2, [8]);
(%o13)                         A2
                                 8
@end group
@group
(%i14) ''%;
(%o14)                          9
@end group
@end example

@opencatbox
@category{Expressions} @category{Arrays}
@closecatbox
@end deffn

@defvr {System variable} arrays
Default value: @code{[]}

@code{arrays} is a list of arrays that have been allocated.
These comprise arrays declared by @code{array},
hashed arrays constructed by implicit definition (assigning something to an array element),
and array functions defined by @code{:=} and @code{define}.
Arrays defined by @code{make_array} are not included.

See also
@code{array}, @code{arrayapply}, @code{arrayinfo}, @code{arraymake}, 
@code{fillarray}, @code{listarray}, and @code{rearray}.
@c IS THIS AN EXHAUSTIVE LIST ??

Examples:

@c ===beg===
@c array (aa, 5, 7);
@c bb [FOO] : (a + b)^2;
@c cc [x] := x/100;
@c dd : make_array ('any, 7);
@c arrays;
@c ===end===
@example
@group
(%i1) array (aa, 5, 7);
(%o1)                          aa
@end group
@group
(%i2) bb [FOO] : (a + b)^2;
                                   2
(%o2)                       (b + a)
@end group
@group
(%i3) cc [x] := x/100;
                                   x
(%o3)                      cc  := ---
                             x    100
@end group
@group
(%i4) dd : make_array ('any, 7);
(%o4)       @{Array:  #(NIL NIL NIL NIL NIL NIL NIL)@}
@end group
@group
(%i5) arrays;
(%o5)                     [aa, bb, cc]
@end group
@end example

@opencatbox
@category{Arrays} @category{Global variables}
@closecatbox

@end defvr

@deffn {Function} bashindices (@var{expr})
Transforms the expression @var{expr} by giving each
summation and product a unique index. This gives @code{changevar} greater
precision when it is working with summations or products.  The form of
the unique index is @code{j@var{number}}. The quantity @var{number} is determined by
referring to @code{gensumnum}, which can be changed by the user.  For
example, @code{gensumnum:0$} resets it.

@opencatbox
@category{Sums and products}
@closecatbox
@end deffn

@deffn {Function} fillarray (@var{A}, @var{B})
Fills array @var{A} from @var{B}, which is a list or an array.

If a specific type was declared for @var{A} 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.

If the dimensions of the arrays @var{A} and @var{B} are
different, @var{A} is filled in row-major order.  If there are not enough
elements in @var{B} the last element is used to fill out the
rest of @var{A}.  If there are too many, the remaining ones are ignored.

@code{fillarray} returns its first argument.

Examples:

Create an array of 9 elements and fill it from a list.
@c ===beg===
@c array (a1, fixnum, 8);
@c listarray (a1);
@c fillarray (a1, [1, 2, 3, 4, 5, 6, 7, 8, 9]);
@c listarray (a1);
@c ===end===
@example
@group
(%i1) array (a1, fixnum, 8);
(%o1)                          a1
@end group
@group
(%i2) listarray (a1);
(%o2)              [0, 0, 0, 0, 0, 0, 0, 0, 0]
@end group
@group
(%i3) fillarray (a1, [1, 2, 3, 4, 5, 6, 7, 8, 9]);
(%o3)                          a1
@end group
@group
(%i4) listarray (a1);
(%o4)              [1, 2, 3, 4, 5, 6, 7, 8, 9]
@end group
@end example

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.
@c ===beg===
@c a2 : make_array (fixnum, 8);
@c fillarray (a2, [1, 2, 3, 4, 5]);
@c fillarray (a2, [4]);
@c fillarray (a2, makelist (i, i, 1, 100));
@c ===end===
@example
@group
(%i1) a2 : make_array (fixnum, 8);
(%o1)             @{Array:  #(0 0 0 0 0 0 0 0)@}
@end group
@group
(%i2) fillarray (a2, [1, 2, 3, 4, 5]);
(%o2)             @{Array:  #(1 2 3 4 5 5 5 5)@}
@end group
@group
(%i3) fillarray (a2, [4]);
(%o3)             @{Array:  #(4 4 4 4 4 4 4 4)@}
@end group
@group
(%i4) fillarray (a2, makelist (i, i, 1, 100));
(%o4)             @{Array:  #(1 2 3 4 5 6 7 8)@}
@end group
@end example

Multple-dimension arrays are filled in row-major order.
@c ===beg===
@c a3 : make_array (fixnum, 2, 5);
@c fillarray (a3, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
@c a4 : make_array (fixnum, 5, 2);
@c fillarray (a4, a3);
@c ===end===
@example
@group
(%i1) a3 : make_array (fixnum, 2, 5);
(%o1)        @{Array:  #2A((0 0 0 0 0) (0 0 0 0 0))@}
@end group
@group
(%i2) fillarray (a3, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
(%o2)        @{Array:  #2A((1 2 3 4 5) (6 7 8 9 10))@}
@end group
@group
(%i3) a4 : make_array (fixnum, 5, 2);
(%o3)     @{Array:  #2A((0 0) (0 0) (0 0) (0 0) (0 0))@}
@end group
@group
(%i4) fillarray (a4, a3);
(%o4)     @{Array:  #2A((1 2) (3 4) (5 6) (7 8) (9 10))@}
@end group
@end example

@opencatbox
@category{Arrays}
@closecatbox
@end deffn

@deffn {Function} listarray (@var{A})
Returns a list of the elements of the array @var{A}.
The argument @var{A} may be a declared array, an undeclared (hashed) array,
an array function, or a subscripted function.

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{orderless}.

For undeclared arrays, array functions, and subscripted functions,
the elements correspond to the index values returned by @code{arrayinfo}.

Unbound elements of declared general arrays (that is, not @code{fixnum} and not @code{flonum})
are returned as @code{#####}.
Unbound elements of declared @code{fixnum} or @code{flonum} arrays
are returned as 0 or 0.0, respectively.
Unbound elements of undeclared arrays, array functions,
and subscripted functions are not returned.

Examples:

@code{listarray} and @code{arrayinfo} applied to a declared array.

@c ===beg===
@c array (aa, 2, 3);
@c aa [2, 3] : %pi;
@c aa [1, 2] : %e;
@c listarray (aa);
@c arrayinfo (aa);
@c ===end===
@example
@group
(%i1) array (aa, 2, 3);
(%o1)                          aa
@end group
@group
(%i2) aa [2, 3] : %pi;
(%o2)                          %pi
@end group
@group
(%i3) aa [1, 2] : %e;
(%o3)                          %e
@end group
@group
(%i4) listarray (aa);
(%o4) [#####, #####, #####, #####, #####, #####, %e, #####, 
                                        #####, #####, #####, %pi]
@end group
@group
(%i5) arrayinfo (aa);
(%o5)                 [declared, 2, [2, 3]]
@end group
@end example

@code{listarray} and @code{arrayinfo} applied to an undeclared (hashed) array.

@c ===beg===
@c bb [FOO] : (a + b)^2;
@c bb [BAR] : (c - d)^3;
@c listarray (bb);
@c arrayinfo (bb);
@c ===end===
@example
@group
(%i1) bb [FOO] : (a + b)^2;
                                   2
(%o1)                       (b + a)
@end group
@group
(%i2) bb [BAR] : (c - d)^3;
                                   3
(%o2)                       (c - d)
@end group
@group
(%i3) listarray (bb);
                              3         2
(%o3)                 [(c - d) , (b + a) ]
@end group
@group
(%i4) arrayinfo (bb);
(%o4)               [hashed, 1, [BAR], [FOO]]
@end group
@end example

@code{listarray} and @code{arrayinfo} applied to an array function.

@c ===beg===
@c cc [x, y] := y / x;
@c cc [u, v];
@c cc [4, z];
@c listarray (cc);
@c arrayinfo (cc);
@c ===end===
@example
@group
(%i1) cc [x, y] := y / x;
                                     y
(%o1)                      cc     := -
                             x, y    x
@end group
@group
(%i2) cc [u, v];
                                v
(%o2)                           -
                                u
@end group
@group
(%i3) cc [4, z];
                                z
(%o3)                           -
                                4
@end group
@group
(%i4) listarray (cc);
                              z  v
(%o4)                        [-, -]
                              4  u
@end group
@group
(%i5) arrayinfo (cc);
(%o5)              [hashed, 2, [4, z], [u, v]]
@end group
@end example

@code{listarray} and @code{arrayinfo} applied to a subscripted function.

@c ===beg===
@c dd [x] (y) := y ^ x;
@c dd [a + b];
@c dd [v - u];
@c listarray (dd);
@c arrayinfo (dd);
@c ===end===
@example
@group
(%i1) dd [x] (y) := y ^ x;
                                     x
(%o1)                     dd (y) := y
                            x
@end group
@group
(%i2) dd [a + b];
                                    b + a
(%o2)                  lambda([y], y     )
@end group
@group
(%i3) dd [v - u];
                                    v - u
(%o3)                  lambda([y], y     )
@end group
@group
(%i4) listarray (dd);
                         b + a                v - u
(%o4)      [lambda([y], y     ), lambda([y], y     )]
@end group
@group
(%i5) arrayinfo (dd);
(%o5)             [hashed, 1, [b + a], [v - u]]
@end group
@end example

@opencatbox
@category{Arrays}
@closecatbox
@end deffn

@c NEEDS CLARIFICATION
@deffn {Function} make_array (@var{type}, @var{dim_1}, ..., @var{dim_n})
Creates and returns a Lisp array.  @var{type} may
be @code{any}, @code{flonum}, @code{fixnum}, @code{hashed} or 
@code{functional}.
There are @math{n} indices,
and the @math{i}'th index runs from 0 to @math{@var{dim_i} - 1}.

The advantage of @code{make_array} over @code{array} is that the return value doesn't have a
name, and once a pointer to it goes away, it will also go away.
For example, if @code{y: make_array (...)} then @code{y} points to an object 
which takes up space, but after @code{y: false}, @code{y} no longer
points to that object, so the object can be garbage collected.  

@c 'FUNCTIONAL ARGUMENT IN MAKE_ARRAY APPEARS TO BE BROKEN
@c EVEN AFTER READING THE CODE (SRC/AR.LISP) I CAN'T TELL HOW THIS IS SUPPOSED TO WORK
@c COMMENTING OUT THIS STUFF TO PREVENT CONFUSION AND HEARTBREAK
@c RESTORE IT WHEN MAKE_ARRAY ('FUNCTIONAL, ...) IS FIXED
@c @code{y: make_array ('functional, 'f, 'hashed, 1)} - the second argument to
@c @code{make_array} in this case is the function to call to calculate array
@c elements, and the rest of the arguments are passed recursively to
@c @code{make_array} to generate the "memory" for the array function object.

Examples:
@c ===beg===
@c A1 : make_array (fixnum, 10);
@c A1 [8] : 1729;
@c A1;
@c A2 : make_array (flonum, 10);
@c A2 [2] : 2.718281828;
@c A2;
@c A3 : make_array (any, 10);
@c A3 [4] : x - y - z;
@c A3;
@c A4 : make_array (fixnum, 2, 3, 5);
@c fillarray (A4, makelist (i, i, 1, 2*3*5));
@c A4 [0, 2, 1];
@c ===end===
@example
@group
(%i1) A1 : make_array (fixnum, 10);
(%o1)           @{Array:  #(0 0 0 0 0 0 0 0 0 0)@}
@end group
@group
(%i2) A1 [8] : 1729;
(%o2)                         1729
@end group
@group
(%i3) A1;
(%o3)          @{Array:  #(0 0 0 0 0 0 0 0 1729 0)@}
@end group
@group
(%i4) A2 : make_array (flonum, 10);
(%o4) @{Array:  #(0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0)@}
@end group
@group
(%i5) A2 [2] : 2.718281828;
(%o5)                      2.718281828
@end group
@group
(%i6) A2;
(%o6) 
     @{Array:  #(0.0 0.0 2.718281828 0.0 0.0 0.0 0.0 0.0 0.0 0.0)@}
@end group
@group
(%i7) A3 : make_array (any, 10);
(%o7) @{Array:  #(NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)@}
@end group
@group
(%i8) A3 [4] : x - y - z;
(%o8)                      - z - y + x
@end group
@group
(%i9) A3;
(%o9) @{Array:  #(NIL NIL NIL NIL ((MPLUS SIMP) $X ((MTIMES SIMP)\
 -1 $Y) ((MTIMES SIMP) -1 $Z))
  NIL NIL NIL NIL NIL)@}
@end group
@group
(%i10) A4 : make_array (fixnum, 2, 3, 5);
(%o10) @{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)))@}
@end group
@group
(%i11) fillarray (A4, makelist (i, i, 1, 2*3*5));
(%o11) @{Array:  #3A(((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)))@}
@end group
@group
(%i12) A4 [0, 2, 1];
(%o12)                         12
@end group
@end example

@opencatbox
@category{Arrays}
@closecatbox
@end deffn

@c DOES THIS MODIFY A OR DOES IT CREATE A NEW ARRAY ??
@deffn {Function} rearray (@var{A}, @var{dim_1}, ..., @var{dim_n})
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{0.0} or @code{0},
depending on the type of the array.  The type of the array cannot be
changed.

@opencatbox
@category{Arrays}
@closecatbox
@end deffn

@deffn {Function} remarray (@var{A_1}, ..., @var{A_n})
@deffnx {Function} remarray (all)
Removes arrays and array associated
functions and frees the storage occupied.
The arguments may be declared arrays, undeclared (hashed) arrays, array functions, and subscripted functions.

@code{remarray (all)} removes all items in the global list @code{arrays}.

@c WHAT DOES THIS MEAN EXACTLY ??
It may be necessary to use this function if it is
desired to redefine the values in a hashed array.

@code{remarray} returns the list of arrays removed.

@opencatbox
@category{Arrays}
@closecatbox
@end deffn

@deffn {Function} subvar (@var{x}, @var{i})
Evaluates the subscripted expression @code{@var{x}[@var{i}]}.

@code{subvar} evaluates its arguments.

@code{arraymake (@var{x}, [@var{i}]} constructs the expression @code{@var{x}[@var{i}]},
but does not evaluate it.

Examples:

@c ===beg===
@c x : foo $
@c i : 3 $
@c subvar (x, i);
@c foo : [aa, bb, cc, dd, ee]$
@c subvar (x, i);
@c arraymake (x, [i]);
@c ''%;
@c ===end===
@example
(%i1) x : foo $
(%i2) i : 3 $
@group
(%i3) subvar (x, i);
(%o3)                         foo
                                 3
@end group
(%i4) foo : [aa, bb, cc, dd, ee]$
@group
(%i5) subvar (x, i);
(%o5)                          cc
@end group
@group
(%i6) arraymake (x, [i]);
(%o6)                         foo
                                 3
@end group
@group
(%i7) ''%;
(%o7)                          cc
@end group
@end example

@opencatbox
@category{Expressions} @category{Arrays}
@closecatbox
@end deffn

@c THIS IS REALLY CONFUSING
@defvr {Option variable} use_fast_arrays
- if @code{true} then only two types of arrays are recognized.  

1) The art-q array (t in Common Lisp) which may have several dimensions
indexed by integers, and may hold any Lisp or Maxima object as an
entry.  To construct such an array, enter @code{a:make_array(any,3,4);} 
then @code{a} will have as value, an array with twelve slots, and the 
indexing is zero based.

2) The Hash_table array which is the default type of array created if one
does @code{b[x+1]:y^2} (and @code{b} is not already an array, a list, or a
matrix -- if it were one of these an error would be caused since
@code{x+1} would not be a valid subscript for an art-q array, a list or
a matrix). Its indices (also known as keys) may be any object.  
It only takes one key at a time (@code{b[x+1,u]:y} would ignore the @code{u}). 
Referencing is done by @code{b[x+1] ==> y^2}.  Of course the key may be
a list, e.g. @code{b[[x+1,u]]:y} would be valid.  This is incompatible 
with the old Maxima hash arrays, but saves consing.

An advantage of storing the arrays as values of the symbol is that the
usual conventions about local variables of a function apply to arrays as
well.  The Hash_table type also uses less consing and is more efficient
than the old type of Maxima hashar.  To obtain consistent behaviour in
translated and compiled code set @code{translate_fast_arrays} to be
@code{true}.

@opencatbox
@category{Arrays} @category{Global flags}
@closecatbox

@end defvr