From: Eric S. Raymond Date: Wed, 18 Feb 2004 04:37:47 +0000 (+0000) Subject: TAnother swction. X-Git-Tag: 1.0~92 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=5294ac5b837fe061ab9886696e5198b7fd0aee47;p=mad.git TAnother swction. --- diff --git a/doc/mad-manual.xml b/doc/mad-manual.xml index 4b078c5..54326aa 100644 --- a/doc/mad-manual.xml +++ b/doc/mad-manual.xml @@ -13,7 +13,8 @@ A"> B"> L"> -M"> +M"> +N"> S"> ]> @@ -2566,7 +2567,7 @@ are ignored and may contain any legitimate Hollerith characters. If a specification contains a Hollerith string of the form -nHa_1a_2...a_n, certain conventions are observed. (1) If the list is +nHa1a2...an, certain conventions are observed. (1) If the list is satisifed, but the next field specification is a Hollerith string, the string is transmitted, anyway. (2) On input, i.e., reading from cards, when a Hollerith string is encountered in the specification, @@ -2618,6 +2619,167 @@ the translator, and furnishes information to the reader of the program. Every card of the remark declaration must have an "R" in column 11. + +Mode Declaration + +All variables and function values are assumed to have the normal mode +unless declared otherwise. Any of the other modes may be specified as +the normal mode by writing the following declarations: + + +NORMAL MODE IS &scriptM; + + +where &scriptM; is one of the following phrases; INTEGER, BOOLEAN, STATEMENT +LABEL, FUNCTION NAME, or FLOATING POINT. Only one such declaration +may appear in a program and it is in effect for the whole program, no +matter where it occurs in the program. If a variable or function +value is to have a mode different from the normal mode then its modes +must be declared in a declaration of the following form: + + +&scriptM; V, L, ..., F., ..., BFN. + + +where &scriptM; is one of the phrases; INTEGER, BOOLEAN, STATEMENT LABEL, +FUNCTION NAME, or FLOATING POINT; for example, BOOLEAN +P,Q,DIGIT.TRUTH. Following &scriptM; is the list of variables and functions +whose values are to be of mode &scriptM;. A program may contain any number +of such mode declarations but a name may not be declared to be of two +different modes. + +All constants are automatically assigned modes by the translator +(see section 1.1). Other automatic assignments of modes are: + + +A name appearing in the statement label field is assigned +statement label mode (see section 1.3). + +A function name constant is assigned function name mode (see +section 1.4). + +A vector appearing as the dimension vector of some +array in a dimension declaration is assigned integer mode (see section +3.3). + +A vector which is preset by a vector values declaration is +assigned a mode consistent with the assigned values (see section 3.7). + + + + +Dimension Declaration + +Variables may be declared to be array variables, such as vectors or +matrices of various dimensions, rather than individual variables. + +Each array is stored in a region whose elements may be referred to by +means of a single subscript, such as A(0), A(1), B(16), etc. Even +elements of higher dimensional arrays may be referred to in this way +at any time. We shall call the subscript thus associated with each +element of an array its "linear subscript." If A is an array then the +name A is equivalent to A(0), e.e., the name A written without a +subscript is assumed to have a subscript of zero. + +Two dimensional matrices are stored internally by rows, i.e., an +m x n matrix will be stored in the order: a11, +a12, a13, ..., +a1n, a21, ..., +a2n, ... amn. In +general, matrices are stroed in the order determined by varying the +right-most subscript first, then the next right-most, etc. Thus, an m +x n x p x q matrix would be stored in the order: +a1111, a1112, ..., +a111q, a1121, +a1122, ... a112q, ..., +a11pq, a1211,..., +a1npq, ... amnpq. + +Elements of higher dimensional arrays may be referred to not only by +their linear subscripts but also by the usual matrix notation, such as +A(1,1), A(I,J), B(I+6,J/3+3). + +Although any number of dimension declarations may be used in a +program, as many variables as desired may be "declared" in any +dimension declaration. The declaration consists of the word +DIMENSION, followed by the variables to be declared. Each variable is +immediately followed by one or two arguments (separated by a comma) +enclosed in parentheses, as follows: + +The first argument is a positive integer constant, specifying the +largest linear subscript which an element of the array is expected to +assume during the execution of the program. The size of the region +allocated is this number plus one, regardless of whether the program +actually makes use of this amount or not. + +The second argument, given only for arrays with dimension n > 1, is +the name of the first element in the "dimension vector" for this +array. If this name is D(k) (k must be an integer constant), the +vactor D is automatically assigned integer mode. D may not be +declared to be other than integer. In addition, D must itself be +dimensioned, either by declaration or by presetting its values +(section 3.7) to have its largest linear subscript # k+n. Assuming +that elements of the array to be dimensioned are to be referred to as +A(I1, I2, In), the elements of the linear array D, i.e. D(k), D(k + +1), ...D(k + n), must be preset (or set during computation) to the +values + + + D(k) = n + D(k + 1) = the linear subscript which corresponds to A(1,1, ...1) - commonly set to 1 + D(k + 2) = current upper bound of I2 (i.e., the current highest value of I2 during the computation) + D(k + 3) = current upper bound of I3 + D(k + 4) = current upper bound of I4 + + +The lower bound of each subscript is assumed to be unity. + +Thus, in the statement: DIMENSION XA(400, V), YT(300, K(3)) where V(0) +=2,V(1) =6, v(2) =13, K(3) =3, K(4) =4, K(5) =8, and K(6) =9, the +variables XA and YT are designated as 2-dimensional and 3-dimensional +arrays respectively. Considering the array element XA(I,J), the range +of J may be expressed by 1 ≤ J ≤ 8 and 1 ≤ K ≤ 9. The +array XA will have a storage region of length 401 set aside for it, +e.g., XA(0), ...XA(400), and the 395 elements XA(6), XA(7), ..., +XA(400) may also be referred to as XA(1,1), XA(1,2), ...XA(31,5) +respectively. The matrix will be located at various places in the XA +region depending on the value of V(1) at the time a reference is made +ot a matrix element during execution of the program. Observe that +this ability to vary the location of the initial array element (i.e., +the array element with unit indices) within the linear array allows +the effective use of negative subscripts - in spite of the fact that +the defined ranges of the subscripts are positive. + +Similarly, the matrix YT will have 301 locations set aside for it, +although these do not all have to be used. The base element of YT, +i.e., YT(1,1, 1) will correspond to the element YT(4) since K(4) = 4. + +If the array is a vector, i.e., one-dimensional, a special convention +is adopted. Only the first argument is given to the DIMENSION +declaration. Thus, in the statement + + +DIMENSION V(10) + + +the array V is specified as consisting of the eleven elements V(0), +..., V(10). If a variable appears in more than one dimension +declaration, the highest linear subscript will be used; however, the +dimension vector must be the same in all occurrences. Negative +subscripts are not available for vectors. + +Dimensioning is automatic in two situations + +(a) In case a statement label vector, say L, is used (see section 1.3) +and n is the highest subscript used on L in the statement label field +(i.e., if L(m) appears then m # n), then n + 1 locations are reserved +for L. L may also appear in a dimension declaration in which case the +highest linear subscript is used. + +(b) If part of all of a linear array is set by a VECTOR VALUES +declaration the array need not appear in a dimension statement unless +the maximum linear subscript implied by the initial values is not +sufficiently high.