[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
25.1 Definitions for Arrays and Tables |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Creates an n-dimensional array. n may be less than or equal to 5. The subscripts for the i'th dimension are the integers running from 0 to dim_i.
array (name, dim_1, ..., dim_n)
creates a general array.
array (name, type, dim_1, ..., dim_n)
creates
an array, with elements of a specified type.
type can be fixnum
for
integers of limited size or flonum
for floating-point numbers.
array ([name_1, ..., name_m], dim_1, ..., dim_n)
creates m arrays, all of the same dimensions.
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 array
function can be used to transform an undeclared array into a declared
array.
Evaluates A [i_1, ..., i_n]
,
where A is an array and i_1, ..., i_n are integers.
This is reminiscent of apply
, except the first argument is an array instead of a function.
Returns a list of information about the array A. For
hashed arrays it returns a list of hashed
, the number of subscripts,
and the subscripts of every element which has a value. For declared
arrays it returns a list of declared
, the number of subscripts, and
the bounds that were given the the array
function when it was called
on A. Do example(arrayinfo);
for an example.
Returns the expression name [i_1, ..., i_n]
.
This is reminiscent of funmake
,
except the return value is an unevaluated array reference
instead of an unevaluated function call.
Default value: []
arrays
is a list of all the arrays that have been allocated,
both declared and undeclared.
See also
array
, arrayapply
, arrayinfo
, arraymake
,
fillarray
, listarray
, and rearray
.
Transforms the expression expr by giving each
summation and product a unique index. This gives changevar
greater
precision when it is working with summations or products. The form of
the unique index is jnumber
. The quantity number is determined by
referring to gensumnum
, which can be changed by the user. For
example, gensumnum:0$
resets it.
Fills array A from B, which is a list or an array.
If A is a floating-point (integer) array then B should be either a list of floating-point (integer) numbers or another floating-point (integer) array.
If the dimensions of the arrays are different A is filled in row-major order. If there are not enough elements in B the last element is used to fill out the rest of A. If there are too many the remaining ones are thrown away.
fillarray
returns its first argument.
Returns a list of the elements of a declared or
hashed array A. The order is row-major. Elements which are not yet
defined are represented by #####
.
Creates and returns a Lisp array. type may
be any
, flonum
, fixnum
, hashed
or
functional
.
There are n indices,
and the i'th index runs from 0 to dim_i - 1.
The advantage of make_array
over 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 y: make_array (...)
then y
points to an object
which takes up space, but after y: false
, y
no longer
points to that object, so the object can be garbage collected.
y: make_array ('functional, 'f, 'hashed, 1)
- the second argument to
make_array
in this case is the function to call to calculate array
elements, and the rest of the arguments are passed recursively to
make_array
to generate the "memory" for the array function object.
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
false
, 0.0
or 0
,
depending on the type of the array. The type of the array cannot be
changed.
Removes arrays and array associated functions and frees the storage occupied.
remarray (all)
removes all items in the global list arrays
.
It may be necessary to use this function if it is desired to redefine the values in a hashed array.
remarray
returns the list of arrays removed.
Evaluates the subscripted expression x[i]
.
subvar
evaluates its arguments.
arraymake (x, [i]
constructs the expression x[i]
,
but does not evaluate it.
Examples:
(%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 |
- if 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 a:make_array(any,3,4);
then 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 b[x+1]:y^2
(and b
is not already an array, a list, or a
matrix - if it were one of these an error would be caused since
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 (b[x+1,u]:y
would ignore the u
).
Referencing is done by b[x+1] ==> y^2
. Of course the key may be
a list, e.g. 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 translate_fast_arrays
to be
true
.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on March, 19 2006 using texi2html 1.76.