GETMATRIX - dynamically allocate a matrix.

Usage:

B:
   matrix = getmatrix( m1, m2, m3, ... mn );
   rlsematrix( matrix, m1, m2, m3, ... mn );
C:
   void *getmatrix(int m1, ...);
   void rlsematrix(void *matrix, ...);

Where:

matrix
contains a pointer through which you can locate the memory allocated to the matrix.
m1, m2, m3, ..., mn
give the size of each dimension of the matrix.

Description:

GETMATRIX allocates storage space for a matrix of the specified dimensions. The size of the matrix is the product of the sizes of its dimensions.

As is usual when dealing with vectors of words, if a dimension is of size "n", then "n+1" words are allocated to obtain a zero origin vector whose highest subscript is "n".

GETMATRIX obtains this storage using GETVEC, and initializes a vector of pointers into "matrix", so that references to the elements of the various dimensions may be made in a natural way.

x = getmatrix(3,2,5);

allocates a 3 x 2 x 5 matrix.

x[3][2][4]

specifies one element from the matrix, and

x[1][2]

refers to a six element vector (0-5).

x[1]

refers to a three element (0-2) vector of pointers to vectors.

RLSEMATRIX is used to release a matrix of the given dimensions.

rlsematrix(x, 3, 2, 5);

releases the matrix "x" from the examples above. It is probably unwise to release only parts of a matrix.

Copyright © 1996, Thinkage Ltd.