Sponsored links: Algebra eBooks
 

Help Index

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z

The Maxima on-line user's manual

Algebra Calculator

Search:

Make_array Calculator

Make_array

Function: make_array (<type>, <dim_1>, ..., <dim_n>) Creates and returns a Lisp array. <type> may be any, flonum, fixnum, hashed or functional. There are n indices, and the ith index runs from 0 to <dim_i> - 1.

The advantage of make_array over array is that the return value doesnt 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.

     Examples:
          (%i1) A1 : make_array (fixnum, 10);
          (%o1)           {Array:  #(0 0 0 0 0 0 0 0 0 0)}
          (%i2) A1 [8] : 1729;
          (%o2)                         1729
          (%i3) A1;
          (%o3)          {Array:  #(0 0 0 0 0 0 0 0 1729 0)}
          (%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)}
          (%i5) A2 [2] : 2.718281828;
          (%o5)                      2.718281828
          (%i6) A2;
          (%o6)
               {Array:  #(0.0 0.0 2.718281828 0.0 0.0 0.0 0.0 0.0 0.0 0.0)}
          (%i7) A3 : make_array (any, 10);
          (%o7) {Array:  #(NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)}
          (%i8) A3 [4] : x - y - z;
          (%o8)                      - z - y + x
          (%i9) A3;
          (%o9) {Array:  #(NIL NIL NIL NIL ((MPLUS SIMP) $X ((MTIMES SIMP)\
           -1 $Y) ((MTIMES SIMP) -1 $Z))
            NIL NIL NIL NIL NIL)}
          (%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)))}
          (%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)))}
          (%i12) A4 [0, 2, 1];
          (%o12)                         12

(%o1)                                true
(%i2) 

Make_array Example

Related Examples

array-disp-do

array( E,1000);

array(F,1000);

E[0]:0;

Calculate

array-plot2d-signum-sum
plot2d(q(x),[x,-5,5]);

q(x):=(signum(x)+1)*0.5;

plot2d(q(x),[x,-5,5]);

U0:2;

Calculate

array-do-if-listarray-plot2d-sin
plot2d([f,[discrete,pointx,pointy],[discrete,rx,ry]],[x,0,6.28],[style,lines,points,points],[point_type,circle,diamond],[legend,"sin(x)","",""]);

m:6;

array([rs,rsy],float,m);

i:0;

Calculate

array-arrayinfo-listarray

m : 2;

array(a, m, 1);

a [0,0] : 1;

Calculate

array-arrayinfo-listarray

array (P,3,1);

arrayinfo (P);

i:1;

Calculate

array-arrayinfo-listarray

array (P,3,1);

arrayinfo (P);

i:1;

Calculate

array-cos-do-expand-load-print

load(fft);

y(t):=cos(2*%pi*0.1*t);

array(ra, float, 31);

Calculate

array-arrays-make_array

array (aa, 5, 7);

bb [foo] : (a + b)^2;

cc [x] := x/100;

Calculate

array-listarray

array (P,3,1);

listarray (P);

P[0,0] : 1;

Calculate