From f1deed64e8b7b433ec457f247c6330a8d0afa37f Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 30 Jun 2004 00:46:19 +0000 Subject: [PATCH] First draft complete. --- doc/mad-manual.xml | 154 ++++++++++++++++++++++++++++++--------------- 1 file changed, 105 insertions(+), 49 deletions(-) diff --git a/doc/mad-manual.xml b/doc/mad-manual.xml index 7bbbb8e..be130e7 100644 --- a/doc/mad-manual.xml +++ b/doc/mad-manual.xml @@ -729,7 +729,8 @@ written in a single box to indicate the correspondence to a single statement. The question still remains: How does one communicate the -algorithm to the computer? A translator such as MAD is designed +algorithm to the computer? A translator such as +MADTranslator is designed according to the philosophy: Once the algorithm has been stated, as in a flow diagram, it should be presented to the computer directly in that form, or as near to it as possible. The "translator" then has @@ -963,13 +964,13 @@ flow diagram. -The first statement, labelled ST, causes a value for a,x, -and ε to be read into computer storage. A block of adjacent +The first statement, labelled ST, causes a value for +a,x, and ε to be read into computer storage. A block of adjacent storage location in the computer (a "vector") named ALPHA is -designated as containing a description of how the three -numbers were punched on the card. (This description – which -is the value of ALPHA – is described in a later statement; see -(9) below.) +designated as containing a description of how the three numbers were +punched on the card. Vector +(This description – which is the value of ALPHA – is +described in a later statement; see (9) below.) The second statement is a simple conditional which causes the statement labelled PRT to be the next one executed if a < @@ -999,14 +1000,16 @@ again if |f(x)| ≥ ε. Otherwise, (i.e., |f(x)| < ε), the next statement in sequence is executed. The PRINT statementPRINT - Statement causes three numbers - the current - values of a, x and ε to be printed. The arrangement and form of - the numbers on the printed page are controlled by the format - description which is the value of the vector named - ALPHA.Format +Statement causes three numbers - the current +values of a, x and ε to be printed. The arrangement and form of +the numbers on the printed page are controlled by the format +description which is the value of the vector named +ALPHA.Format The TRANSFER statement following causes the statement -labelled ST to be the next one performed. +labelled ST to be the next one performed. +TRANSFER Statement + The statement labelled PRT is the one executed immediately after the first statement whenever a < 1.0. This statement @@ -1018,7 +1021,8 @@ alphabetic information preceding thenumber; namely, the remark The next two statements following the last TRANSFER TO ST set the initial values of two vectors named ALPHA and BETA. -Although VECTOR VALUES statements can be used to preset vectors to +Although VECTOR VALUES statementsVECTOR VALUES +Statements can be used to preset vectors to specified numeric values, in both instances here the values are format descriptions. The strings of characters between the dollar signs (MAD quotation marks!) are to be taken @@ -1128,11 +1132,13 @@ discussed in Chapter II. -The second statement in the program causes the inout information, -properly labeled., to print out, preceded by the title "SOLUTION OF -CUBIC EQUATION". The appropriate alphabetic information is contained -in the format information which is t be found in the vecvtor TITLE, as -set by a VECTOR VALUES statement later in the program. +The second statement in the program causes the inout +information, properly labeled., to print out, preceded by the title +"SOLUTION OF CUBIC EQUATION". The appropriate alphabetic information +is contained in the format information which is t be found in the +vector TITLE, as set by a VECTOR VALUES statement +VECTOR VALUES +Statementslater in the program. Two functions are defined in this program, and each is @@ -1225,7 +1231,8 @@ Constants Constants, Alphabetic consists of from one to six admissible charactersAdmissible Characters preceded and followed by the -character "$". The admiss- ible characters include all letters of the +character "$".$ Sign +The admiss- ible characters include all letters of the alphabet, the digits 0 through 9, the special characters +, -(minus sign), -(dash), *, /, =, ). (. ., the comma "," and the blank space, to be represented here occasionally (but not punched on input cards), @@ -1260,11 +1267,15 @@ being indistinguishable). There are two Boolean constants – "true", which is written 1B, and "false" which is written 0B. -Boolean Constants +Boolean Constants +0B +1B Variables +Variable + The name of a variable consists of one to six letters or digits, the first of which must be a letter. If the variable is defined as an n-dimensional array variableArray @@ -1287,6 +1298,7 @@ enclosing subscripts may not be omitted. Statement Labels Statement Labels +Vector, Statent Label A statement may be labelled or unlabelled. Labels are used to refer to a statement in other statements. A statement label consists @@ -1412,7 +1424,9 @@ have the value 1B. .AND. M.THEN.P has the value 0B if and only if M has the -value 1B and P has the value 0B. +value 1B and P has the value 0B. +.THEN. + @@ -1761,6 +1775,8 @@ following floating point numbers: Transfer Statement +TRANSFER Statement + This statement has the form: TRANSFER TO &scriptS; Here &scriptS; may be any statement label or any expression in @@ -2032,13 +2048,13 @@ 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: +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 @@ -2070,10 +2086,11 @@ using the criterion "|f(x)| < ε and |xk (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: +increment. Zero Increment for +Iteration 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: @@ -2126,6 +2143,8 @@ be entirely within the scope of a. The following diagrams represent some valid configurations: Scope +Valid Iteration Configuration + &scope1; @@ -2189,6 +2208,8 @@ waits for the user to press Enter. Normally, the value of a function will occur as part of an expression, as in the statement: +Value of a Function + Z = COS.(X)/SIN.(X + 2.) @@ -2442,6 +2463,8 @@ produced, allowing the operator to read the comment. according to format &scriptF;. READ BCD TAPE READ BINARY TAPE +WRITE BCD TAPE +WRITE BINARY TAPE @@ -2455,8 +2478,8 @@ according to format &scriptF;. WRITE BINARY TAPE &scriptN;, &scriptL; -Transmits &scriptL; to tape &scriptN; in binary form as one -record. +Transmits &scriptL; to tape &scriptN; in binary form as one record. +WRITE BINARY TAPE @@ -2466,6 +2489,7 @@ record. Transmits &scriptL; to or from drum &scriptN; starting with drum address &scriptA; (where &scriptA; is an integer expression). READ DRUM +WRITE DRUM @@ -3216,12 +3240,15 @@ Name constant is assigned function name mode A vector appearing as the dimension vector of some arrayArray Variables in a dimension declaration is assigned integer mode (see ). +linkend='dimension_declaration'/>). +Vector + A vector which is preset by a vector values declaration is assigned a mode consistent with the assigned values (see ).Dimension -Vector +Vector VECTOR VALUES +Statements @@ -3240,7 +3267,7 @@ each element of an array its "linear subscript."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. +zero.Zero subscript Two dimensional matrices are stored internally by rows, i.e., an m × n matrix will be stored in the order: a11, @@ -3325,9 +3352,11 @@ the defined ranges of the subscripts are positive. 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 +If the array is a + vector,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) @@ -3351,9 +3380,10 @@ 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. +declarationVECTOR VALUES +Statements the array need not appear in a +dimension statement unless the maximum linear subscript implied by the +initial values is not sufficiently high. Equivalence Declaration @@ -3497,7 +3527,8 @@ of the following form: Hollerith (BCD) (a) VECTOR VALUES &scriptV; = c0, -c1, ... c&scriptL; +c1, ... c&scriptL; +VECTOR VALUES Statements Here &scriptV; is of the form N(n) or simply N, if n = 0. The elements N(n), ... N(n + &scriptL;) are preset to the values @@ -3514,7 +3545,8 @@ c1 must all be of the same mode. (b) VECTOR VALUES &scriptV; = $ k1 ... km$, -$km+1... kp$, ... +$km+1... kp$, ... +$ Sign Here the ki may be any valid characters @@ -3901,7 +3933,9 @@ Declaration The name of a function with the period deleted must not be used as the name of a variable or as a statement label. A statement label must not be identical with any variable -name.Statement Labels +name.Statement Labels +Variable + The translator automatically calls on some subroutines, hence the following names may not be used as variable names or statement labels @@ -3922,6 +3956,8 @@ in Chapter 4). SETEOF Subroutine SETETT Subroutine SYSTEM Subroutine +TAPERD Subroutine +TAPEWR Subroutine Subroutines @@ -4029,6 +4065,8 @@ idea!). Example 2<emphasis role='note'>: Printing the truth table of a Boolean expression</emphasis> +Truth Table + Problem: A logical (Boolean) expression such as (P .AND. Q) .OR.(.NOT. P .AND. R .AND. S).OR.(R .OR. P) will have a value TRUE or FALSE (represnted here by 1B and 0B, @@ -5043,6 +5081,8 @@ recursive functions. +Value of a Function + SET LIST TO Statement @@ -5069,6 +5109,9 @@ statements always refer to the current list. <emphasis role='note'>Example 4: Evaluate Tschebychev polynomials</emphasis> + +Tschebychev Polynomial Example + Problem: To evaluate Tschebychev polynomials. Analysis: The Tschebychev polynomial T(N,X) @@ -5130,7 +5173,8 @@ Spaces are not relevant. 1.3 The statement may start anywhere in cols. 12-72. With the exception of characters enclosed between "$" spaces are not relevant. (Spaces may not be relevant even if they are so enclosed (see section -2.15) on format specifications). +2.15) on format specifications).$ +Sign 1.4 The identification information in cols. 73-80 is not used by the computer for any purpose but printing during translation and is @@ -5312,6 +5356,7 @@ here. Entry to this routine causes a return to the operating system. The END OF PROGRAM statement produces a call for this routine. END OF PROGRAM Statement +SYSTEM Subroutine @@ -5334,7 +5379,11 @@ location of the format specification, (2) tape number, and (3) a list of variables to be written. The WRITE BCD TAPE ... statement produces a call for this subroutine. -Hollerith (BCD) +Hollerith (BCD) +TAPEWR Subroutine +WRITE BCD TAPE +WRITE BINARY TAPE + @@ -5355,6 +5404,7 @@ The READ BCD TAPE . . . statement produces a call for this routine. READ BCD TAPE READ BINARY TAPE +TAPERD Subroutine @@ -6423,6 +6473,12 @@ Input-OutputInput-Output Statements Non-ExecutableNon-Executable Statements Subscript, LinearLinear Subscript Subscript, NegativeNegative Subscript +THROUGH StatementIteration Statement +Transpose of a MatrixMatrix Transpose +TruncationIntrger Division +Variables, BoundBound Variables +Variables, DummyDummy Variables +Vector, PresettingPresetting Vectors -- 2.43.0