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-display2d-expand-false-plot2d
plot2d([[discrete, p],f(x)], [x,1,3.6], [style, points, lines],  [color, red, blue], [point_type, asterisk],  [legend, "data", "approximation"], [xlabel, "x"], [ylabel, "y"]);

p:[[1.3,0.25],[1.15,3...

display2d:false;

n:6;

Calculate

array-expand-plot2d
plot2d([[discrete, p],f(x)], [x,0,4], [style, points, lines],  [color, red, blue], [point_type, asterisk],  [legend, "data", "approximation"], [xlabel, "x"], [ylabel, "y"]);

p:[[0.4,0.3],[1.2,3.2...

n:6;

array (d, n, n);

Calculate

array

variables: 3;

array(x,3);

x*2;

Calculate

array-cos-random-sin

array(data,8,8,8);

for i: 0 thru 7 do f...

data;

Calculate

array-listarray

array (P,3,1);

array (Q,3,1);

P[0,0] : 1;

Calculate

array-listarray

array (a1, fixnum, 8);

listarray(a1);

Calculate

array-expand-plot2d
plot2d([[discrete, p],f(x)], [x,1,3.7], [style, points, lines],  [color, red, blue], [point_type, asterisk],  [legend, "data", "approximation"], [xlabel, "x"], [ylabel, "y"]);

p:[[1.3,0.25],[1.15,3...

n:6;

array (d, n, n);

Calculate

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

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

i:0;

f(x):=sin(x);

Calculate