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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on September, 20 2006 by texi2html 1.76 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Many creative people <dev@texi2html.cvshome.org>
Send bugs and suggestions to <users@texi2html.cvshome.org>
-->
<head>
<title>Maxima Manual: 25. Arrays</title>
<meta name="description" content="Maxima Manual: 25. Arrays">
<meta name="keywords" content="Maxima Manual: 25. Arrays">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.76">
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
body
{
color: black;
background: white;
margin-left: 8%;
margin-right: 13%;
}
h1
{
margin-left: +8%;
font-size: 150%;
font-family: sans-serif
}
h2
{
font-size: 125%;
font-family: sans-serif
}
h3
{
font-size: 100%;
font-family: sans-serif
}
h2,h3,h4,h5,h6 { margin-left: +4%; }
div.textbox
{
border: solid;
border-width: thin;
/* width: 100%; */
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);
/*background: rgb(200,255,255); */
/* font-family: fixed */
}
pre.example
{
border: none;
padding-top: 1em;
padding-bottom: 1em;
padding-left: 1em;
padding-right: 1em;
background: rgb(247,242,180); /* kind of sandy */
/* background: rgb(200,255,255); */ /* sky blue */
font-family: "Lucida Console", monospace
}
div.spacerbox
{
border: none;
padding-top: 2em;
padding-bottom: 2em
}
div.image
{
margin: 0;
padding: 1em;
text-align: center;
}
-->
</style>
<link rel="icon" href="http://maxima.sourceforge.net/favicon.ico"/>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Arrays"></a>
<a name="SEC83"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="maxima_24.html#SEC82" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC84" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="maxima_24.html#SEC81" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_26.html#SEC85" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_72.html#SEC264" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 25. Arrays </h1>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC84">25.1 Definitions for Arrays</a></td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr size="6">
<a name="Definitions-for-Arrays"></a>
<a name="SEC84"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC83" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="maxima_26.html#SEC85" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC83" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_26.html#SEC85" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_72.html#SEC264" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 25.1 Definitions for Arrays </h2>
<dl>
<dt><u>Function:</u> <b>array</b><i> (<var>name</var>, <var>dim_1</var>, ..., <var>dim_n</var>)</i>
<a name="IDX735"></a>
</dt>
<dt><u>Function:</u> <b>array</b><i> (<var>name</var>, <var>type</var>, <var>dim_1</var>, ..., <var>dim_n</var>)</i>
<a name="IDX736"></a>
</dt>
<dt><u>Function:</u> <b>array</b><i> ([<var>name_1</var>, ..., <var>name_m</var>], <var>dim_1</var>, ..., <var>dim_n</var>)</i>
<a name="IDX737"></a>
</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>'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>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</code>
function can be used to transform an undeclared array into a declared
array.
</p>
</dd></dl>
<dl>
<dt><u>Function:</u> <b>arrayapply</b><i> (<var>A</var>, [<var>i_1</var>, ..., <var>i_n</var>])</i>
<a name="IDX738"></a>
</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>, ..., <var>i_n</var> are integers.
</p>
<p>This is reminiscent of <code>apply</code>, except the first argument is an array instead of a function.
</p>
</dd></dl>
<dl>
<dt><u>Function:</u> <b>arrayinfo</b><i> (<var>A</var>)</i>
<a name="IDX739"></a>
</dt>
<dd><p>Returns information about the array <var>A</var>.
The argument <var>A</var> may be a declared array, an undeclared (hashed) array,
an array function, 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>listarray</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>listarray</code>.
</p>
<p>For array 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 stored function values.
The stored function values are returned by <code>listarray</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>listarray</code>.
</p>
<p>Examples:
</p>
<p><code>arrayinfo</code> and <code>listarray</code> applied to a declared array.
</p>
<table><tr><td> </td><td><pre class="example">(%i1) array (aa, 2, 3);
(%o1) aa
(%i2) aa [2, 3] : %pi;
(%o2) %pi
(%i3) aa [1, 2] : %e;
(%o3) %e
(%i4) arrayinfo (aa);
(%o4) [declared, 2, [2, 3]]
(%i5) listarray (aa);
(%o5) [#####, #####, #####, #####, #####, #####, %e, #####,
#####, #####, #####, %pi]
</pre></td></tr></table>
<p><code>arrayinfo</code> and <code>listarray</code> applied to an undeclared (hashed) array.
</p>
<table><tr><td> </td><td><pre class="example">(%i1) bb [FOO] : (a + b)^2;
2
(%o1) (b + a)
(%i2) bb [BAR] : (c - d)^3;
3
(%o2) (c - d)
(%i3) arrayinfo (bb);
(%o3) [hashed, 1, [BAR], [FOO]]
(%i4) listarray (bb);
3 2
(%o4) [(c - d) , (b + a) ]
</pre></td></tr></table>
<p><code>arrayinfo</code> and <code>listarray</code> applied to an array function.
</p>
<table><tr><td> </td><td><pre class="example">(%i1) cc [x, y] := y / x;
y
(%o1) cc := -
x, y x
(%i2) cc [u, v];
v
(%o2) -
u
(%i3) cc [4, z];
z
(%o3) -
4
(%i4) arrayinfo (cc);
(%o4) [hashed, 2, [4, z], [u, v]]
(%i5) listarray (cc);
z v
(%o5) [-, -]
4 u
</pre></td></tr></table>
<p><code>arrayinfo</code> and <code>listarray</code> applied to a subscripted function.
</p>
<table><tr><td> </td><td><pre class="example">(%i1) dd [x] (y) := y ^ x;
x
(%o1) dd (y) := y
x
(%i2) dd [a + b];
b + a
(%o2) lambda([y], y )
(%i3) dd [v - u];
v - u
(%o3) lambda([y], y )
(%i4) arrayinfo (dd);
(%o4) [hashed, 1, [b + a], [v - u]]
(%i5) listarray (dd);
b + a v - u
(%o5) [lambda([y], y ), lambda([y], y )]
</pre></td></tr></table>
</dd></dl>
<dl>
<dt><u>Function:</u> <b>arraymake</b><i> (<var>name</var>, [<var>i_1</var>, ..., <var>i_n</var>])</i>
<a name="IDX740"></a>
</dt>
<dd><p>Returns the expression <code><var>name</var> [<var>i_1</var>, ..., <var>i_n</var>]</code>.
</p>
<p>This is reminiscent of <code>funmake</code>,
except the return value is an unevaluated array reference
instead of an unevaluated function call.
</p>
</dd></dl>
<dl>
<dt><u>System variable:</u> <b>arrays</b>
<a name="IDX741"></a>
</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>array</code>,
hashed arrays constructed by implicit definition (assigning something to an array element),
and array functions defined by <code>:=</code> and <code>define</code>.
Arrays defined by <code>make_array</code> are not included.
</p>
<p>See also
<code>array</code>, <code>arrayapply</code>, <code>arrayinfo</code>, <code>arraymake</code>,
<code>fillarray</code>, <code>listarray</code>, and <code>rearray</code>.
</p>
<p>Examples:
</p>
<table><tr><td> </td><td><pre class="example">(%i1) array (aa, 5, 7);
(%o1) aa
(%i2) bb [FOO] : (a + b)^2;
2
(%o2) (b + a)
(%i3) cc [x] := x/100;
x
(%o3) cc := ---
x 100
(%i4) dd : make_array ('any, 7);
(%o4) {Array: #(NIL NIL NIL NIL NIL NIL NIL)}
(%i5) arrays;
(%o5) [aa, bb, cc]
</pre></td></tr></table>
</dd></dl>
<dl>
<dt><u>Function:</u> <b>bashindices</b><i> (<var>expr</var>)</i>
<a name="IDX742"></a>
</dt>
<dd><p>Transforms the expression <var>expr</var> by giving each
summation and product a unique index. This gives <code>changevar</code> greater
precision when it is working with summations or products. The form of
the unique index is <code>j<var>number</var></code>. The quantity <var>number</var> is determined by
referring to <code>gensumnum</code>, which can be changed by the user. For
example, <code>gensumnum:0$</code> resets it.
</p>
</dd></dl>
<dl>
<dt><u>Function:</u> <b>fillarray</b><i> (<var>A</var>, <var>B</var>)</i>
<a name="IDX743"></a>
</dt>
<dd><p>Fills array <var>A</var> from <var>B</var>, which is a list or an array.
</p>
<p>If <var>A</var> is a
floating-point (integer) array then <var>B</var> should be
either a list of floating-point (integer) numbers or another
floating-point (integer) array.
</p>
<p>If the dimensions of the arrays 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 thrown
away.
</p>
<p><code>fillarray</code> returns its first argument.
</p>
</dd></dl>
<dl>
<dt><u>Function:</u> <b>listarray</b><i> (<var>A</var>)</i>
<a name="IDX744"></a>
</dt>
<dd><p>Returns a list of the elements of the array <var>A</var>.
The argument <var>A</var> may be a declared array, an undeclared (hashed) array,
an array function, 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>orderless</code>.
</p>
<p>For undeclared arrays, array functions, and subscripted functions,
the elements correspond to the index values returned by <code>arrayinfo</code>.
</p>
<p>Unbound elements of declared general arrays (that is, not <code>fixnum</code> and not <code>flonum</code>)
are returned as <code>#####</code>.
Unbound elements of declared <code>fixnum</code> or <code>flonum</code> arrays
are returned as 0 or 0.0, respectively.
Unbound elements of undeclared arrays, array functions,
and subscripted functions are not returned.
</p>
<p>Examples:
</p>
<p><code>listarray</code> and <code>arrayinfo</code> applied to a declared array.
</p>
<table><tr><td> </td><td><pre class="example">(%i1) array (aa, 2, 3);
(%o1) aa
(%i2) aa [2, 3] : %pi;
(%o2) %pi
(%i3) aa [1, 2] : %e;
(%o3) %e
(%i4) listarray (aa);
(%o4) [#####, #####, #####, #####, #####, #####, %e, #####,
#####, #####, #####, %pi]
(%i5) arrayinfo (aa);
(%o5) [declared, 2, [2, 3]]
</pre></td></tr></table>
<p><code>listarray</code> and <code>arrayinfo</code> applied to an undeclared (hashed) array.
</p>
<table><tr><td> </td><td><pre class="example">(%i1) bb [FOO] : (a + b)^2;
2
(%o1) (b + a)
(%i2) bb [BAR] : (c - d)^3;
3
(%o2) (c - d)
(%i3) listarray (bb);
3 2
(%o3) [(c - d) , (b + a) ]
(%i4) arrayinfo (bb);
(%o4) [hashed, 1, [BAR], [FOO]]
</pre></td></tr></table>
<p><code>listarray</code> and <code>arrayinfo</code> applied to an array function.
</p>
<table><tr><td> </td><td><pre class="example">(%i1) cc [x, y] := y / x;
y
(%o1) cc := -
x, y x
(%i2) cc [u, v];
v
(%o2) -
u
(%i3) cc [4, z];
z
(%o3) -
4
(%i4) listarray (cc);
z v
(%o4) [-, -]
4 u
(%i5) arrayinfo (cc);
(%o5) [hashed, 2, [4, z], [u, v]]
</pre></td></tr></table>
<p><code>listarray</code> and <code>arrayinfo</code> applied to a subscripted function.
</p>
<table><tr><td> </td><td><pre class="example">(%i1) dd [x] (y) := y ^ x;
x
(%o1) dd (y) := y
x
(%i2) dd [a + b];
b + a
(%o2) lambda([y], y )
(%i3) dd [v - u];
v - u
(%o3) lambda([y], y )
(%i4) listarray (dd);
b + a v - u
(%o4) [lambda([y], y ), lambda([y], y )]
(%i5) arrayinfo (dd);
(%o5) [hashed, 1, [b + a], [v - u]]
</pre></td></tr></table>
</dd></dl>
<dl>
<dt><u>Function:</u> <b>make_array</b><i> (<var>type</var>, <var>dim_1</var>, ..., <var>dim_n</var>)</i>
<a name="IDX745"></a>
</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>'th index runs from 0 to <em><var>dim_i</var> - 1</em>.
</p>
<p>The advantage of <code>make_array</code> over <code>array</code> 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 (...)</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>
</dd></dl>
<dl>
<dt><u>Function:</u> <b>rearray</b><i> (<var>A</var>, <var>dim_1</var>, ..., <var>dim_n</var>)</i>
<a name="IDX746"></a>
</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>
</dd></dl>
<dl>
<dt><u>Function:</u> <b>remarray</b><i> (<var>A_1</var>, ..., <var>A_n</var>)</i>
<a name="IDX747"></a>
</dt>
<dt><u>Function:</u> <b>remarray</b><i> (all)</i>
<a name="IDX748"></a>
</dt>
<dd><p>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.
</p>
<p><code>remarray (all)</code> removes all items in the global list <code>arrays</code>.
</p>
<p>It may be necessary to use this function if it is
desired to redefine the values in a hashed array.
</p>
<p><code>remarray</code> returns the list of arrays removed.
</p>
</dd></dl>
<dl>
<dt><u>Function:</u> <b>subvar</b><i> (<var>x</var>, <var>i</var>)</i>
<a name="IDX749"></a>
</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>
<table><tr><td> </td><td><pre class="example">(%i1) x : foo $
(%i2) i : 3 $
(%i3) subvar (x, i);
(%o3) foo
3
(%i4) foo : [aa, bb, cc, dd, ee]$
(%i5) subvar (x, i);
(%o5) cc
(%i6) arraymake (x, [i]);
(%o6) foo
3
(%i7) ''%;
(%o7) cc
</pre></td></tr></table>
</dd></dl>
<dl>
<dt><u>Option variable:</u> <b>use_fast_arrays</b>
<a name="IDX750"></a>
</dt>
<dd><p>- if <code>true</code> then only two types of arrays are recognized.
</p>
<p>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);</code>
then <code>a</code> will have as value, an array with twelve slots, and the
indexing is zero based.
</p>
<p>2) The Hash_table array which is the default type of array created if one
does <code>b[x+1]:y^2</code> (and <code>b</code> 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</code> 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</code> would ignore the <code>u</code>).
Referencing is done by <code>b[x+1] ==> y^2</code>. Of course the key may be
a list, e.g. <code>b[[x+1,u]]:y</code> would be valid. This is incompatible
with the old Maxima hash arrays, but saves consing.
</p>
<p>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</code> to be
<code>true</code>.
</p>
</dd></dl>
<hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC83" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="maxima_26.html#SEC85" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_72.html#SEC264" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<p>
<font size="-1">
This document was generated by <em>Robert Dodier</em> on <em>September, 20 2006</em> using <a href="http://texi2html.cvshome.org/"><em>texi2html 1.76</em></a>.
</font>
<br>
</p>
</body>
</html>
|