From 6469b5ba0fdcccf6747ca10e4f988de56127d34e Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 27 Jan 2004 05:52:08 +0000 Subject: [PATCH] This version is complete up to 2.2.12, but lacks some diagrams. --- doc/mad-manual.xml | 231 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 228 insertions(+), 3 deletions(-) diff --git a/doc/mad-manual.xml b/doc/mad-manual.xml index b64979b..bc035e7 100644 --- a/doc/mad-manual.xml +++ b/doc/mad-manual.xml @@ -152,7 +152,8 @@ the original style in DocBook. (except for the capital thetas, which were typed capital Os with bars hand-drawn across them). The script-S used in the original as a base for subscripted labels has no ISO equivalent and has been transcribed as -a Greek letter sigma (&statement;). +a Greek letter sigma (&statement;). The script-N used at some +places in the original has been replaced by a script M, ℳ. Footnotes were tagged with asterisks in the original rather than being numbered. Section references to section numbers have been @@ -1522,10 +1523,234 @@ the transfer was made. In all cases, every reference to an expression E1 will involve its current value at the time of reference. Moreover, the variable V may have -its value changed at any time during the execution of the -scope. +its value changed at any time during the execution of the scope. In a +statement of the form (a), the value of V will be reset by the value +of the next E1 for the next computation of the +scope. In a statement of form (b), the current value of V will be +used for incrementing, testing, etc. + +Examples: + +(i) To evaluate the polynomial + cnxn + + cn-1xn+1 + ...+ + c1x + c0 using the + formula (...((cnx + + cn-1)x + cn-2)x + ...+ + c1)x + c0 (nested + multiplication), we may write the program: + + + INTEGER J,N + Y = 0 + THROUGH POLY, FOR J = N, -1, .L. 0 + POLY Y = X * Y + C(J) + + +(For the meaning of the statement INTEGER J,N see section 3.2). + +(ii) A Newton's Method solution (Xk+1 = +xk - +f(xk)/f'(xk)) of the +equation f(x) = cos x - x = 0 could be written as a single statement, +using the criterion "|f(x)| < ε and |xk - +xk+1| = +|f(xk)/f'(xk)| < | +ε " for stopping the iteration: + + + NEW THROUGH NEW, FOR X = X0, (COS.(X)-X)/(SIN.(X) + 1.), + 1 .ABS.(COS.(X) - (X) .L. EPSLON .AND. + 2 .ABS.(COSX.(X) - (X)/(SIN.(X) + 1.) ) .L. EPSLON + + +where X0 is the initial guess. + +(iii) If the transformation of the iteration variable is to be +performed within the scope of the iteration, one may use a zero +increment. E.g., if J is an integer variable, and the scope of the +iteration is to be performed for those multiples of 2 which are not +multiples of 5 and which are less than the value of the integer K, one +might write the iteration as follows: + + + THROUGH END, FOR J = 2, .GE. K + ... + ... + J = K J + 2 +END WHENEVER J .E. (J/5) * 5, J = J + 2 + + +(iv) A table-look-up procedure using an interation statement. +Suppose that a string of alphabetic (or numeric) characters (i.e., a +"sentence") has been decomposed into single characters stored in C(1), +C(2), ..., C(K), where K is the length of the string. Then the first +occurrence of a comma could be found as follows: + + +LOOK THROUGH LOOK, FOR I = 1, 1, C(I), .E. $, $ .OR. I .G. K + WHENEVER I .G. K, TRANSFER TO NOCOMA + + + +Nested Iteration Statements + + +As indicated in section 2.5, the "scope" of an iteration +statement is the block of statements designated for repeated +execution, indicated by ... below: + + + THROUGH END, FOR V = E1, E2, B + ... + ... +END ... + + +Some of the statements within the scope of an iteration may, +themselves, be iteration statements. However, if iteration statement +b is in the scope of iteration +a, then the scope of b must +be entirely within the scope of a. The following +diagrams represent some valid configurations: + +Here, although the scopes of a and +b both end on statement K, iteration +b is incremented and tested first. Therefore, +iteration b is completed before iteration +a is incremented: + +The following diagram represents an invalid configuration: + +When iteration statements occur in the scope of other iteration +statements, they are said to be "nested". The "nesting depth" of an +iteration statement is the number of iteration statements in whose +scope it appears. The nesting depth of an iteration may not exceed +50. For example: + +In example (5), iteration a has a nesting +depth 0, iteration b has nesting depth 1, and +iteration c has nesting depth 2. In example (3), +both b and c have nesting +depths of 1. + +There are no restrictions on jumping into or out of the +statements in the scope of an iteration. + + +Pause Statement + + +PAUSE NO. n + + +This statement indicates a breakpoint in the program, and it +causes the computer to stop in such a way that the operator can +manually start it and automatically go on to the next statement in the +program. The number n is an octal integer containing up to 5 digits, +which will be displayed on the computer console for the operator to +note when the computer stops, thus indicating the point in the program +at which the stop occurred. + + +Function Statement + +Normally, the value of a function will occur as part of an expression, as in the statement: + + + programlisting>Z = COS.(X)/SIN.(X + 2.) + + +Certain functions, however, may stand alone as separate +statements, as a statement calling for the sorting of a list, etc. +This would appear as: + + +EXECUTE LSORT.(ARRAY, MAP, N) + + +(See section 3.8 for definition of functions). Here ARRAY, MAP, +N are the "arguments" of the function (subroutine) LSORT. Arguments +and parentheses may be omitted in an EXECUTE statement if the function +has no arguments. + + +Error Return Statement + +Provision is made for including an error return in function +definition programs (see section 3.8). The form of the statement is +simply: + + +ERROR RETURN + + +(An example of its use is shown near the end of subsection +3.8.3). + +In order to use it in a function evaluation, the last +(right-most) argument of the function must be the label of a statement +or a variable in statement label mode, whose value is the label of a +statement to which a transfer is made in case the ERROR RETURN +statement is executed. + +Even though an error return has been provided in the definition +of a function, in the use of the function the last argument may be +omitted. If it is omitted, execution of the ERROR RETURN statement +will cause control to be transferred to the operating system in which +the translated program is imbedded, with an error indication. + + +End of program Statement + +This statement has the form: END OF PROGRAM. + + +This statement must be the last statement in the program, both +physically (i.e., the last card) and in the sequence of computation. +Execution of this statement will transfer control to the operating +system in which the translated program is imbedded. An alternate way +of terminating a program - i.e., returning to the operating system - +is to attempt to execute an input statement when the data has been +exhausted. +Function return + + +FUNCTION RETURN ℳ + + +This statement is used in a function definition to indicate a +return to the calling program. ℳ is an expression whose value is to +be the output of this function considered as a single valued function. +ℳ need not be specified if outputs are specified in the argument list +(see section 3.8). + + +Entry to a function + +Entry points to a function being defined are indicated by + + +ENTRY TO ℳ + + +where ℳ is the name of this entry (see section 3.8). + + + + + + + + + + -- 2.43.0