RATS 11.1
RATS 11.1

Instructions /

DIMENSION Instruction

Home Page

← Previous Next →

DIMENSION  array(dims)   (separate multiple arrays by blanks)

DIMENSION sets the sizes (dimensions) of arrays. You must introduce an array prior to dimensioning it. For convenience, you can also do the dimensioning on a DECLARE or LOCAL instruction.

 

Note that you don't have to dimension an array that's being created or set as a result of a matrix operation. For instance, if A=B*C, A will get its dimensions from the matrix multiply.

Parameters

array(dims)

The list of arrays you want to dimension, with the dimensions for each array listed in parentheses. You can dimension any number of arrays with a single instruction and the arrays dimensioned do not have to be of the same type.

Dimensioning fields

A dimensioning field has one of the forms:

 

name(dimension)

for one-dimensional arrays (VECTOR arrays)

name (dim1,dim2)

for the two-dimensional arrays: RECTANGULAR, and SYMMETRIC, and PACKED. This sets up an dim1 x dim2 matrix. (dim2 is ignored for SYMMETRIC or PACKED, since such matrices must be square).

The dimension expressions can be any integer-valued expression, not just constants.

Examples

compute n=6

declare rect  s1 s2

declare vector  v1

dimension v1(10) s1(n,3) s2(n^2+n,n+17)


declares and dimensions the arrays V1, S1, and S2. V1 is a 10-element VECTOR, S1 is a 6 by 3 RECTANGULAR and S2 is a 42 by 23 RECTANGULAR.


 

declare vector[rectangular] vv(10)

do i=1,10

  dim vv(i)(5,5)

end do i

 

When you have an array of arrays, as in this case, you must dimension each of the component arrays separately.

Notes

You can DIMENSION an array several times during a program, but re-dimensioning an existing array erases its previous contents. If you have an array which (possibly) needs to be extended without losing the original information, you might be better off using a LIST rather than a VECTOR.


 


Copyright © 2026 Thomas A. Doan