LIBRARY OF THE UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN Page APPENDIX A. PL/l PROGRAM kk B. FORTRAN SUBROUTINES 6l C. USER'S MANUAL 72 1. INTRODUCTION 1. 1 Purpose The SMART system is intended to be of use to people such as physicists, engineers, or others who need to perform such complex calculations as solving a system of linear equations, finding the eigenvalues and eigenvectors of a matrix, or inverting a matrix, but who have not spent or do not want to spend the time necessary to learn a procedure-oriented language, such as FORTRAN or PL/l. SMART will enable such a user to sit at a console and, with a set of simple commands at his disposal, perform a wide range of matrix operations. The user need not be concerned with the details of using the library subroutines currently available for these purposes. SMART will request all pertinent information as it is needed, and will supply the user with the results of the computation in an easily readable form when finished. 1. 2 System Requirements A system such as SMART should have the following characteristics. a) The commands should be simple, and should clearly indicate the operation to be performed. b) The user should not be required to learn the entire set of commands to perform a single operation. c) The methods of input and output should be as trouble free and simple as possible. d) The system should detect as many errors as possible before attempt- ing to perform the operations, so that the user is reasonably assured of receiving correct results without the need for debugging and rerunning any programs. The SMART system meets the above requirements in the following ways, a) There are ten commands in the language. There is one command for 2 each operation, plus a command for input and a command for output. The commands are composed of English words, not mnemonic codes, and there is a simple scheme for naming matrices. b) Since each operation has a distinct command, the user has to learn only that command to perform the desired operation. For example, it is not neces- sary to set up a loop of instructions to perform an operation such as scalar multiplication of a matrix. One command, such as M5 = 13- 3 * MT is all that is required. In addition, the users manual for the system is structured in such a way that the user can learn as much or as little about the system as he needs to /.now. c) As mentioned above, there is a single command for input and a single command for output. On input the user merely indicates that he wants to enter a matrix into the system and SMART responds by requesting all pertinent information, including the individual elements of the matrix being entered. On output the user indicates the matrix he wishes to be printed, and SMART will output the matrix in a standard format. With some commands, such as the ones for solving systems of linear equations and the eigenvalue command, output is automatic, and no separate output command is needed. d) The simple syntax of the language allows the translator to catch all language errors before compiling the object code. In addition, such things as row-column compatibility for matrix multiplication are checked and suitable erro. ^ges are typed before attempting to solve the problem. In the case ' attempting to invert a singular or nearly singular matrix or attempting to such a matr a coefficient matrix for a system of linear equations, •.gularity is detected in the routine that performs the calculations, and a message to this effect is output. -3- 1.3 Overview of SMART The SMART system can be divided into three major components. a) A PL/l program, designed to be put into the University of Illinois PLORTS (P. L. One Remote Terminal Subset) time sharing system. This program's purpose is to receive input commands from the user, perform syntax checks and other tests on the input command, maintain the symbol table and several files, transmit error messages to the user, and compile FORTRAN statements, primarily DIMENSION and CALL statements. b) A set of FORTRAN subroutines whose function it is to perform the various matrix operations implemented in SMART. The main program for these subroutines will be the program compiled by the PL/l program. c) A user's manual stored as a PLORTS time sharing file, struc- tured in such a way that the user can access as much or as little of the manual as is necessary for his purpose. The block diagram of Figure 1 shows how the various parts of the system are related. JOB STEP #1 .;tep #2 USER AT TELETYPE CONSOLE t 1 <© C/2 03 t) PL/1 PROGRAM (PROCESS COMMANDS, TRANSMIT ERROR MESSAGES, MAINTAIN FILES, COMPILE FORTRAN STATEMENTS) CO > 1 1 HEADERS ELEMENTS o o » 2 Ir 1 MATRIX FILE MAIN FORTRAN PROGRAM (COMPILED BY PL/l PROGRAM) FORTRAN SUBROUTINES (PERFORM MATRIX OPERATIONS) I ELEMENTS ■ Figure 1. A Lock Marram 2. DESCRIPTION OF THE SMART LANGUAGE 2. 1 General Since the SMART language was designed for the non-programming user, it can he characterized as an operation oriented language, as opposed to procedure oriented languages such as PL/l and FORTRAN. The individual statements in the language correspond to entire matrix operations, rather than to the individual steps that go into the procedure for performing the operation. With the restriction that each command must be typed on a single line, the SMART language can he termed a free format language. That is to say within the confines of a line on a teletype console, a SMART statement can start anywhere, and any blanks within the line will be ignored. The SMART language consists of ten different commands, which can be divided into three different types, plus an editing feature. The three different command types are: a) Input and output commands. With these commands the user can enter matrices to be operated upon, and view the results of the various operations. b) Assignment commands. These commands correspond to matrix operations whose results are themselves matrices, such as matrix multipli- cation and inversion. c) Directly output commands. This group of commands corresponds to those matrix operations whose results are other than a matrix. An example of such an operation would be finding the eigenvalues and eigen- vectors of a matrix, or solving a system of linear equations. 6 Before going into an explanation of the various commands, a few- definitions of terms used in the explanations will be in order. a) Matrix Name - This is the letter M followed by an integer between 1 and 99- SMART requires the user to give each matrix a unique name of this type. In the following explanations, a matrix name will be denoted by M ||. b) Matrix File - A file (OS/360 Data Set) in which all matrices are stored. This includes both matrices explicitly entered and matrices generated by assignment type commands. c) Output File - A file in which the results of directly output commands are stored, plus a copy of any matrix from the matrix file that the user specifies via the output command. Once all the operations are performed (3) the user can access the output file by means of the PLORTS list command. d) Number - A signed (+ or -) or unsigned integer or real number, optionally followed by the letter D and a signed or unsigned integer. Exam- ples: 20, 50. 3D-1, -331+.7, 1U02. 2. 2 Statements The individual commands have the following meanings. 2.2.1 Input and Output Commands a) ENTER MATRIX M # #. This statement initiates the process of entering a matrix into the matrix file. Upon recognition of this command, SMART will ask the user for the number of rows of the matrix. The user should respond by typing an integer between 1 and 99« SMART will then make a similar request, and expect a similar reply, for the number of columns of the matrix. The next step in the input ence i s of requests by SMART for the elements of the matrix, in row- major ' ':ond subscript varying most rapidly). After each request the user v >e the number, as defined above, that corresponds to the matrix element SMAP'.' reqiH I ing. The procedure will stop automatically after SMART 7 requests the last element of the matrix, at which time the user is free to enter another matrix if he so desires, or type any of the other commands in the language. b) PRINT MATRIX M # #. This command will cause SMART to put a copy of the named matrix into the output file. The primary purpose of the PRINT MATRIX command is for viewing the results of assignment type commands, since these results are put into the matrix file rather than directly into the output file. However, it may be used with any matrix in the matrix file. The matrices are written into the output file one element per line, with the matrix name and element index preceding the value of the element. For exam- ple, if the command PRINT MATRIX M21+ were given, the output file would appear as follows, with M21+ being a 5 x 5 matrix. y\2h (l, l) = . 1i7256i1|.U99721U66doi M24 (1, 2) = -.73732U6691510. 3UD-02 M2U((5, 5) = . 35568211+ 9721*833) 4 D 02 2.2.2 Assignment Commands The SMART assignment type commands allow a user to perform the follow- ing operations: invert a matrix, multiply two matrices, add two matrices, and multiply a matrix by a scalar. The individual statements are, respectively: M # # = INVERSE M # # M##=M##*M## M## =M##+ M## M # # = NUMBER * M # # In each case the left-hand matrix name should not be the same as any matrix name(s) on the right-hand side of the equal sign. SMART will test the 8 right-hand side matrices for dimensional compatibility with the intended opera- tion, and assign the proper dimensions to the left-hand side matrix. In the case of scalar multiplication the number will be tested for conformity with the definition given above. The results of the operation will be stored in the matrix file and given the left-hand matrix name, so that this new matrix will be available for use in later matrix computations. 2.2.3 Directly Output Commands Solving a system of linear equations, computing the Euclidean norm of a matrix, and computing the eigenvalues and eigenvectors of a matrix are all directly output operations, since the results of these computations are put directly into the output file, rather than back into the matrix file. No PRINT MATRIX command is needed. The form of these commands is S0LVE M##*X=M## N0RM M # # EIGENVALUE M # # For the SOLVE command, the right-hand matrix may have 1 to 99 columns, and should have as many rows as does the left-hand matrix. Each right-hand column represents a set of values to be used in solving the set of linear equations. The output file will contain a copy of the S0LVE command, followed ; elements of the unknown X matrix. Each column of the X matrix will be a solution to the system of equations with the corresponding column of the right-hand matrix used as the right-hand side. For the N0RM command, the output file will contain a line that reads T MATRIX M # # = followed by the computed Euclidean norm, i.e. , the square t of the sum of the squares of the matrix elements. •be EIGENVALUE command, SMART will respond by asking the user if wants the eigenvectors of the matrix, to which the user should respond with YES or NO. The output file will contain a line that reads EIGENVALUES OF M # # or EIGENVALUES AND EIGENVECTORS OF M # #. Following this line will be the eigenvalues of the matrix, printed as a complex number. For example, EIGENVALUE 2 = (-0. 2499999999999986DOO, 0. 96824 58365518509D 00) might be printed for a matrix whose exact second eigenvalue is -2. 5 + i. 96825. If the user gave a YES response, the eigenvector associated with the eigenvalue would be printed below the eigenvalue as a complex column vector. 2. 3 Editing Facilities The editing facilities of SMART are offered in addition to the available PLORTS editing features, and allow a user to start typing a command or reply anew if he has made an obvious mistake. The user can re- cover from this mistake by typing ERR and retyping the command or reply. If he is near the end of a line he may type ERR and start the command or reply on the next line. This process can continue until the command or reply appears to be correct. SMART will ignore any characters on a line to the left of the rightmost ERR. 10 3. SYSTEM DESCRIPTION 3. 1 PL/l Program The PL/l program portion of the SMART system is basically a translator from the simple SMART language described in Section 2 into FORTRAN. The FORTRAN object code consists primarily of DIMENSION statements and calls to the various FORTRAN subroutines which perform the operations. This translation is accomplished interactively, in the sense that no FORTRAN is compiled unless and until the user has entered a syntactically and semantically correct command. By semantically correct is meant that the user cannot request an operation on a matrix that has not been entered, nor can he request an operation on a matrix for which that matrix is not suited. Interaction with the user occurs when a syntactic or semantic error has been made. To accomplish all this, the PL/l program can be functionally divided into four sections. These sections include communication with the user, command recognition and syntax checking, maintenance of the symbol table and the several files, and the compilation of FORTRAN object code. Communication with the user is divided into messages to and commands from the user. In the present implementation the program uses the default PL/l input and output data sets SYS IN and SYSPRINT. When the program is put into the time sharing system, the proper file names (as yet undecided) will be used. Messages from the user are pres- ently data cards containing one command or reply per card. They are . as needed into a character string called COMMAND. This string is glared CHAR (80) VARYING, but the length will be changed in the 11 final version to correspond with the length of a line of teletype input, which is 72 characters long. Messages to the user are output one message per line, with messages being of varying length. To save space, error messages are com- posed from a set of character strings declared at the beginning of the program. Syntax checking and command recognition are relatively simple tasks because of the simple structure of the SMART language and the ease with which character strings may be manipulated in the PL/l language. Initially, the COMMAND string is subject to pre-processing, which consists of removing every- thing in the string up to and including the rightmost ERR that may be present in the command, and then removing all blanks in the remaining command. After pre- processing, the command is tested for the occurrence of one of the ten SMART commands. Each test consists of two or three PL/l statements. As a typical example, the test for the command EIGENVALUE M / # would be performed with the following two statements. LP = INDEX (COMMAND, 'EIGENVALUEM' ); IF LP =0 THEN G0 T0 EIGEN; where LP is a binary fixed variable, and EIGEN is the entry to the EIGENVALUE command processor. If COMMAND does not conform to any of the allowed commands-, SMART issues an error message to that effect and requests a corrected command. The tasks of maintaining and searching the symbol table are distributed throughout the program, rather than handled by a single subroutine. This is possible since the simplified structure of matrix names (the letter M followed by a digit between 1 and 99); and the fact that real general matrices are the only data types handled by SMART allows a simple symbol table structure. The SMART symbol table consists of a set of four one- dimensional arrays, each of 100 elements, plus a counter named CNT that indicates the current number of matrices entered in the matrix file. The four arrays have the following names and functions. 12 1. M # (I) is declared to be CHAR (2) VARYING, and is the integer portion of the Ith matrix name to be entered in the matrix file. For example, if the fourth ENTER MATRIX command was of the form ENTER MATRIX M29 then M # (k) would be the character string '29'. 2. ROW # (I) and COL # (i), also declared as CHAR (2) VARYING, are the number of rows and the number of columns of the Ith matrix to be entered in the matrix file. 3. DIMFLG (I) is declared to be BIT (l) INITIAL ((100) (l) 'O'B), and is a set of flags to indicate whether a DIMENSION statement has been compiled for the Ith matrix in the matrix file. SMART does a sequential search of the M # array, stopping at the maximum index indicated by the variable CNT, each time there is need to access a particular matrix name or test a matrix name to determine whether that name has been entered. Entries are made simply by incrementing CNT by 1 and inserting the new matrix name in M| (CNT). The task of file maintenance is also distributed throughout the program, there being three separate files maintained. 1. The matrix file (MTXOUT) This is the file in which the users matrices are stored. Each record in the file is 23 characters in length, this being the maximum length of a RTRAN double precision real (floating point) number (l6 decimal digits plus even spaces for sign, decimal point, and exponent). Each record is either a nt, which is a FORTRAN double precision number in EBCDIC, or is a •: header. A matrix header contains four pieces of information: the integer 'Ortion of a matrix name, a pointer to the next matrix header in the file, and the dimen. of the matrix. The generation and storing of headers is performed the HEAD1 e, and matrix elements are stored as they are received by 13 the INARRAY procedure. A matrix is stored in the matrix file as a header followed by the elements of the matrix in row-major order. 2. The FORTRAN output file (F0RTLST) This is the file into which the compiled FORTRAN program writes its output. The only function of the PL/l program with regard to this file is that of writing "blanks into as many records as are needed for the FORTRAN output. This is necessary because of an idiosyncrasy in 0S/36O concerning FORTRAN output data sets with the DISP = NEW parameter. By writing blanks, during the first job step (the PL/l program), in as many records as are needed, and passing this data set to the second job step (the FORTRAN program) with a DISP = (M0D, PASS) parameter, it is then unnecessary for 0S/36O to initialize the entire F0RTLST data set, which it would have attempted if the F0RTLST data set were given the DISP = NEW parameter in the second job step. 3. The FORTRAN object code file (F0RT0UT) This is the file into which SMART writes the compiled F0RTRAN object code. At the conclusion of the PL/l program, this file contains the main program portion of the second job step. Each record is 80 characters in length, the length of a FORTRAN punched card. 0S/36O will initially allocate ten records, and will allocate ten additional records as they are needed, up to a maximum of 15 times. The task of compiling FORTRAN statements is divided between the individual command processors and the DIMENS subroutine procedure. For the END command SMART merely compiles a STOP and an END statement, then thanks the user politely. This is done in the statement recognizer portion of the program. For all other SMART commands there are two character strings involved named Ik CALLC0M and FTC0M. CALLC0M is declared in the main program as CHAR (132) VARYING and is the FORTRAN CALL statement. FTC0M is declared in DIMENS as CHAR (66) VARYING and is the FORTRAN DIMENSION statement. The command processor will assign as an initial value to CALLC0M the characters 'CALL' concatenated with whatever FORTRAN subroutine is to be called, followed by a left parenthesis. Thereafter the procedure DIMENS is called once for each matrix involved in the command and each auxiliary matrix or array used by the called subroutine. The parameters for the DIMENS procedure include the letter and number comprising the matrix name, the number of dimensions of the matrix, the first and second dimensions, a flag indicating whether this matrix has been previously dimensioned, and the CALLC0M character string as described above (Figure 2). DIMENS then sets up a DIMENSION statement by concatenating the letter, number and dimensions along with appropriate parentheses and commas onto the FTC0M character string. Concurrently, this same information is concate- nated with the CALLC0M character string. The flag is then tested and if the DIMENSION statement is to be put into the object file, this is accomplished with a call to the CARDOUT procedure. After the command processor has compiled a DIMENSION statement for each appropriate matrix, it then completes the CALLCOM character string by concatenat- ; a character string representing the current value of the variable MXREC, a counter for the number of records put into the matrix file, any other information needed for this particular call, and a right parenthesis. A call to 1 procedure then puts the CALL statement into the object file. To tie all of the above together, we shall now follow the progress of oal command, ML ERR Ml = INVERSE M30 throug: grain and note the action of the various sections of the program onse to tl 15 DIMENS: PROC ( LET,NUM,NDI MS, DI Ml ,DIM2, FLAG, CALLCOM) ; /* DIMENS SETS UP A DIMENSION STATEMENT TO BE PUT INTO THE FORTRAN OUTPUT FILE, AND CONCATENATES THE INFORMATION IN THE DIMENSION STATEMENT ONTO THE CALLING SEQUENCE FOR THE ROUTINE TO BE CALLED, IF FLAG = 1 THEN JUST THE LATTER IS D0NE9 */ DCL NDIMS; DCL (LET,NUM,DIM1,DIM2) CHAR(*) VARYING; DCL FTCOM CHAR(66) VARYING; DCL CMA CHAR( 1 ) INI T ( • ,• ); DCL LPR CHARd ) INIT( • ( • ) ; DCL RPR CHAR( 1) INIT { • ) • ) ; DCL CALLCOM CHARU32) VARYING; DCL FLAG BIT(l); DCL DIM CHAR(IO) I N I T ( • D I MENS I ON •); FTCOM = LET | | NUM ; CALLCOM = CALLCOMI |FTCOM| |CMA| |NUM| |CMA| IDIM1 | |CMA; IF FLAG = »1«B THEN GO TO TSTNDIMS; FTCOM = DIM| (FTCOMI |LPR | IDIM1; TSTNDIMS: IF NDIMS = 1 THEN GO TO PUTONRPR; CALLCOM = CALLCOMI |DIM2 | |CMA; IF FLAG = »1»B THEN GO TO RET; FTCOM = FTCOMI |CMA| IDIM2; PUTONRPR: IF FLAG = '1»B THEN GO TO RET; FTCOM = FTCOMI |RPR; CALL CARDOUT(FTCOM) ; FLAG = 'l'B; RET: RETURN; END DIMENS; Figure 2. DIMENS Procedure 16 The command is first read into the character string COMMAND, and then subject to pre-processing. Afte*r pre-processing the COMMAND string contains 'M^INVERSENTSO'. The statement recognizer then sees that this is an assignment type statement by recognizing the first 'M' and the '=', and consequently gives control to the assignment type command processor (ATCP) (Figure 3). The first thing the ATCP does is test to be sure the 'M' is the first character in the string (Figure J+). LFLAG-2 is a fatal error message flag and is initialized to 0. LFLAG2 will be set to 1 if a fatal error message is printed. The ATCP does not relinquish control until as many error messages as are necessary are printed so that the user can correct as many errors as possible at one time. After LFLAG2 is initialized the left-hand matrix number is extracted, by means of the SUBSTR function, and stored in MTMP (l), a five character string of varying length (Figure k) • This is done at this point since the left-hand matrix number is information common to all assignment commands. A call to the LEGAL procedure tells whether MTMP (l) is an integer between 1 and 99 and, if not, an error message is printed and LFLAG2 set to 1. If we now have a legal left-hand : number then the M # # array is searched to see if this matrix has been previously entered. It should not be, since overwriting of previously-entered matrices is not allowed in SMART, but if it has been entered then an error message is printed and LFLAG2 is set to 1. Overwriting of previously-entered • rices is not allowed, since the matrix to be overwritten may be of smaller total size than the result matrix, and the result matrix would then occupy ce in the matrix file previously occupied by both the overwritten matrix plus the header and several elements of the next matrix in the matrix file. •:t comes another statement recognition section, to determine which "ignment commands we have. After COMMAND is recognized as an INVERSE command control is passed to the INVERSE command processor (Figure 5). The 17 NXTLINE: PUT EDI T (• PLEASE PROCEED'HA) SKIP; GET EDIT(COMMAND) (A(80) ) ; /* READ IN NEXT COMMAND */ PUT EDIT(CUMMAND) (A(80) )SKIP; /* PRE-PROCESS THE INCOMING COMMAND */ CALL NOERR( COMMAND) ; CALL TRIM(COMMAND,NULLFLAG) ; IF NULLFLAG = 1 THEN GO TO NXTLINE; CALL SOUISH(COMMAND) ; /* END OF PRE-PROCESSING, START OF STATEMENT RECOGNIZER */ LP = INDEX(COMMAND, 'END' ) ; IF LP -.= THEN DO; FTCOM = 'STOP' ; CALL CARDOUT(FTCUM) ; FTCOM = 'END' ; CALL CARDOUT(FTCOM) ; PUT EDIT {'THANK YOU') (A) SKIP; GO TO DONE; END; LP = INDEX(COMMAND, • ENTERMATR I XM • ) ; IF LP -= THEN GO TO INPUT; LP = INDEX(COMMAND, 'SOLVE' ) ; IF LP -= THEN GO TO ELIM; LP = INDEX(COMMAND, • E I GENVALUEM ' ) ; IF LP -.= THEN GO TO EIGEN; LP = INDEX(COMMAND, 'NORM' ) ; IF LP --= THEN GO TO NORM; LP = INDEX(COMMAND, • PR I NTMATR I XM • ) ; IF LP -.= THEN GO TO OUT; LP = INDEX(COMMAND, «M» ) ; LPJ = INDEX(COMMAND t •=• ) ; IF LP -.= £ LPJ -is THEN GO TO ASSIGN; ILLCOM: PUT L I ST ( • I LLEGAL COMMAND , PLEASE CORRECT') SKIP; GO TO NXTLINE; Figure 3. COMMAND Input, Preprocessing and Statement Recognizer. 18 /* ASSIGNMENT TYPE COMMAND PROCESSORS */ ASSIGN: IF LP -= 1 THEN GO TO ILLCOM; LFLAG2 = 0; MTMP(l) = SUBSTR(C0MMAND,2,LPJ-(LP+1) ) ; /* EXTRACT LHS MATRIX NUMBER */ CALL LEGAL (MTMP( 1 ) t LFLAG) ; IF LFLAG > THEN DO; PUT EDIT{MSG1»MTMP( 1) t MSG2,MSG3) (A, A,A,A) SKIP; LFLAG2 = 1; GU TO FNDASN; END; UU I = 1 TO CNT; IF MTMPd ) = M#( I ) THEN DO; PUT EDIT(MSG1»MTMP( 1 ) ,MSG7,MSG8) ( A,A, A, A) SKIP; LFLAG2 = 1; END; END; FNDASN: LP = I NDEX ( COMMAND ,' INVERSEM •) ; IF LP -.= THEN GO TO INVERT; LP = INDEX (COMMAND, '=M» ) ; IF LP -.= THEN DO; LPJ = INDEX(COMMAND t '*M« ) ; IF LPJ -= THEN GO TO MXMPY; LPJ = INDEX(COMMAND, »+M« ) ; IF LPJ -.= THEN GO TO MXADD; tLSE GO TO ILLCOM; tND; ELSE DO; LPJ = INDEX(CUMMAND, >*M« ) ; IF LPJ -.= THEN GU TO SCALAR; ELSE GO TO ILLCOM; END; messing of Assignment Commands. 19 /* INVERSE COMMAND PRUCESSOR */ INVERT: MTMPI2) = SUBSTR ( COMMAND, LP + 8 ) ; CALL LEGAL(MTMP(2) tLFLAG) ; IE LFLAG > THEN DO; PUT EDIT(MSG1,MTMP(2) »MSG2,MSG3) (A,A,A, A) SKIP; /- M IS NOT A LEGAL MATRIX NAME */ LFLAG2 = 1; END; (-NDRHS: DO I = 1 TO CNT; IE M#(I) = MTMP(2) THEN DO; J = I; GU TO INVEND; END; END FNDRHS; PUT EDIT (MSG1,MTMP(2) ,MSG5) (A, A, A) SKIP; /* M HAS NOT BEEN ENTERED */ LFLAG2 = l; GO TO TSTLF2; INVFND: IF ROW#(J) -.= COL#(J) THEN DO; PUT EDIT(MSG1,MTMP(2) ,MSG6) (A,A,A) SKIP; /- M IS NOT A SQUARE MATRIX */ LELAG2 = 1; END; TSTLF2: IF LFLAG2 = 1 THEN GO TO NXTLINE; LHSHDR: CNT = CNT + 1; M#(CNT ) = MTMP( 1 ) ; RUW#(CNT ) = ROW#( J ) ; CUL#(CNT ) = COL#( J) ; CALL HEADER (MTMP( 1 ) ,NXTMX,ROW#( J) ,COL#( J ) ) ; NRC = ROW#( J ) * COL#( J ) ; DO I = 1 TO NRC; WRITE FILE(MTXOUT) FROM(NUMB); END; MXREC = MXREC + NRC; TMPRD(2) = CHAR(NRC); CALL SOUISH( TMPRD(2) ) ; Figure 5. INVERSE Command Processor. 20 right-hand matrix number is extracted and stored in MTMP(2), then tested by LEGAL. If MTMP(2) is a legal matrix number the M # array is searched to see if this matrix number has been entered. If not an error message is printed and LFLAG2 is set to 1. If it has been entered then the dimensions are checked to be sure we are taking the inverse of a square matrix. If not, an error message is printed and LFLAG2 is set to 1. At this point LFLAG2 is tested and if equal to 1 control is passed back to the command input where the next command is requested. If everything is fine up to this point then the next piece of business to be taken care of is putting a header into the matrix file followed by enough space to contain the inverse matrix. The information from the header comes from MTMP(l), the left-hand matrix number, and the R0W# and C0L# elements for the right-hand matrix, which were found in the symbol table search for the right-hand matrix number. The pointer to the next matrix header is calculated in the HEADER procedure using the location of the present header and adding to this the product of the row and column dimensions plus 1. After the space has been reserved on the matrix file for the inverse matrix, the MXREC counter is incremented by the number of records reserved, and the compilation of F0RTRAN object code is begun (Figure 6). The first matrix to be dimensioned is the right-hand matrix, followed by three auxiliary matrices required by the DGELGZ F0RTRAN subroutine which calculates the inverse. The call to NXTRA which precedes the three calls to DIMENS merely increments the RA iable and converts it to a character string for use in the calls to DIMENS, that the auxiliary matrices will have unique names, in case another INVERSE •yped later. nally ...\C0M character string is completed, put into the object . ■.rid the inverse commar processed. CALLCOM = CLU I • INVERT! •; 21 N = MTMP(2 ) ; NUIMS = 2; CALL DIMENS(A,MTMP(2) , ND I MS, ROW# ( J ) ,COL#( J ), DI MFLG ( N ), CALLCOM ) ; DIMR: CALL NXTRA ( RA , TMPRD ( 1 )) ; ZKOB = «0«B; CALL D I MENS (AID, TMPRD ( 1 ) , ND IMS , ROW* ( J ) ,COL#ts the routines to be performed, and the matrix name(s) to be used as rands and result. The Reckoner uses a postfix notation, while SMART uses infix notation. For example, the SMART command M2 * M3 d translate into the Reckoner language as : TMMUL M2 M3 Ml . fMMlJL is the Reckoner code name for the matrix multiplication routine. In anguages the matrix M3 is to be pre-multiplied by M2, with the result in 141. For the eigenvalue problem, the command is 7EIGEN ABC, where :ie eigenvalues and eigenvectors of A and C may be omitted if no eig< are d< . Where SMART allows A to be a general matrix, with rallies and eigenvectors, the Reckoner forces symmetry on 29 A by taking the average of A(l, J) and A(j, I), for all I and J. One of the system functions mentioned above is the ability to change the names of system-provided operations, so that the odd-looking 7MMUL and 7EIGEN commands may be changed by the user to whatever names suit him. Input and output is accomplished in what seems to be a roundabout way in the Reckoner, and the process is not conversational as in SMART. For example, to enter a 3 x 2 matrix the commands would be 7CHAR M # 3 2 # 2.273 2.11+5 - .891 6.821 1+933 - 3 # # 7 CTOD M MAT1 The first line says that a character string is to be input and called M, and the outer # characters delimit this string. Inside the string the 3 and 2 indicate dimensions, and the matrix elements are between the inner #'s in row-major order. The 7CT0D M MAT1 command is a convert character to decimal command, with M being the character string and MAT1 the name of the resulting matrix. Output for this matrix would be accomplished in the following way: 7TYPE MAT1 3 2 and MAT1 would then be typed with 3 rows and 2 columns. The idea of coherent programming is strongly stressed in the under- lying philosophy of the Reckoner. As mentioned earlier, the Reckoner is a system for utilizing routines, rather than for writing them. In addition, the library of routines is open-ended, so that new routines may be added from time to time. The requirement for coherence stipulates that, within reasonable constraints, routine in the library should be able to call upon any other routine or use She res-alts of any other routine as input. By "reasonable constraints'* is ■leant, that a file of, say, street names would not be used as input to a linear equation solver. To accomplish this goal the designers of the Reckoner have established a set of conventions to be followed by anyone writing routines to 30 be added to the library, conventions concerning operands and results, conventions for calling other programs, and conventions for passing parameters between pro- grams. In addition, the Reckoner has a small algebraic compiler which produces object code that follows these conventions. The result of all this is that by- following these conventions a programmer can add routines to the library without disrupting existing programs, even though these programs can, and most likely will, be used in combinations unforeseen by the original programmers. k'2 MAP ( Mathematical Analysis Program ) The MAP system at M. I.T. 's project MAC is designed for on-line mathe- matical analysis. It deals primarily with functional analysis rather than linear algebra, hence it is not closely related to SMART in terms of types of problems. The two systems are similar, however, in that there is a high degree of interaction between the user and the system. In both systems the user begins the problem- solving process by typing a short command indicating the type of interaction desired (input, problem solving, output) and the computer directs the user from that point on by noting any errors and requesting pertinent information. Both systems use the computer as an instructor. The SMART user 's -al is stored in secondary storage, while in MAP the computer responds to certain commands by typing an explanation of what the command means, and ecting the user to type the appropriate responses. As an example, the function V: I UUv 2 -Ts 2 )), v 1 -put and integrated. User input will be lower case and underlined, response will be upper case. ':4AND I sqrtf (gamsqs) / 'i . ' v * * 2 + gamsqs))) . THE NEXT LINE MIN, MAX, AND DEL FOR THE VARIABLE V. 31 -l l. .05 MIN = -20 MAX = 20 DEC VALUE OF CONSTANT GAMSQS PLEASE 0.01 COMMAND PLEASE integrate INTEGRATE HAS THREE OPTIONS ON THE LIMITS 1. BOTH LIMITS FIXED 2. LOWER LIMIT FIXED UPPER LIMIT VARIABLE 3. SYMMETRIC INTEGRATION BETWEEN VARIABLE LIMITS PLEASE INDICATE WHICH OPTION BY TYPING 1, 2, or 3 1 WHAT WOULD YOU LIKE TO INTEGRATE i(v) NAME OF ANSWER PLEASE integ DEC VALUE OF LOWER LIMIT PLEASE = DEC VALUE OF UPPER LIMIT PLEASE = 1 COMMAND PLEASE At this point a numerical integration procedure would be invoked and the user could then have the system print the results. k.3 MARI ( Matrix Arithmetic ) The MARI system is not an on-line interactive system at all, but an extension of the assembly language for the IBM 7°30 STRETCH machine. In this language matrix instructions are expressed as single address assembly language instructions with the prefix MX. When the assembler encounters these instructions they are assembled as (normally) invalid operation codes. For example, the SMART command Ml = M2 * W) would be written in the MARI system as 32 INSTRUCTION COMMENT LINK; B, MX0P 'SUBROUTINE LINKAGE MXL, M2 'LOAD MATRIX M2 MXR*, M3 'RIGHT MULTIPLY BY M3 MXST, Ml 'STORE RESULT AS Ml MXEND The instructions LINK; B,MXOP and MXEND are needed to enter and exit the interpretive subroutine which is the heart of the MARI system. Once entered, this routine executes each instruction by calling an appropriate subroutine to perform the operation. The interpreter assumes that an implied operand is stored in a pseudo-accumulator, which is actually a directory word which points to the location of the implied operand matrix in the matrix storage area. The operation of the above commands runs as follows. The MXL, M2 instruction causes the interpreter to load a pointer to the location of M2 from the directory of matrix names into the pseudo-accumulator. MXR*, M3 passes a pointer to M3 along to the matrix multiplication routine, which reserves space for the result and performs the operation. The MXST, Ml instruction then copies a pointer to the result into the directory at location Ml. Input and output is done by means of the subroutines MXI0 and MXPRNT. The calling sequence to input a matrix is CN0P LINK; B, MXI0 'CALL MXI0 ftREA 'AREA CONTAINING MATRIX AME 'NAME T0 BE GIVEN MATRIX TYPE, R0W, C0L 'MATRIX TYPE AND DIMENSIONS :0 assumes that the elements are stored in the correct sequence the particular type in INARKA. The different matrix types are null, 35 scalar, diagonal, symmetric and general (stored either column-wise or row-wise). To print a matrix, the following calling sequence would he used: LINK; B, MXPRNT 'CALL MXPRNT , NAME 'MATRIX NAME , IDENT 'ADDRESS OF IDENTIFYING INFORMATION (ALPHANUMERIC) The identifying information is printed along with the matrix elements. The MARI system most resembles SMART in the method of storing matrices. Both systems use headers with information as to the matrix name and dimensions. In MARI there are two headers for each matrix. The first header points back to a location in the directory which contains the matrix name, and the second con- tains the matrix type and dimensions. SMART has just one header, which contains the integer portion of the matrix name, a pointer to the next header, in the file, and the dimensions. In each system the matrix elements immediately follow the headers in storage. In MARI the matrix elements are stored according to the type of matrix, whether diagonal, symmetric, etc. , while SMART stores all matrices as general matrices. The MARI system saves space in storing special types of matrices, but necessitates having a separate routine to perform the same opera- tion on different matrix types, whereas SMART is able to use just one routine for each operation. The MARI system does have a single command for finding eigenvalues and eigenvectors, but the command is restricted to symmetric matrices only. There is no single command for solving a system of linear equations. This would have to be programmed, using the set of matrix instructions available. k.k NAPSS ( Numerical Analysis Problem - Solving System ) NAPSS is a system under development at Purdue University. Like MAP it is oriented more toward functions of one or more variables than toward linear 3k algebra, and will deal with problems such as finding the zeroes of a polynomial, functional approximation, and solving differential equations. The proposed system will have two modes of operation, a conversational mode and a batch mode. In the conversational mode the system will request information from the user as it is needed, much the same as SMART and MAP, while in the batch mode the system will expect such information to be in a standard input file. One concept which seems to be unique with NAPSS is a delayed interaction feature in the batch mode. This will cause a program to suspend operation when it requires additional information, and the user can, at his convenience, reactivate the program from a console and supply the needed information. In the following example the line numbers are for later reference and would not normally appear in a program. 1. ACCURACY 3 DIGITS 2. DATA APFILE 3. F(T) = APPR0X (X, D) G(T) = APPR0X (Y, E) 5. S0LVE DIFF EQ F0R U(T) , V(T) 6. dt2 U(T) = V (T) + 2 d F (T) + SIN (G(T) * T) 7- dt2 V(T) = - U(T) + 3.1 d G(T) - COS (F (T) * T) . T = (0, 10), U (0) = V (0) = d V(0) = 9- END PL0T CURVE (U(T), V(T))T = (0, 10); HI: "M0TION 0F FORCED PSEUD0 PARTICLE"; LI: LABEL TITLE 11. TABLE T, U(T), V (T) T = (0, 10); HEAD HI; LABEL LI 12. 3T0P Lines ay that F(T) and G(T) are to be curves fitted to tables of data 35 pairs (X, D) and (Y, E) respectively, and this data, according to line 2, is to be found in a file called APFILE. Lines 5 to 9 define a differential equation and initial values. Line 10 is a request for a plot of the curve U(t) vs. V(t) given in parametric form, with the given heading and a label to be found at the symbolic address TITLE. Line 11 requests the same information in tabular form with the same heading and label. Rather than call a single subroutine to perform the desired operation, NAPSS will utilize what the authors term a "polyalgorithm". This is a method of solving a specific type of problem "formed by the synthesis of a group of (7) numerical methods and a logical structure into an integrated procedure. ' ' This logical structure, which, in the conversational mode, will include the user of the system, will monitor the course of the computation. At critical points the user will be asked to make decisions, on the basis of intermediate results, as to which of several alternative numerical methods best suits the problem at hand. The authors point out that this concept can be a powerful one in several ways. First, the designer of the polyalgorithm can include, in his choice of methods for solving a problem, a method or methods which may only converge for a certain subclass of the problem or range of values. By a proper choice of these partially successful methods it may be possible to construct a polyalgorithm which will converge for an entire class of problems or range of values. Second, such a polyalgorithm would be a powerful tool for teaching numerical analysis, enab- ling a student to experiment and compare various methods of solving a given problem. k . 5 Cambridge Linear Algebra Language Like MARI, the Cambridge Linear Algebra Language is not implemented as an on-line interactive system. The system was originally designed as an aid in the study of econometric models in the Department of Applied Economics, but is of sufficiently general design to be included in this survey. 36 In general, the system divides storage into fixed sections for matrices, vectors and scalers. There are 10 matrix stores, 10 vector stores and 10 scalar stores. Matrices have a maximum size of 2000 elements, vectors a maximum of 100 elements, with the first two elements of each containing the dimensions. Each matrix, vector, or scalar is referenced by an integer between and 9. In- put is by means of paper tape or punched cards, with a / (slash) signifying the end of a row or the end of a vector. The system automatically computes and stores the size of the matrix or vector in the first two locations of one of the 10 stores. A statement in the language consists of a four-tuple of integers. The first integer refers to the operation to be performed, the second and third are the operands, and the fourth is the number of the store into which the result is to be put. A matrix in storage may be overwritten, so that the restriction on the number of matrices is less severe than appears at first glance. There would be a considerable waste of storage, however, if, for example, 10 matrices of 10 x 10 size were stored in the system. There are a total of 50 available operation codes, loosely grouped into the following classes. The numbers 0-9 are matrix operations, 10-19 are vector operations, 20-29 scalar operations, and 3O-I4.9 are mixed mode and miscellaneous operations, such as scalar multipli- cation of a matrix and subroutine calls, respectively. As an example, to perform the SMART command Ml = M2 * M3 in this stem one would write 3?31, where the first 3 is the operation code for matrix multiplication, the 2 and the following 3 refer to matrix stores 2 and md 1 refers to the result in matrix store 1. If the first 3 had been, say, a 13, which is the operation code for the element product of 2 vectors, the d 1 would have referred to vector stores. One unusual feature of this system is the method of implementing 37 subroutines and loops. A sequence of instructions is read into a vector store, and whenever this sequence is to be executed the programmer writes an instruction with an operation code of kl for a subroutine or kQ for a loop. Every four numbers in the vector store represents one instruction in the sequence, with a maximum of 2k instructions stored in any one vector store. A particular sequence could be used as a subroutine on one call and as a loop on another call. In the case of a loop, the loop parameters (number of repetitions and criteria for exit) are handled by the third and fourth integers in the instruction. The second integer indicates in which vector store the loop is located. For example, the instruction Ij.8 3 5 6 would mean that the sequence of instructions in vector store 3 is to be executed as a loop. Scalar store 5 contains the number of pass- es through the loop, and scalar store 6 contains a number which may be decrement- ed within the loop. If this number becomes less than zero before normal termi- nation of the loop, control is to be returned to the next instruction after the loop call. In the case of a subroutine call the third and fourth integers are zero, which means that loop parameters must not be stored in vector store zero. Since the sequences of instructions are stored in vector stores, the use of subroutines and loops reduces the number of vector stores available for other use. a.. 6 basic The BASIC language, which was designed at Dartmouth College as a time- sharing language, includes as a subset of the language eleven BASIC statement types designed for matrix computations. They are characterized by the letters MAT at the beginning of the statement. A DIM (dimension) statement must pre- cede any MAT type statements, and matrix names must consist of a single letter. For example, to read in two 3 x 3 matrices, execute a matrix multiplication, then print the result, one would write the following program. In this case line numbers are an integral part of the program. 58 1 DIM A (2,2), B(2,2), C(2,2) 2 MAT READ A,B 3 DATA 1, 2, 3, k, 5, 6, 7, 8, 9 li DATA 2, U, 6, 8, 10, 12, H, l6, 18 5 MAT C = A * B 6 MAT PRINT C 8 END One idiosyncrasy of BASIC is that actual matrix dimensions are one greater than that specified in the DIM statement, so that the 3x3 matrices A, B, and C are dimensioned (2,2). This is because matrix element subscripts start with zero rather than 1. The MAT READ A, B statement causes the first nine elements in the DATA list to be read into matrix A, and the second nine items into matrix B. The MAT PRINT C statement will cause the matrix C to be printed 5 numbers per line. The 11 MAT statement types include matrix addition, subtraction, multiplication, matrix inversion and transposition plus statements for forming special matrices of all ones and all zeroes and the identity matrix. The solu- tion of a system of linear equations or eigenvalue, eigenvector problems is not included as a single MAT statement type. In scalar multiplication, the scalar may be an algebraic expression. U.7 MATHLAB The MATHLAB system, developed at M. I.T. 's project MAC and the MITRE Corporation, is related to both the MAP system and to NAPSS in that it deals with functions of one or more variables, rather than operations on matrices. Where MAP and NAPSS use numerical methods to perform the various operations on the user defined functions, MATHLAB on the other hand is entirely symbolic. Hence, MATHLAB is able to perform many operations that would be impossible, or at best extr' .'icult on the other two systems. For example, by means 39 of simple commands the user is able to simplify an expression or equation, substitute a variable or expression into another expression or equation, and add two equations. This emphasis on the symbolic mode of operation means that MATHLAB is weak in areas where the other two systems are strong. Simple numer- ical calculations are cumbersome, i.e., ADD ((q.. ,. . . ,q )NAME) is the command for adding the quantities q ,...q and assigning this value to NAME. The quan- tities q, , qp**",q can be arithmetic quantities, expressions or equations. MATHLAB cannot plot graphs, which is a simple matter in MAP or NAPSS. The user commands for the most part are very simple, and most commands have heavy error protection. The user receives an error message if he makes any mistakes while constructing variables and equations. The following example will illustrate some of the commands and responses of the system. denote nil ej5 = = y t 3 + y * y = ( x + z) * (u + v) var=a*t+2*t+t*s+s+b*s + 4*tt2+c*tt2, THANKS FOR THE EQUATION EJ> AND THE VARIABLE VAR please simplify (e3 ek) (Ek) Y t 3 + Y t 2 = (x + z) * (u + v) expand ((x a)) YES please simplify (ek e5) ko (E5) Y t 3+Yt 2=X*U+X*V+Z*U+Z*V factor (t s) YES please simplify (var var2) VAR2 =(2+A+S) *T+ (^+C) *Xt 2 + (l + B) * Y The denote function above is the means of entering equations and variables into the system. The double equal sign indicates that what follows is an equation; a single equal sign indicates a variable. The single comma signifies the end of the input. The expand command will cause a product of sums to be multiplied out whenever one of the arguments (there may be more than two arguments in both the expand and factor commands) appears in the product. The factor command does just that, with the t term taking precedence over the s, i.e., the t term will be factored first, then the s. The system includes many other commands, including differentiation, integration, solving a single linear or quadratic equation in terms of a given variable, the standard arithmetic commands, plus several manipulative commands such as invert, flip, makequation and makevariable. The system is written in the LISP language, and new commands may be added by anyone familiar with LISP. There are limited facilities for extension of the system by the user. In particular the user can teach the system the deriva- tives of the user's favorite function and he can also change the names of cystem commands. 5. SUMMARY At the time of this writing, the PLORTS system, of which SMART will eventually be a subsystem, is not yet operational. Therefore, experi- ence with SMART is limited to that gained during debugging and testing of the prototype program. However, several observations can be made from that experience. a) The editing facilities of the system, along with the free format of the language, are a definite help to the less than expert typist. Several of the typing errors shown in the example program in the user's manual are the result of actual errors made at the keypunch machine, and were not planned in advance or planted in any way. b) The method of entering matrices, one element to a. line at the request of SMART, seems to be fairly natural, and the entering of test matrices in the example program went rapidly, even for the largest (5x5) matrices. For larger matrices, however, the method could become tiresome, and a more rapid method, perhaps utilizing a teletype with an attached paper tape reader, would be more desirable. One addition to the present input method that might prove helpful would be to have SMART type a message such as NEW ROW or STARTING ROW # # at appropriate points in the input process, so that the user would have a double check on the element to be entered at that point. Another addition could be some method of aborting the input process, or of backing up and starting over at a point in the middle of a matrix, if the user found he had skipped an element or made a mistake in entering an element after the fact. In the present system, however, such a backing up facility would require an extensive modification of, if not the matrix filing system, at least the INARRAY program for entering matrices into the system. This modification k2 would be necessary since the INARRAY program writes matrix elements into the matrix file as they are received from the user, rather than storing them in main storage and writing them into the file after the user correctly enters the last matrix element. The single element at a time method was chosen so that the PL/l program would use as little space as possible, which meant saving only one element rather than an entire array. c) . One facility which would prove useful, and could easily be incorporated into the operational version of SMART, would be to enable users to file matrices in their own private files. This would enable a user to perform some operations one day, keep the results in his own file, and come bac back some other day and be able to manipulate these results without having to go through the process of entering the matrix anew. The user could also, with his private matrix file, enter matrices into the file using the batch processing facilities available. He could, perhaps, submit his matrix as the data cards to a simple program that would construct a header from informa- tion on the first card, then write this header and the subsequent elements into the user's file. The user would then be free to sit at a console and start typing commands. d) The modularity of the system allows a programmer reasonably proficient in PL/l and FORTRAN to add new matrix operations with ease. To add a new operation one merely has to add a few statements to the command recognizer, then write a separate command processor for the new command in Pl/l, plus the corresponding FORTRAN subroutine. 43 REFERENCES (1) Branin, Jr., F. H. , Hall, L. V., Carlitz, R. M. , and Chen, T. C. "An Interpretive Program for Matrix Arithmetic. " I. B. M . Systems Journal , Vol. k, No. 1, pp. 2-2U, 19^5. (2) Burley, H. T. "A Programming Language for Linear Algebra. " The Computer Journal , Vol. 10, No. 1, pp. 69-73, May, 1967. (3) Gear, C. , Whaley, A. , and Weidenhofer, N» "The University of Illinois PL0RTS System--Phase Provisional User's Manual." Department of Computer Science File No. 793; March, 1969. (k) Engleman, C. "Mathlab: A Program for On-Line Machine Assistance in Symbolic Computations. " Proceedings - Fall Joint Computer Conference, pp. 1+13-421, 1965. (5) Farina, Mario V. Programming in BASIC , the Time Sharing Language . Prentice Hall, Englewood Cliffs, N. J. , 1968. (6) Kaplow, R. , Brackett, J. , and Strong, S. "Man-Machine Communica- tions in On-Line Mathematical Analysis. " Proceedings - Fall Joint Computer Conference, pp. k^-kll , ~L9bb. (7) Rice, John R. , and Rosen, Saul. "A Numerical Analysis Problem- Solving System." Proceedings - A. CM. National Meeting, pp. 51- 56, 1966. (8) Stowe, A. N. , Weisen, R. A., Yntema, D. B. , and Forgie, J. W. "The Lincoln Reckoner: An Operation-Oriented, On-Line Facility with Distributed Control. " Proceedings - Fall Joint Computer Conference, pp. kj>3-khk, 19&6. (9) Stowe, A. N. "Reckoner User's Guide." Personal Communication, 1969. kk APPENDIX A PL/l PROGRAM bMART: PROCEDURE OPT IUNS(MAIN) ; i)CL INVFLG BIT( 1 ) ; DLL COMMAND CHAR(RO) VARYING; DCL RA BIN FIXED IN I 1 (0) ; UCL NXIMX BIN FIXED INITU); DCL NXltf CHAR(lb) VARYING; DCL PTR CHAR(b); ljCL (MTXDUT, FOR TOUT, FORTLST) FILE OUTPUT; DCL NPIR(2); DCL TMPR[)(2) CHAR(15) VARYING; DCL OIMFLG(IOO) BIT(I) I N I T ( ( 100 ) ( 1 ) • ' B ) ; DCL M#(100) CHAR(2) VARYING; DCL MThP(3) CHAR(b) VARYING; dcl pr()d(2) bin fixfd; dcl blanks char(ro) initu80)' '); dcl (row, cud (2) bin fixbd; dcl prud#(2) char(6) varying; dcl nrmflg chak(I) init('O'); dcl rwcli2) char(7) varying i n i t ( ' rows ' , ' columns • ) dcl cmt bin fixed i n i t ( 0) ; dcl numb char(23) init((23)' •) external; dcl ftcard char(ro) external; DCL (ROrftf.COLiM ( 100) CHAR(2) VARYING; I CL C# CHAR ( 1 ) INI1 ( ' • ) 5 DCL FTCOM CHAR(66) VARYING; DCL -VISGl CHAR ( 1 ) INI T ( 'M' k5 ) dcl DCL DCL DCL DCL DCL DCL DCL MSG2 MSG3 MSG4 MSGb MSG6 MSG7 MSGR MSG9 CHAR ( lb) CHARI 12 ) CHAR ( 11 ) CHAR(21 ) CHAR (23) CHAR( 18 ) CHAR ( 3R) CHAR( 14) DCL DCL DCL DCL DCL DCL DCL DCL DCL DCL DCL DCL DCL DCL DCL DCL DCL UCL DCL DCL DCL DCL DCL MSG10 MSG11 MSG12 MSG13 INI T < • I N II ( ' I N I T ( • INIT( ' INI T ( • INIT( • INI T ( • I N I T ( ' CHAR (16) INI T ( '01 CHAR( 8) I N I T { • ELEMENT( • ) ; CHAR(28) INIT('THE RIGHT HAND SIDE CHAR(24) IIMITJ' ARE NOT COMPATIBLE IS NOT A LEGAL' ) ; MATRIX NAME' ) ; NUMBER OF' ) ; HAS NOT BEEN ENTERED' ) ; IS NOT A SQUARE MATRIX' ) ; HAS BEEN ENTERED, • ) ; AND MAY NOT BE USED ON LEFT-HAND PLEASE REPEAT' ) ; SIDE' ) D NOT RECEIVE • ) MATRICES' ) FOR • ) ; MSG1M2) CHAR(14) MXPR0G(2) CHAR(6) IMTI'MXADDI MLTPNO CHAR(23) VARYING; TWO CHAR (1) INIT('2'); A CHAR ( 1 ) IN I 1 ( ' A' ) ; R CHAR ( 1 ) INIT( 'R • ) ; VALU CHAR(4) INI T ( • VALU' ) ; DIM CHAR (10) IN IT ( 'DIMENSION • CLL CHAR ( b ) INI T ( 'CALL • ) ; VCR CHAR (3) INI T( • VCR ' ) ; VCI CHAR ( 3) INIT( • VCI ' ) ; VLR CHAR (3) INI T( • VLR ' ) ; VLI CHAR (3) I N I T ( • VLI ' ) ; INDC CHAR(4) I N I T ( ' INDC ) ; AID CHAR (3) IMIT ( ' AID' ) ; LPR CHAR ( 1 ) INIT( • ( • ) RPR CHAR ( 1 ) INI T ( ' ) • ) CMA CHAR ( 1 ) I N I T { • , ' ) ZROB BIT ( 1 ) : INI T ( 'ADDITION' , 'MULTIPLICATION' ) MXMPY( • ) DCL CALLCOM CHAR(132) VARYING; k6 UmARRAy: proc (row,cod ; /* inarray asks the user for the elements uk the matrix in ruw-major ORDER. IT RIGHT-JUSTIFIES EACH ELEMENT AS IT IS ENTERED IN A 23 CHARACTER FIELD, THEN STORES IT IN I HE NEXT POSITION IN THE MATRIX FILE. */ DCL (ROW, COL) BIN FIXED; Tl CHAR(23) VARYING; l)CL I'LL DCL DCL J = K = EL J; k; LFLAG; l; l; iMXELT: PUT ED I T ( MSG 1 1 , J ,CMA ,K , • ) = • ) (A,F(2) ,A,F(2) ,A) SKIP; /* ELFmEinjTI J,K ) = */ g b r CALL CALL IF v LaLL l-LTl CALL 11- L LeLT SDHS wk n H IT ivUMH K = I F K t-LSF ■vjfrWk J = I E J ELSE : ' - 1 1 I FILE (SYS IN) EDI I (COMMAND) (A(80) ) ; noerr ( command) ; tr im( command, null flag) ; ullflag = 1 then go to nn; squish (command) ; = COMMAND; VALID(EL1 1, LFLAG) ; FLAG = 1 1HEN GO TO NXELT; 1 = LENGTH! ELT1 ) ; TR(NUMB,24-LELT1,LELT1 ) = ELTl; E FILE (MTXUOT ) FROM(NOMB); FILE( SYS PRINT ) EDIT (NUMB) ( A (23) ) ; = ( 2 3 ) • • : K + l; > COL THEN GU TU NEWRUW; GO TO NXELT ; OW: K = l; J+l ; >R(JW THtN RETURN; TO NXbL ( ; POI EUIT(MSG10,MSG11,J,CMA,K,'), , ,MSG9)(A,A,F(2),A,F(2),A,A)SKIP; NXELT; I NAkkA Y ; : k / LP: It- LP ROC(CSTRING) ; rURNS EVERYTHING TO THE RIGHT OF (A POSSIBLE) 'ERR 1 IN CSTRING ■/ T Nf. ) VARYING; [NlJtX (CSTR INC • ERR' ) ; ,TRING,LP+3) J 1MB, I > i fl • ) : kl /* LEGAL TbSTS NMB TU SEE IF IT DCL NMB CHAR(*) VARYING; DCL NMBFLG(2); DCL CH(2) CHAR( 1 ) ; DLL I; DCL NMBLNG; LFLAG = 0; •Mr-iBFLG ( 1 ) = 0; nmBFLG(2) = 0; Ni-iBLNG = LENGTH (NMB) ? Ih NMBLNG > 2 THEN GU TU GT2; NmBL: DU I = 1 TO NMBLNG; Ch(1) = SUBS7R(NMB,I ,1 ) ; IS AN INTEGER BETWEEN 1 AND 99 */ •1', THEN 1 ChLP: OU CH( 2 ) = Ih CHI 1 ) = CH(2) END CHLP; i,U TU ENMBL; EUU: NMBELG( I ) = enmbl: FMU nmbl; l)l) I = 1 TO NMBLNG: 1 h MMBFLGI I ) = THEN tiMl); ^ ETURN ; (IDT: LhLAG = 2; RETURN; i,(2: LHLAG = 1: RETURN; ENI) lec;al; 2' GU •3 TU EUU; •5« , »6» , '7' , '8« , «9« GU TU (JUT; HEADER : PROCtUURE(MN,NXTMX,MROW,MCUL ) ; uCL NXlMX; UCL DCL UCL DCL MINI CHARf*) VARYING; MP IR CHAR I lb) VARYING; (MROw,MCUL) CHAR(*) VARYING; I LMN, LMPTR ,LMRUW,LMCUL) BIN FIXED; MXTMX = NXTMX + MRUW-MCUL + 1; :"PTR = CHAR ( IMX1 MX ) ; CALL SOU I SHI MP1R ) ; LMN = LENGTH! MN) : LMPTR = LENG1HIMPTR ) ; LMRUW = LENGTH! MRUW) ; LmCUL = LENGTHIMCUL ) ; NOMB = (23) • • ; SUBSTR ( NUMB, 3-LMN, LMN) = MN ; S(JBS1R( NUMB, 8-LMPTR, LMPTR )= MPTR; SUBSTR (NUMB, 21-LMRUW,LMR0W) = MRUW; S0BSTR(NUMB,2^-LMCUL,LMCUL ) = MCUL WRITE EILE(MTXUUT) FROM(NUMB) PUT EDIT (NUMB) (AI23) ) SKIP; MXREC = MXREC + 1? NUMB = ( 23) ' ' ; RETURN; END HEADER; 48 CARDOUl /* CARU CODE. LONG CHARA DCL F# UCL DCL DCL DCL IF COM FTC SEO FTC LENG FICM2 = hlCARD wk ITE F PUT FDI GU TD F LUNG: F 1-1 CARD WRITE F RUT FDI = ' MCM2 = I- ICARD WRITE F PUT FDI : Rh ElMl) CAR : PR OUT II IT B CTFR CHAR CHA DM C CHA M2 C IH(F FTC = F# ILE ( T( FT IN; TCM2 = F# ILF( 1 (FT 1 • : SUB = F# ILF ( T( FT TURN DUUI OC( FTCUM) ; PUTS AN IMAGE UF A FORTRAN SOURCE CARU INTO THE OBJECT ALSO TESTS THE INCOMING STATEMENT AND IF IT IS TOO REAKS IT UP INTO TWO CARD IMAGES WITH A CONTINUATION IN THE SECOND CARD */ ( b ) I N I T ( ( b ) ' • ) ; R( 1 ) INIT( » • ) ; HAR(132) VARYING; R ( 8 ) I N I T ( ( R ) • • ) ; HAR ( 66 ) ; TCOM) > 66 THEN GU TO LONG; OM; I |CUN| I FTCM2I I SEO; FQR1CJUT ) FROM(FTCARD) ; CARD) ( A(RO) ) SKIP: = SUBSTR ( FTCOM, 1 ,66) ; I | CON | I FTCM2I I SEO; FORTOUl ) FRUM( FTCARD) ; CARD) ( A(80) ) SKI P; STR(FTCUM,67) ; I | CON I | FTCM2 I I SEO; FORTOUl ) PROM( FTCARD) ; CARD) ( A( 80) ) ; D I MENS: PROC( LET ,NUM ,NDI MS , D I Ml , DI M2 , FL AG , C ALL CUM ) ; •MENS SETS UP A DIMENSION STATEMENT TO BE PUT INTO THE FORTRAN OUTPUT FILE, AND CONCATENATES THE INFORMATION IN THE DIMENSION STATEMENT ONTO THE CALLING SEQUENCE FOR TO */ BE CALLED. IF FLAG = 1 THEN JUST THE LATTER VARYING; THE KUOTINE IS D0ME9 i'CL ND I MS; ( LET ,NUM,DIM1 ,DIM2 ) CHAR(*) DM CHAR(66) VARYING; CHAR ( 1 ) I Nil ( • , • ) ; LPR CHAR ( 1 ) INIT ( ' ( • ) ? HAR ( 1 ) INIT ( • ) ' ) ; CALl .HAK ( 1 32 ) VARYIfJ FLAG BIT ( 1 ) ; (10) INIT( ' DIMENSION iM; .ALLLOMl | h I CUM | | CM A | I NUM | | CMA | | DlMl I |CMA; ii Ml TSTNDIMS; I I nIMl ; I F IM| | DIM/ | | lma; DCL DCL FLAG ) in putonrpr; I) III I lull* ' 1 »H I HhN GU III Rl- I 1+9 CALL CARDOUT( FTCUM) hLAG = • 1 'B; KtT: RETURN; hNl) dimfns; IMXTRA: PROC(RA,CSTRNG) ; DLL RA BIN FIXbl); i)CL CSTRNG CHAR(*) VARYING; ka = RA + 1 ; CbTRNG = CHAR (RA ) ; CALL SQUISH(CSlRIViG) ; KhTURN; hND NX IRA; VALID: PR DC (NUMBER t L FLAG) ; UCL CHR CHAR ( 1 ) ; i)CL ERROR CHAR(l) ; DCL PTFLG BIT( 1 ) INIT ( »0' B ) ; DLL LFLAG; UCL NUMBER CHAR (23) VARYING; DLL NPI; DLL lnmbr; LNMBR = LENGTH ( NUMBER ) ; Li- LAG = o; i\-k T = 1 ; /* NMT IS A STRING POINTER */ (.ALL SIGN (NPI ,NUMBER ) : Ri-ALNU: CALL DEC PNl ( NUMBER , NPI , PTFLG ) LALL I Ml (NUMBER , NPT , ERROR ) ; Ih FRROR -.= • • THEN GO TO ERRMSG; PTFLG = ' 1«B THEM GO T(J OPTD; L DEC PNl (NUMBER, NPT, PI FLG) ; PTFLG = 'O'b THbN GU TU UPTU; L INT( NUMBER , NPI, ERROR ) ; FRROR ERRDR GO n • ' THEN DO; •0' THEN GO T( ERRMSG; OPTD; TO ADDUO; I b Lai I b ( Al I b 1 h biviD; in- TO: lb IMPT > LNMBR THbN GO CHR = SUBSTR ( NUMBbR ,NPT, 1 ) ; 1 I- CHR -.= ' D» THEN GU I U ERRMSG; iv v T = N P T + 1 ; (,-\LL SIGNfNPT, NUMBER ) ; LALL INT ( NUMBER, NPT, ERROR ) ; Ih ERROR -•= ' • FHEN GU TU ERRMSG; Ih NPT <= LNMBR 1 HEN GO TO ERRMSG; K hi URN; bKRMSG: POI EDI T( NUMBbR, • IS NUT A LI-LAG = 1; KhTURN; AUODO: NUMBbR = NUMBbR | | 'DO' : RETURN; bNl) VAL ID? VALID NUMBER' ) (A, A) SKIP; 50 SIGN: PkOC< NPT, NUMBER ) ; UCL NP1 ; l»CL NUMBER CHAR(23) VARYING; UCL CHR CHAR ( 1 ) ; CHR = SUBSTR(NUMBER,NPT, 1 ) ; I h CHR = •+• | CHR = •-• THEN NPT kMURN; mmi) SIGN; = NPT + 1 ; HmT UCL UCL UCL UCL UCL PR ERR (NP MUM CHR UIG LwMBR = tRROR = 1 1- n p r = s hlRST: 1 E CHR HIK ERROR = K r I URN; ANCE K t S T : I = S I = 1 I- CHR URN: I CHk INI UC ( NUMB ER,N Pi, ERROR ) ; OR CHAR ( 1 ) ; T, I , LNMBR ) ; BER CHARI23) VARYING; CHAR ( 1 ) ; IT( 10) CHAR( 1) INIT(«l , f , 2 , t , 3 , f , ^ , » , S> , » , 6 , f , 7 l f , 8«, , 9 , f , 0»); LENGTH! NUMBER ) ; i i • > LNMBR THEN RE I URN; UBS IR (NUMBER, NPT t l ) ; UU I = 1 TO 10; = DIGIT(I) I HEN GO TO ADVANCE; S I ; CHK ; : Mpj = NPT + 1 ; B NPT > LNMBR THEN RETURN; UBSTR (NUMBER, NPT , 1 ) : 1 To io; = UIGIT(I) 1HEN GO TO NEXTCHR; : mpt = NPT + 1; EST; • PROC ( NUMBER ,NPT ,PTELG) ; (23) vary [NG; ■ ! • ( l ) : • r ( 1 ) ; I K ( NUMBER ,NP1 , 1 ) ; = ' . ' I HEN UU; ■ '.HMMANU, Nlll I PI AG ) ; IPAII ",LANKS hkUM THE INCOMING COMMAND. */ I ivjULLELAG = 1; BACKDOOR: DO I = N BY -1 TO It- SUBS Ik ( CUMMANU, I ,1 ) -.= • tlMU BACKDOOR; KtTURN; SHORTEN: NULLELAG = 0; COMMAND = SUBSTR (COMMAND, 1 , I ) K i- 1 URN; E_ iv) i ) I R I M ; 51 l; • THEN GO TO SHORTEN; iuliISH /* SOU NUN USI DLL CO DLL BL hlNDBL -F : I I- ML N Li IMMAN GU TO t-Ki iN I : i - 1 j in MM I) SO IN THt COMMAND PRUCEDURE TRIM ) AND REHJRNS A STRING OH MUS r BE USED PRIOR TO PROCEDORt (COMMAND) ; SH REMOVES ANY BLANKS BLANK CHARACTERS. THE G SOUISH */ MAND CHAR(*) VARYING; K B I inj I- I X b I) ; K: BLl\K = I IMDEX ( COMMAND , I- BLIMK = THEN RETURN; = 1 1HEN GO 10 ERUNT; = SUBS TR (COMMAND, 1 , BLNK-1 ) | | SUBSTR ( COMMAND , BLNK+ 1 ) ; IMDBLNK ; COMMAND = SUBSTR (COMMAND, 2 ) ; I iMDBLNK; ISh; RUI PAGE; M X R E C = o : EICUM = 'IMPLICIT REALMS (A-H,0-Z)'; Lttl L CARDOOT ( E I COM ) ; ETCOM = 'COMMON /IVAR/ 111,110"; CALL CAKDOUT ( E I COM) ; FT COM = '111 = 1 ' ; '..ALL CARDOOT ( E I CUM) ; • i L I M E : PUT EUIT('PLEASE PROCEED'MA) SKIP; uET EDIT (COMMAND) (A (SO) ) ; /* READ IN NEXT COMMAND */ POT EDI T( COMMAND) ( A (BO) )SKIP; /* PRE-PROCESS THE INCOMING COMMAND */ CALL NUERR (COMMAND) ; CALL IR IM(COMMAND,NOLLELAG) ; IE NULLELAG = 1 THEN GO TO NXTLlNE; CALL SOU I SH( COMMAND) ? /* END OE PRE-PROCESSING, START OE STATEMENT RECOGNIZER */ LP = INDEX(C0MMAND, • END' ) ; IE LP -.= THEN DO; El COM = ' STOP' ; LALL CARDOOT ( E ICOM) : El COM = • END' ; CaLL CARDUUT ( EICUM) ; PUT FOIT (• THANK YOO«)(A) SKIP; GO TO DONE; END; LP = INUEX(CUMMAND t » ENl ERMAT R I XM • ) ; IP L p ^= 1HEN GU TU INPUT; LP = INUEX(CUMMAND, •SULVtr 1 ) ; IP LP -.= THEN GO TG PLIM; LP = INDEX(COMMAND, • EIGENVALUES ) ; IF LP -•= THEN GU 10 EI GEN; LP = INDEX (COMMAND, 'NORM' ) ? IF LP i= 1HEN GU TU NORM; LP = INDEX(CGMMAND, • PR I NTMATR I XM ' ) ; IF LP -» = THEN GU TU HUT; LP = I NDEX( COMMAND, • M' ) ; LPJ = INDEX(CUMMANU, ' = ' ) : IP L p .,= o g LPJ -.= THEN GU TU ASSIGN; ILLCUM: PUT LIST (• ILLEGAL COMMAND, PLEASE CORRECT • ) SKIP; GO TU IMXTLINE; 52 /* ENTER MA1RIX COMMAND PRUCESSUR */ IiMpiiT: CNT = CM + 1; MlMP(l) = SOBSIR (COMMAND, LP+12) ; CALL LEGAL(MTMP( 1),LELAG) ; I I- LELAG > THEN UU; PUT EDIT(mSG1,MTMP(1 ) ,MSG2,MSG3) (A, A, A, A) SKIP; /* M IS NUT A LEGAL MATRIX NAME */ LimT = CN1 - l; gu to nx1line; end; no i = l iu cn'i - l; IF M#( i ) = MTMP( l ) then DO; PUT FIJI T(MSG1 ,MlhP( 1 ) ,MSG7) ( A, A, A) SKIP; / HAS BEEN bNTEREI) */ I = CN1 - 1; i NXTLINE; ■ CN I ) = MlMP( l ) ; vLh: I I = 1 TO 2; LIN: PUl EI)IT(MSG4| |C#tRWCL(I)f • = ')(A,A,A) SKIP; IMUIv,. [JWS OR COLUMNS) - */ li| I ( COMMAND) ( A ( HO) ) ; PUl EDI1 (T.ljMMANU) ( A (80) ) ; CALL NUERR (COMMAND) ; I » JM(CUMMAND,NOl LFLAG) ; AG = 1 IHEN GU 10 RWCL IN; (COMMAND) ; ■ GAL (COMMAND, LELAG) ; ,A,KWCL ( I ) ) ( A, A, A, A) SKIP: A OF (WOWS OR COLUMNS) */ uu td rwclin; bNi); PROD#( I ) = COMMAND; END INDXLP; KUW#(CN I ) = PROD#( 1 ) ; C0L#(CN1 ) = PR0D#(2 ) ; kuw( l ) = R uw# ( CNT ) ; CUL(l) = COL*(CNT); CALL HEAUER(M#(CNT) , NX 1 MX , ROW* ( CNT ) , COL#(CNT ) ) ; CALL INARRAY(ROW( 1 ) ,COL ( 1 ) ) J MXREC = MXREC + ROW ( 1 ) *COL ( 1 ) ; (,CJ TO NXTLINE; 53 /* SULVb COMMAND PROCESSOR */ hLIM: LP = INDEX(COMMAND, »M' ) ; LPJ = INDEX (COMMAND, • *X = M> ) ; IF LP = | LPJ = THEN GO TO ILLCOM; IF LPJ < LP THEN GO TO ILLCOM; I imG = LPJ - (LP + 1); rtl'MPd) = SUBS IR (COMMAND, LP+1,LNG) ; MTMP(2) = SUBS TR(CUMMAND,LPJ+4) ; LFLAG2 = 0; l)U I = 1 TO 2; CALL LEGAL ( MlMP ( I ) ,LELAG) ; IF LFLAG > THfclM DO; LFLAG2 = 1: PUT EDIT (MSG1,M1MP( I ) ,MSG2,MSG3) (A, A, A, A) SKIP; END; END; J = 0; n = o; LPH: DO I = 1 BY 1 TO CN1 ; IF M* ( I ) = M1MP( 1 ) THEN J = I ; IE M#(I) = M "I M P ( 2 ) THEN K = I ; END LP8; IE J = THbN DU; PUT EDIT( MSG1 ,MTMP( 1 ) ,MSGb) ( A, A, A) SKIP; / -- M HAS NOT BEEN ENTERED */ LFLAG2 = 1; END; [E K = 1HEM DO; POT EDIT(mSG1 ,MTMP(2) ,MSG5) ( A, A, A) SKIP; / M HAS NO'I BEEN ENTbRED */ LELAG2 = 1; END; IH LELAG2 = 1 THEN GO TO NXTLINE; IE ROWfc(J) -■= RUW#(K) THEN DO; POT ED1TM THE NOMBER OF ROWS FOR M»,MTMP(1),« AND »,MTMP(2), • ARE WOT EQOAL ' ) ( A, A, A, A, A) SKIP; Gu TO NXTLINE; bNO; IF ROWW(J) -.= COL*(J) THEN DO; PUT bl)IT(MSGl,MTMP(l),MSG6) (A,A, A) SKIP; ^ /* M IS NUT A SQUARE MATRIX */ GU TO NXTLINb; t im n ; KUW(l) = RUW#(K); CUL( 1) = COL#(K) ; KUW(2) = RUW*MJ); CUL (2) = COL#( J) ; DO I = 1 TU 2; PROU( I ) = RUW( I )*COL( I ) ; TMPRL)( I ) = CHAR ( PROO( I ) ) ; CALL S(0UISH( TMPRD( I ) ) ; END; DO 1 = 110 PRUU( 1 ) + 2; WRITfc FILE( FURTLST) FRUM ( BLANKS ) ; END; PRUD*( 1 ) = 1MPRD( 1 ) ; PROIJ*(2) = TMPRO(2); TMPRU< 1 ) = CHAR (MXREC ) ; CALL S0UISH( TMPRIM 1 ) ) ; nIMj : im = M#( J ) ; imUIMS = 2; CALLCOM = CLL | I • FLIMI • ; (.ALL 1)1 MENS ( A,m#( J ) , NO I MS , RUW# ( J ) , CGL# ( J ) , U 1 MFLG ( N ) , CALLCOM) ; nlMK: N = m# (K ) ; CALL OIMENS( A,M*MK ) t NO I MS , ROW* ( K ) ,COLtf ( K ) , DI MFLG ( N ) , CALLCOM) ; 4RST: CALL NXl RA(RA,TMPRO( 2) ) ; n i ) I m s = 1 ; / ki ib = 'O'B; (ALL Dl MENS (R, I MPRU( 2 ) , NO I MS , PROD# ( 1 ) ,PROU#( 1 ) , Z RUB , CALLCOM ) ; /k()B = »0'n; LALL UIMENSt A | | A,TMPRO(2) , NO I MS , PROD# ( 2 ) , PRUU* ( 2 ) , ZROB » CALLCOM ) ; (.Al.LCOM = CALLCOMl | TMPROI 1 ) | |RPR; CALL CAROOOT(CALLCMM) ; GO TO NXTLINb; /* NORM AND FIGtNVALUE CUMMAND PRUCESSUR */ RM: NRMFLG = • 1 • ; i- 1 GEN: IF NRMFLG = ■ 1« THEN DO; MTMP(l) = SUBSTR(CUMMANO»LP+b) ; biMl); ELSE IM); hIMP(1) = SUBSTR(C0MMAND,LP+11 ) ; i- N I ) ; CALL LEGAL (M|MP( 1 ) ,LFLAG) ; IF LPLAG > IHFIM OU; 'IMP: PUl FOI1 ( MSG1 ,M1MP( 1 ) ,MSG2»MSG3) ( A, A, A, A ) SKIP; I . NOl A LEGAL MATRIX MAME */ i i NX fLINM : I « 1 B Y 1 1 1 I C M I ; M*( J) = mi mp ( l ) IHfcN GO TCI L99; UUP I ; PUT EDIT(MSG1 ,MTMP( 1 ) ,MSG5) (A, A, A) SKIP; M HAS NOI BEEN ENTERED */ 55 I VK NRMELG = '0' ; GO TG NXTLINE; IE ROWtf(J) -= COLfr(J) THEN DO; PUT EDIT( MSG1 ,M#< J ) t MSG6)( A, A,A) SKIP; M IS NOT A SQUARE MATRIX */ NRMELG = • 0' ; Gil II) NXTLINE; I imi); I MPRUC1 ) = CHAR(MXREC ) ; CALL SOUISH( TMPRD( 1 ) ) ; LlVEC: IE NRMFLG = '1'B THEN GO TO ONLYVL; PUT EUIT(»00 YOU ALSO WANT THE EIGENVECTORS OE M«,MTMP(1), •? ANSWER YES OR N0.«) (A,A,A)SKIP; GI-I'ANS: GET Et)lT(COMMAND) (A(80)); CALL NO ERR (COMMAND) ; CALL TR IM(COMMAND,NULELG) ; It- NULELG = 1 THEN DO; ■MGANS: PUT EDI T(MSG10, 'THE PROPER RESPONSE , ' , MSG9 ) ( A t A , A ) SKIP; GO TO GETANS; END; CALL SDUISH(COMMANU) ; IDXYES = INDEX(COMMAND, • YES' ) ? IDXNO = INDEX (COMMAND* 'NO' ) ; IE IDXYES -.= THEN GO TO ALSOVC; IE IDXNU -* = THEN GO TO ONLYVL; GO TO NGANS; dim! YVL : ROW( 1 ) = RUW*( J ) ; DO I = 1 TU ROW( 1 ) + 2; WRIlt MLE(EORTLST) EROM (BLANKS); END; N = M# ( J ) ; ! :■■, s - 2 ; ! COM = CLL I I ' EIGVAL ( • ; LI D I MENS! A,m# (J) ,KiDIMS,ROW#( J ) ,COL#( J) ,DIMELG(N) , CALLCOM) ; •Al : CALL NXTRA( RA t TMPRD(2 ) ) ; = ' o ' B ; .'. i 1 MENS ( VALUt TMPRD( 2 ) , ND I MS , ROW* ( J ) , TWO , ZROB , CAL LCUM ) ; ■ U.l COM = CALLCOM | | TMPRD( 1 ) | |CMA | INRMELGI | RPR; i I. CAKl)UUT(CALLCllM) ; h L G = • ' ; GO I II MX i L INE ; OVC: N = ROW# ( J ) ; DO I = 1 TO N*N + 2*N + 1; WRITE FILb(EURTLST) EROM ( BLANKS ) ; END; N = Mfr ( J ) ; i i ) i f i S - 2 ; i I Cum = CLL I I ' EIGVEC ( ' ; CALL DlMENSi A,M#( J ) , ND I MS t ROW* ( J ) ,CUL# (J),DIMELG(N) t CALLCOM) ; VC01M: CALL NX7 RA ( R A , TMPRD ( 2 ) ) ; /i-Oii - 'O'B; i p\\ I U1MENS ( VCR,TMPRD(2) t NDIMS»ROW#( J ) ,COL#( J ) , ZROB , CALLCOM ) ; IB = M)'B; CALL DIMENS< VCI , TMPRD(2) , NO I MS , ROW* ( J ) ,COL# ( J ) , ZRUB , C ALLCOM ) ; ZRUB = 'O'B; nuIms = l; CALL DIMENS(VLR,TMPRD(2) ,ND I MS ,ROW# ( J ) ,COL#( J) , ZROB ,C ALLCOM ) ; ZROB = 'O'B; CALL DIMENS(VLI , TMPRU(2) ,ND I MS , ROW* ( J ) ,COL# ( J >, ZROB ,C ALLCOM ) ; ZKOB = 'O'B; CALL DIMENS( INDC,TMPRD(2) ,ND I MS ,ROW# ( J ) ,COL#( J) , ZROB ,C ALLCOM ) ; CALLCOM = CALLCOMI | TMPRD( 1 ) | I RPR; CALL CARDOUT(CALLCOM) ; GO TU NXTLINE; /* ASSIGNMENT TYPE COMMAND PROCESSORS */ ASSIGN: IF LP is 1 THEN GO TO ILLCOM; LI-LAG2 = 0; Ml'HP(l) = SOBSTR(COMMAND,2,LPJ-UP+l ) ) ; /* EXTRACT LHS MATRIX NUMBER */ CALL LEGAL(MTMP( 1 ) ,LFLAG) ; I E LELAG > THEN 01); PUT FOI f (MSG1,MTMP( 1 ) ,MSG2,MSG3) (A, A, A, A) SKIP; LI-LAG2 = 1; (,u tu fnoasm; end; l)U I = 1 TO CNT; I h MTMP( 1 ) = M*( I ) THEN 00; PUT EDI T(MSG1,MTMP< 1 ) ,MSG7,MSG8) (A, A, A, A) SKIP; LhLAG2 = l; t-NU; end; (-imI)ASN: LP = INDEX(CUMMAND, • INVERSEM' ) ; It- LP --= THEN GO TU INVERT; LP = INUEX( COMMAND, «=M» ) ; I h LP -= THEN DO; LP J = I NDEX( COMMAND, ' *M« ) ; IE LPJ -,= THEN GO TU MXMPY; LPJ = I NDEX ( CuMmAND, '+M' ) ; IP LP. J -.= THEiM GO TU MXADD; F Gil TU ILLCOM; : mi: lpj = index ( command, • *m« ) ; IE LPJ -•= IhEN GO TU SCALAR; hi [LLCOM; : : - / = 1 ; r n , E T 2 # 3 J : • - Z\ (2) = SOHSl R (COMMAND, LP+2,LPJ-( LP+2 )) ; MP(3) = SUBSTK (COMMAND, LPJ+2 ) ; / IRCK hllK LEGAL MATRIX NUMBERS */ : DO I = 2 10 \\ (.All \\ ( MTMP< I ) , LELAG) ; \f I » 1H6N DOj Pi/1 i ,M IMP( I ) ,MSG2,MSG3) ( A, A, A, A ) SKIP; 56 /* M IS NOT A LEGAL MATRIX NAME */ END; END LEGALLP; /* HAVE 1HE MA1RICES BEEN ENTERED? */ hlND2#3: DU I = 2 TO 3; /* ARE THE 2 RHS MATRICES ENTERED? */ 1 nnER : DO J = 1 TO CNT; IE M#(J) = MTMP(I) THEN DO; np1R( I - 1 ) = J; GU TO FE2#3; b N D ; END INNER; kill EDI 1 (MSG1 ,Ml MP( I ) ,MSG6>) ( A,A,A) SKIP; 57 /* M HAS NOl BEEN ENTERED */ I i- 1 AG2 = 1 ; M-?#3: END FIND2#3; /* ARE ALL MATRIX NOMBERS LEGAL? */ IE LELAG2 -i= THEN GO TO NXTLINE; /* YES, ARE THE MATRICES COMPATIBLE? #/ M- MX = 1 THEN GO TO FORCOL; IE COL#(NPTR( 1 ) ) ^= RUW#(NPTR(2) ) THEN GO TO MXMSG; Gil 10 MXHDR; EORCOL: IE ROW#( NPTR ( 1 ) ) -= ROW# ( NPTR ( 2 ) ) THEN GO TO MXMSG; It- COL«(NPTR( 1) ) -* = C0L#(NPTR(2 ) ) THEN GO TO MXMSG; 1,0 I i I MXHDR ; MXMSG: POT EDIT ( MSG 1 2 , MSG 1 3 , MSG 14 ( MX ) ) (A, A, A ) SKIP; /* I HE RIGHl HAND SIDE MATRICES ARE NOT COMPATIBLE EOR (ADDIlIOiM OR MULTIPLICATION) * / GO TO NXTLINE; /* PREPARE A HEADER AMD SPACE ON FILE MT XOUT FUR THE LHS MATRIX*/ MXHDR: CM I = CNT + 1; M#(CNT)=MTMP(1); KllWfl (CNl ) = KIN# (NPTR ( 1 ) ) ; Clil -■• (CM r ) = COL* (NPTR ( 2 ) ) ; LAl L HEADER (Ml MP ( 1 ) , NX T MX, ROW* (CNT) , COL* (CNT) ) ; k'ki. = Kiiwtf ( CNl ) *COL*( CNT ) ; DO I = 1 10 nrc; WRITE EJLE(MTXOOT) FROM(NUMB); END; MXREC = MXREC + NRC; I MPRDI I ) = CHAR (MXREC ) ; CALL SDOISH( TMPRU( 1 ) ) ; M S = 2 ; CM I.Ciln = CLL | | M.XPRUG(MX ) ; nl Ml p: LH1 i = 2 TO 3; N = N P I R { I - 1 ) : K = M T MP ( I ) ; LAI L D I MENS! A,MTmP( I ) , ND I MS , ROW* ( N ) ,COL* ( N ) , DI MFLG ( K ) ,CALLCOM) ; Sn ( POIM: End DIMLP; l = M P I R ( 1 ) ; J - NPTR (2) ; K = MTMP ( 1 ) ; CALL DlMhNSJ A,i«ilMP( 1 ) ,NDIMS,ROW#( I ) ,COL#( J ),DIMFLG{K ) ,CALLCOM) ; CAILCUM = CALLCOMI | TMPRD( 1 ) | |RPR; (ALL CAkl)UUT(CALLCOM) ; GO TO NXTLINE; 58 /* INVERSE COMMAND PROCESSOR */ IimVFRT: MTMP(2) = SUBSTR ( COMMAND, L P + 8 ) ; CALL LEGAL(MTMP(2) ,LFLAG) ; II- LELAG > THEN DO: PUT EDIT(MSG1,MTMP(2) ,MSG2,MSG3) (A, A, A, A) SKIP; / ■:- M IS NOT A LEGAL MATRIX NAME */ LFLAG2 = 1; END; r-iMDRHS: DO I = 1 TO CNT; II- M#(I) = mTMP(2) THEN DO; J = I; (-,() TO IiMVEND; i- ill); i-hu fndrhS; PUT EDIT (MSG1,MTMP(2) ,MSG5) (A, A, A) SKIP; / ■- M HAS NO I BEEN ENTERED */ LFLAG2 = 1; GO TO TSTLE2: liMVHNI): IE ROW*HJ) -.= CUL#(J) THEN DO; PUT EDI T(MSG1 ,MTMP (2 ) ,MSG6) ( A, A, A ) SKIP; M IS NUT A SUUARE MATRIX 1 ; */ I l LAG2 : h-2: IE LFLAG2 = 1 THEN GO TO NXTLINE; NOR: CNT = CN I' + I ; CNT) = m T m P ( 1 ) ; ,,H(\ i ) = R()w# ( J ) ; ■ii) = CoL#( J) ; I HEADER (MTMP( ] ) f NXTMX,KIJW#(J),COL#(J)); RMW* ( J ) * COL* ( .J ) ; DO I = 1 Ml NRC; wPIIE FlLb(MTXOUT) EROM(NUMB); id; MXRhL = MXRbC + NRC; |MPRD(2) = l.HAP(NRC); Ul SH( I MPRD(2 ) ) ; I 1 • INVERT ( • ; M I MP I 2 ) : i hi • &,MTMP(2) ♦NDIMSfROW#{ J) f COL#(J)»DIMFLG(N) , CALL COM) ; A , I MPPD( 1 ) ) ; , i ■( 1 ) ,NI)IrtS,ROW*( J) ,COLrt( J) ,/ROH,CALLCOM) ; 59 i\ THEN DO; LI-LAG2 = 1; HUT FDIT(MSG1 ,MTMP( 2 ) ,MSG2,MSG3) ( A, A, A, A ) SKIP; h im D ; dm I = 1 To CNT ; It- M#(I) = MTMP(2) THEM GO TO LE2TST; hhlD; kuT EDI1 (MSG1,mTMP(2) ,MSGb) ( A, A, A) SKIP; I hLAG2 = 1 ; Lh/TST: IE LELAG2 > THPN GO TO NXTLINE; i.nT = CwT + 1; Mb (CNT ) = MTMP ( 1 ) ; kijw#(CmT ) = ROw^f ( I ) : ( .UL* (CNT ) = COL* ( I ) ; (.ALL HEADER (M#( CNT) ,NXTMX,ROW#( I ) ,COL#( I ) ) ; imkC = Row*/ ( I ) * CUL# ( I ) ; I M I J = 1 Til nrC; IIP P I Lh ( M I XIIU I ) EROM( NOMB ) ; u ; i»tXKEC = MXREC + NRC: I -PkO( 1 ) = CHAR (MXREC ) ; (.ALL SnuiSH( I MPRD( 1 ) ) ; CALLCOM = CLL I I ' SCALAR ( • ; = MTmP( 1 ) ; imdIms = 2 ; (.ALL D I MENS ( A, NT MP ( 1 ) , ND I MS, ROW#( I ) ,COL#( 1 ) , D I ME LG ( N ) , C ALL COM ) ; = M T M P ( ? ) ; CALL DIMENS( A,MIMP(2) , ND I MS, ROW#( I ) ,COL# ( I ) , D I MELG ( N ) , CALL COM) ; LALLCOM = CALLCOmI I MLTPNOI ICMA I I TMPRD( 1 ) I |RPR; CaLL CARDOOl (CALLCOM) ; GO 10 NXTLINE? /* PRINT MATRIX COMMAND PROCESSOR */ HUT: COMMAND = SUBSTR ( COMMAND, LP+1 1 ) ; /# REMOVE • PR I NTMATR I X « #/ LP = I imuPX ( COMMAND, • M» ) ; Ih LP 1= 1 THEN GO 10 ILLCOM; MTi-iP(l) = SOBSIR (COMMAND, LP+1 ) ; /* EXTRACT THE MATRIX NOMBER */ CALL LEGAL(MTMP( 1 ) ,LFLAG) ; IE LFLAG > THEN GO TO NGMTMP; DO I = 1 TO CNT; IF M#(I) = MTMP(l) THEN GO TO COMPUTE; END; PUT EDIT(MSG1,MTMP( 1 ) ,MSG5) (A,A,A) SKIP; 60 /* M HAS NOT BEEN ENTERED */ GO TO NXTLINE; COMPUTE: MROW = ROW*(I); NCOL = COL#( I ) ; DO J = 1 TO NROW* NCOL + 1; WRITE FTLE(EORTLST) FROM ( BLANKS ) ; END; TMPRIM 1 ) = CHAR (MXREC ) ; CALL SOUISH( TMPRD( 1 ) ) ; MCllM = CLL | I ' PRiMTMX" I ILPR I |M#( I ) I |CMA| |TMPRD( 1 ) | (RPR; CALL CARUOUT( FTCOM) ; GO TO NXTLINE; liUNF: END SMART; 61 APPENDIX B FORTRAN SUBROUTINES 62 IMPLICIT REAL*8 (A-H,0-Z) COMMON /IVAR/ 111,110 111 = 1 DIMENSION A5(4,4) DIMENSION A7(4,2) DIMENSION RK8) DIMENSION AA1 ( 16) CALL ELIM(A5,5,4,4,A7,7,4,2,R1,1,8,AA1,1,16,26) DIMENSION A10(5,5) DIMENSION VALU2(5,2) CALL EIGVAL(A10,10,5,5,VALU2,2,5,2,52,1 ) DIMENSION VCR3(5,5) DIMENSION VCI3(5,5) DIMENSION VLR3(5) DIMENSION VLI3(5) DIMENSION INDC3(5) CALL EIGVEC(A10,10,5,5,VCR3,3,5,5,VCI3,3,5,5,VLR3,3,5,VLI3,3,5,IND 1C3,3,5,52) DIMENSION A99(5,5) DIMENSION AID4(5,5) DIMENSION RM25) DIMENSION AAM25) CALL INVERTi A99, 99 , 5, 5, A I D4,4, 5, 5, R4,4, 25, AAA, 4, 2 5, 2 3, 25 , 104 ) DIMENSION A23(5,5) DIMENSION A37(5,5) CALL MXMPY(A23,23,5,5,A99,99,5,5,A37,37,5,5,130) CALL PRNTMX(23,130) CALL PRNTMX(37,130) DIMENSION A20(5,5) CALL SCALAR ( A20 , 20 , 5 , 5 , A37 , 37 , 5 , 5 , 20D0 , 1 56 ) CALL PRNTMX(20,156) DIMENSION A40(5,5) CALL MXADD(A20,20,5,5,A20,20,5,5,A40,40,5,5,182) CALL PRNTMX(40,182) c 1 fin SKIP END . FORTRAN program for example in user? mar, ia] , compiled by PL/l program. 63 SUBROUTINE SEARCFH MN, I ROW, ICOL , NOMX , MXREC ) DEFINE FILE 10 ( 200020 » 23,6 , 1 10 ) COMMON /IVAR/ 111,110 110 = 1 NUMX = 20 REA0( 10' I 10,1 ) MNUMB,NEXT,IROW, ICOL 1 FORMAT! 12, 15, 10X, 213) IFIMNUMB .EO. MN) GO TO 50 110 = NEXT IF( 110. GT. MXREC) GO TO 30 GO TO 20 30 NOMX = 1 50 RETURN END 6k SUBROUTINE E I GVAL ( A ,MN , JROW , JCOL , VALU,NVAL , NVLROW ,NVLCOL , MXREC , 1 NORM) IMPLICIT REAL*8(A-H,0-S,U-Z) 01 MENS I ON A( J ROW, J ROW) , VALU ( J ROW , 2 ) COMMON /IVAR/ 111,110 COMMON /OR/ITER(200) ,DUMMY( 100) DEFINE FILE 10 ( 200020 , 23, E , 1 10 ) , 1 1 ( 200020, 80 , E , 1 1 1 ) CALL SEARCFM MN, I ROW, I COL , NOMX , MXREC ) IF(NOMX.EQ.l) GO TO 15 GO TO 5 15 WRITE( 11' 111 ,77) MN 77 FORMAT( 'UNABLE TO LOCATE MATRIX M»,I2) RETURN 5 READ(10» I 10,2) ( ( A ( I , J ) , J= 1 , ICOL ) , I = 1 , I ROW ) CALL FRANC Z ( A , VALU , JROW , ANORM , JROW ) IFINORM .EO. 0) GO TO 30 35 WRITE ( 11 ' I 11 ,40) MN, ANORM 40 FORMATMNORM OF MATRIX M',I2,' = ',023.16) RETURN 30 WRITE( 11 ' I 11,80) MN 80 FORMAT(« EIGENVALUES OF M',I2) DO 42 I = 1, IROW 42 WRITE ( 11 ' 111 ,45) I , VALU ( I , 1 ) , VALU ( I , 2 ) A5 FORMAT( ' EIGENVALUE ',13,' = ( • , D2 3. 16 , • , • , D2 3. 1 6, • ) » ) GO in 35 2 FORMATUJ23. 16) END 65 SUBROUTINE SCAL AR ( A ,NA ,NAROW ,NACOL , B t NB,NBROW , NBCOL , AMPY,MXREC ) IMPLICIT REAL*8(A-H,0-Z) DIMENSION A(NAROW,NACOL) ,B ( NBROW , NBCOL) COMMON/IVAR/I11, 110 DEFINE FILE 10 ( 200020 , 23,E , I 10 ) , 1 1 ( 200020, 80 , E , 1 1 1 ) MN = NB CALL SEARCH(MN,IROW,ICOL,NOMX,MXREC) IF(NOMX.EQ.l) GO TO 200 READ( 10M10,1)((B(I,J) ,J=1,IC0L) , I = 1,IR0W) 1 F0RMAT(D23.16) DO 10 I = 1,IR0W DO 10 J = 1, ICOL 10 A( I f J ) = AMPY * B( I ,J) MN = NA CALL SEARCH (MN, I ROW , I COL ,NOMX , MXREC ) IF (NOMX.EO.l ) GO TO 200 WRITE ( 10 • 110,1 ) ( (A( I ,J) ,J=1,IC0L) ,1 = 1, I ROW) RETURN 200 WRITE ( 11 • 111 ,350) MN 350 FORMAT(« UNABLE TO LOCATE MATRIX M«,I2) RETURN END 66 SUBROUTINE MX ADD ( B , NB , NBROW , NBCOL ,C , NC , NCROW , NCOL, A , NA, NAROW, 1 NACOL,MXREC) IMPLICIT REAL*8( A-H,0-Z) COMMON/IVAR/111,110 DIMENSION A(NAROW,NACOL ) ,B(NBROW, NBCOL ) »C ( NCROW, NCOL ) DEFINE FILE 10 ( 200020 , 23, E , 1 10 ) , 1 1 ( 200020, 80 , E , 1 1 1 ) N = MN = NB 10 CALL SEARCFKMN, IROW, I COL , NOMX , MXREC ) IF (NOMX.EO.l) GO TO 200 IF (N.EO.l ) GO TO 100 IF(N.E0.2) GO TO 300 READ(10'I10,1M(B(I,J),J = 1, I COL) ,1=1, IROW) 1 F(JRMAT(D23.16) N = 1 MN = NC GO TO 10 100 RFAD(10'I10,1)((C(I,J),J = 1, I COL) ,1 = 1, IROW) N = 2 MN = NA DO 40 I * 1, IROW DO 40 J = 1 , ICOL 40 A( I, J) = B( I ,J ) + C( I ,J) GO TO 10 300 WRITE(10'I10,1)((A(I,J),J=1,IC0L),I=1, IROW) RFTURN 200 WRITE( 11 • I 11,3^0) MN 5bO FORMAT! • UNABLE TO LOCATE MATRIX M',I2) RFTURN END 67 SUBROUTINE PRNTMX ( MN, MXREC ) RFAL*B ANUMB COMMON/IVAR/I11, 110 DEFINE FILE10(200020,23,E,I10), 11 ( 200020,80 , E , 1 1 1 ) CALL SEARCH(MN,IROW, I COL , NOMX , MXREC ) IF(N0MX.E0.1 ) GO TO 40 00 25 I = 1» IROW DO 25 J = 1,IC0L RFADdO' 110,1 ) ANUMB 25 WRITE! 11 • 111 ,2) MN,I,J,ANUMB 1 F0RMAT(D23.16) 2 FORMAT( »M' ,I2,« ( • ,I2,« , • ,I2,« ) = ND23.16) RETURN 40 WRlTEdl' 111,3) MN 3 FORMAK "UNABLE TO LOCATE MATRIX M",I2) RETURN END 68 SUBROUTINE I NVERT ( A A , MA A , MROW, MCOL , RA ,MRA, MRAROW, MRACOL, R, NR, 1 NRROW,A,NA,NAROW,MA,NRC,MXREC) IMPLICIT REAL*8( A-H,0-Z) COMMON/IVAR/111,1 10 DIMENSION A A < MRU W, MROW ),RA (MROW, MROW), A (NRC),R(NRC) DEFINE FILE 10 ( 200020 , 23, E , 1 10 ) , 1 1 ( 200020, 80 , E , I 1 1 ) C C SET UP IDENTITY MATRIX C DO 10 I = 1,MRUW DO 10 J = 1,MRUW IFM.NE.J) GO TU 9 RA( I , J ) = l.OUO GO TO 10 9 RAIUJ) = O.ODO 10 CONTINUE MN = MAA CALL SEARCH IF(JX.F0.2) GU T030 RE 40 IiM COEFFICIENT MATRIX REALM 10 ■ 110,1) ( ( AA( I ,J) , J = l , I COL ) , 1 = 1, IRUW) MM = MK JX = 2 Gli "III 4 READ IN HIGH I HAND SIDE MATRIX 30 REAOC 10 • 110,1) ( (RA( I ,J ) ,J = 1, ICUL) , 1 = 1, IRUW) CALL UGELGZJ R A , A A , J ROW , J RUW , KCOL , KClJL , R , I PRO 1 , A , I PR 02 , EP S , I ER ) Ib( IbK.bO.-l ) GO TO lbb IE( I ER .bO.O) GO 10 466 Ih (IbR.GI.l) WRITE( 11' 111,270) MJ < + 66 WRITE( 11 • I 11,320) MJ,MK 320 F i ) K ki A T ( « SOLVb M',I2,'*X = M',I2) I CM = UO 211 J = 1,1 COL DO 211 I = I, IRUW I C N I = I C IM 1 + 1 211 WRITE! 11* Ill,2bO) I,J,R(ICNT) 2*>0 FORMAT ( IX, • X( • , 12, ' , • , 12, • ) = • ,02 3.16) RETURN ^60 FORMA I ( 1 X , ' UNABLE III SOLVE SYSTEM', 12, 1 ' DOb TO SINGULAR MATRIX' ) ] bb WR ITE( 11 • 111 ,260) MJ RET URN ^70 FORMAT ( IX, ' POSSIBLE LOSS OF SIGNIFICANCE IN ANSWERS TO SYSTEM M' 1,12,' DUE TO ILL CONDITIONING') 1 FORMAT (023, 16) 300 FORMAT! IX, 'M« , 12, • ( ' , 12, • , • , 12, • ) = •,023.16) ^b WR I TE ( 11 • 1 1 1 ,77) MN 77 EORmAT( IX, 'ONARLE TO LOCATE MATRIX M',I2) RETURN 100 STOP E N i ) 72 APPENDIK C USER'S MANUAL 73 ♦♦DEFINITIONS** 1. MATRIX NAME - THIS IS THE LETTER M FOLLOWED BY AN INTEGER BETWEEN 1 AND 99. EXAMPLES - M37,M19,M6. 2. MATRIX FILE - A FILE IN WHICH ALL MATRICES ARE STORED. THIS INCLUDES BOTH MATRICES EXPLICITLY ENTERED BY THE USER AND MATRICES GENERATED BY CERTAIN INSTRUCTIONS. 3. OUTPUT FILE - A FILE IN WHICH RESULTS OF COMPUTATIONS ARE STORED, PLUS A COPY OF ANY MATRIX FROM THE MATRIX FILE THAT THE USER SPECIFIES. THE USER HAS ACCESS TO THE OUTPUT FILE BY MEANS OF THE LIST COMMAND. 4. NUMBER - A SIGNED ( + OR -) OR UNSIGNED INTEGER OR REAL NUMBER, OPTIONALLY FOLLOWED BY THE LETTER D AND A SIGNED OR UNSIGNED INTEGER. EXAMPLES: 123, -54.87D-3, .764D1, -33.D+10, 43.77 **BASIC INSTRUCTIONS** 1. ENTbR MATRIX M## 35.000 54.000 2. SOLVE M## * X = M## 55.000 66.000 3. EIGENVALUE M## 67.000 75.000 4. M## = INVERSE M## 82.000 90.000 5. M## = M## * M## 91.000 97.000 6. NORM M## 76.000 81.000 7. PRINT MATRIX M## 98.000 100.000 8. M## = NUMBER * M## 101.000 107.000 9. m## = M## + M## 108.000 118.000 10. END 119.000 122.000 11. ERR 123.000 133.000 **MEANING OF INSTRUCTIONS** 1. ENTER MATRIX M## - THIS IS THE BASIC COMMAND FOR ENTERING MATRICES INTO THE MATRIX FILE. SMART WILL RESPOND TO THIS COMMAND BY REQUESTING FIRST THE NUMBER OF ROWS IN THE MATRIX, THEN THE NUMBER OF COLUMNS. THE USER WILL TYPE THE APPROPRIATE INTEGER, (BETWEEN 1 AND 99), AFTER EACH REQUEST. AFTER CORRECTLY RECIEVING THIS INFORMATION, SMART WILL REQUEST THE ELEMENTS OF THE MATRIX IN ROW-MAJOR ORDER, (LAST SUBSCRIPT VARYING MOST RAPIDLY). AFTER SMART REQUESTS ELEMENT(I,J) = ,THE USER WILL RESPOND BY TYPING THE VALUE OF THE I,JTH ELEMENT OF THE MATRIX. THIS SHOULD BE A NUMBER AS DEFINED ABOVE. WHEN THE LAST ELEMENT HAS BEEN ENTERED THE USER MAY THEN ENTER ANOTHER MATRIX, OR HE MAY TYPE ONE OR MORE OF THE OTHER COMMANDS. 145.000 180.000 2. SOLVE M## * X = M## - THIS COMMAND SOLVES THE SYSTEM OF LINEAR EQUATIONS A*X = B, WHERE A IS A SQUARE MATRIX, X IS THE MATRIX TO BE COMPUTED, AND B IS A MATRIX WITH THE Ik SAME NUMBER OF ROWS AS A. THE NUMBER OF COLUMNS FOR B CAN VARY FROM 1 TO 99, EACH COLUMN REPRESENTING A SET OF RIGHT HAND SIDE VALUES. MATRICES A AND B HAVE TO BE IN THE MATRIX FILE PRIOR TO USING THE SOLVE INSTRUCTION. THE MATRIX X WILL AUTOMATICALLY BE PLACED IN THE OUTPUT FILE. 145.000 182.000 3. EIGENVALUE M## - THIS COMMAND CAUSES THE COMPUTATION OF THE EIGENVALUES AND, OPTIONALLY, THE ASSOCIATED EIGENVECTORS OF THE NAMED MATRIX. UPON RECEIPT OF THIS COMMAND, SMART WILL ASK THE USER IF HE ALSO WOULD LIKE THE E IGENVECTORS , TO WHICH THE USER WILL RESPOND WITH YES OR NO. THE RESULTS WILL AUTOMATICALLY BE PLACED IN THE OUTPUT FILE. 220.000 223.000 4. NORM M## - THIS COMMAND CAUSES THE COMPUTATION OF THE EUCLIDEAN NORM OF THE SPECIFIED MATRIX, I.E. THE SQUARE ROOT OF THE SUM OF THE SQUARES OF THE MATRIX ELEMENTS. THE NORM WILL AUTOMATICALLY BE PLACED IN THE OUTPUT FILE. 1B6.000 219.000 5. M## = INVERSE M#* - THIS COMMAND CAUSES THE COMPUTATION OF THE INVERSE OF THE RIGHT HAND MATRIX, AND THE RESULT WILL BE STORED IN THE MATRIX FILE AND GIVEN THE NAME ON THE LEFT HAND SIDE. THE LEFT AND RIGHT HAND MATRIX NAMES MUST BE DIFFERENT. IF THE RIGHT HAND MATRIX IS SINGULAR, A MESSAGE TO THAT EFFECT WILL BE PUT INTO THE OUTPUT FILE. 253.000 257.000 h, h#U = M## * M## - THIS COMMAND CAUSES THE COMPUTATION OF THE PRODUCT OF THE TWO RIGHT HAND SIDE MATRICES. THE RESULT WILL BE STORED IN THE MATRIX FILE AND GIVEN THE NAME ON THE LEFT HAND SIDE. THE LEFT HAND SIDE NAME SHOULD NOT RE THE SAME AS EITHER OF THE TWO RIGHT HAND SIDE NAMES. 258.000 259.000 7. PRINT MATRIX M## - THIS COMMAND CAUSES A COPY OF THE NAMED MATRIX TO BE PUT INTO THE OUTPUT FILE. 256.000 263.000 8. m## = NUMBER * M## - THIS COMMAND CAUSES THE MULTIPLICATION OF EACH ELEMENT OF THE RIGHT HAND SIDE MATRIX BY THE NUMBER. THE RESULT WILL BE STORED IN THE MATRIX FILE AND GIVEN THE NAME ON THE LEFT HAND SIDE. THE LEFT AND RIGHT HAND SIDE MATRIX NAMES MUST BE DIFFERENT. 264.000 272.000 M*« s M«ft + M## - THIS COMMAND CAUSES THE COMPUTATION ME IHE SUM OF THE TWO RIGHT HAND SII MATRICES, I.E., CORRESPONDING ELEMENTS ARE ADDED. fHE TWO RIGHT HAND SIDI MATRICES SHOULD HAVE EQUAL NUMBERS OF ROWS AND COLUMNS AND IHEIR RESPECTIVE MAIRIX NAMES SHOULD NUT BE THE SAME AS THf LEET HAND MATRIX NAME. THE RES0L1 75 WILL BE PUT INTO THE MATRIX FILE AND GIVEN THE NAME ON THE LEFT HAND SIDE. 273.000 282.000 10. END - THIS COMMAND SIGNIFIES THE END OF THE SERIES OF MATRIX COMPUTATIONS. IT MUST BE TYPED BEFORE ANY OF THE PREVIOUSLY TYPED COMMANDS WILL BE EXECUTED. 281.000 285.000 11. ERR - THIS COMMAND IS USED WHENEVER THE USER HAPPENS TO MAKE AN ERROR OF ANY SORT WHILE TYPING THE VARIOUS COMMANDS OR RESPONSES. HE CAN THEN RECOVER BY TYPING ERR AND THEN TYPING THE CORRECTED COMMAND OR RESPONSE. THIS PROCESS CAN BE REPEATED AS OFTEN AS NECESSARY, CONTINUING ONTO SUBSEQUENT LINES IF NEED BE. SMART WILL TAKE, AS THE USER COMMAND OR RESPONSE, EVERYTHING ON THE LINE THAT COMES AFTER THE LAST ERR. 183.000 186.000 **EXAMPLE** IN THIS EXAMPLE, WE WILL FIRST SOLVE A 4X4 SYSTEM OF LINEAR EQUATIONS, USING 2 DIFFERENT RIGHT HAND SIDES. THEN WE WILL FIND THE NORM, EIGENVALUES AND EIGENVECTORS OF ANOTHER MATRIX. FINALLY, WE WILL GENERATE THE IDENTITY MATRIX BY FIRST CALCULATING THE INVERSE OF A MATRIX, THEN MULTIPLYING THIS MATRIX BY ITS INVERSE. THE IDENTITY MATRIX WILL BE SCALAR MULTIPLIED BY 20, AND THE RESULTING MATRIX WILL BE ADDED TO ITSELF TO GIVE A MATRIX WITH 40 ALONG THE PRINCIPAL DIAGONAL AND ZEROS ELSEWHERE. PLEASE PROCEED ENTER MATRIX M5 NUMBER OF ROWS = K ERR 4 NUMBER OF COLUMNS = 444 ILLEGAL NUMBER OF COLUMNS NUMBER OF COLUMNS = 4 tLEMENT( 1, 1) = 0.4096D0 ELEMENT( 1, 2) = 123. 4D ERR 0.1234D0 ELEMENT( ELEMENT! 1, 4) = 0.2 D.2 ELEMENT! tLEMENT! ELEMENT! ELEMENT! ELEMENT! bLEMENT! ELEMENT! ELEMENT! ELEMENT! bLEMENT! ELEMENT! ELEMENT! PLEASE PROCEED ENTER MATRIX M7 NUMBER OF ROWS = I ILLEGAL CHARACTER IN NUMBER OF ROWS NUMBER OF ROWS = 4 NUMBER OF COLUMNS = 2 ELEMENT! 1, 1) = 4.043D-1 1, 2) = 123. 4D 1, 3) = 0.3678D0 1, 4) = 0.2943D0 2, 1) = 0.2246D0 2, 2) = 0.3872D0 2, 3) = 0.4015D0 2, 4) = 0.1129D0 3, 1 ) = 0.3645D0 3, 2) = 0.1920D0 3, 3) = 0.3781D0 3, 4) = 0.0643D0 4, 1) = 0.1748D0 4, 2) = 0.4002DO 4, 3) = 0.2786D0 4, 4) = 0.3927D0 76 -0.7568D+0 155.0D-3 0.6224D+1 .000424D+3 -0.2781D-1 0.2557D+0 0.3342D0 M5 ELEMENT! l t 2) ELEMENK 2, 1) = ELEMENT! 2, 2) = ELEMENT! 3, 1) = ELEMENT! 3, 2) = ELEMENT! 4, 1) = ELEMENT! 4, 2) = PLEASE PROCEED SULVE Mb * X = M7 PLEASE PROCEED EM ERR ENTER MATRIX Mb HAS BEEN ENTERED PLEASE PROCEED ENTER MATRIX MIO NUMBER OP ROWS = b NUMBER OF COLUMNS = b ELEMENT! 1, 1) = -.bDO tLEMENT! 1, 2) = -l.ODO ELEMENT! 1, 3) = -l.ODO ELEMENT! 1, 4) = -0.5DO ELEMENI ( 1 , b ) = -1 .ODO ELEMENT! 2, 1) = l.ODO ELEMENT! 2» 2) = O.ODO ELEMENT! 2, 3) = O.ODO ELEMENI ( 2,4) = O.ODO ELEMEN I ( 2, 5) = O.ODO tLEMENT! 3, 1) = O.ODO ELEMENT! 3, 2) = l.ODO ELEMENT! 3, 3) = O.ODO ELEMENT! 3, 4) = O.ODO ELEMENT I 3, b) = O.ODO tLEMENT! 4, 1) = O.ODO tLEMENT! 4, 2) = O.ODO tLFMENI! 4, 3) = l.ODO tLEMENT! 4 f A) = O.ODO tLEMENT! 4, 5) = O.ODO MENTI 5, 1) = O.ODO ■lENl! 5, 2) = O.ODO MEN1 ( 5, 3) = O.ODO MENTi 5, A) = l.ODO MENU 5 f 5) = O.ODO ELF ASF PROCEf M Mil • N ENTERED 301.000 HI 302.000 mi l w/.'jI I HP E I (,EN VECTORS UP [ X N b . DO 1 , / - . ) 200 .'.<• 700 292.000 300.000 302.000 337.000 MIO? ANSWER YES OR NO 77 ELEMENT! ELEMENT! ELEMENT! ELEMENT! ELEMENT! ELEMENT ( ELEMENT! ELEMENT! ELEMENT! ELEMENT! ELEMENT! ELEMENT! ELEMENT! tLEMENT! ELEMENT! ELEMENT! ELEMENT! ELEMENT! ELEMENT! tLEMENT ( ELEMENT! ELEMENT! PLEASE PR M10 = I M10 HAS B PLEASE PR M23 = I PLEASE PR M37 = M PLEASE PR PRINT M PLEASE PR PRINT M PLEASE PR hb - 12 3< Mb HAS BE 12361 D 00, ID 0, IOD 00, 2D 00, i 00, 0.8 6602 540 3 7844 3410-00) 0.2 962 8654642791 7 5D-14) -(J. 86602540378443360 00) -0.8660254037844368D 00) -0.0 ) ;, 1) = . -/6485010505185D-01 If 21 -0.22392850603347440 00 .16647992057946120 01 624 J /h urn) 00 . i i 100604 3502 1 468D 01 , J460509 P531D 01 1077] 660 00 79 ( 2 , 3) = -0. ( 2 , 4) = 0. ( 2 , 5) = -0. ( 3 , 1) = -0. ( 3 r 2) = -0. ( 3 f 3) = 0. ( 3 » A) = 0, ( 3 r 5) = 0. ( A , 1) = -o. ( 4 , 2) = 0. ( 4. , 3) = 0, ( A , 4) = 0. < 4. , 5) = -o. ( 5 , 1 ) = -0. ( 5. , 2) = 0. ( 5 r 3) = -o. ( 5. , 4) = -o. ( 5 > 5) = 0. , 1 ) = 0. r 2) = -0. » 3) = -0. - 4) = -0. 5) - -0. ( 2. - 1) - -o. ( 2, 2) - 0. ( 2, 3) - 0. ( 2, 4) - 0. ( 2, 5) - 0. ( 3, 1 ) = 0. < 3, 2) = 0. ( 3, 3) = 0. ( 3, A) = -o. ( 3, S ) = -o. ( 4, - 1) = -o. ( 4, 2) = 0. ( A, - 3) = -o. ( 4., 4) = 0. ( 4, 3) = -o. ( 5, 1 ) = 0. ( 5, 2) = 0. ( 5, 3) = 0. ( 5, 4) = 0. ( 5, 5) = 0. 1) = 0. 2) = -o. - 3) = -09 4) = -o. 5) = -09 ( 2, 1 ) = -o. ( 2, 2) = 0. ( 2, 3) = 0. ( 2, A) = 0. ( 2, 5) = 0. ( 3, , 1) = 0. ( 3, 2) = 0. ( 3, ,3) = 0.1 ( 3, 4) = -0. 29634870872070640 01 96384464815339380 00 1367284960877871D 01 3619912 2804600900-01 3954902347660918D 00 5487932488321592D 00 2599677923990677D 00 4011193627930617D 00 13861644517523220 00 7719896753707481D 00 29036205829699580 01 13029176973112440 01 44075159029160130 01 9 5 5948 01499 61820D-01 33496199817472220 00 23b7259128545073D 01 1049405115963064D 01 3283528538724351D 01 99999999999999890 00 3053113317719178D-15 99920072 2 16264070-15 34694469 5 19 5361 2 D-l 5 499600 36 1 081 32 02D- 15 24980018 054066000-15 9999999999999994D 00 444089 2098 50062 30-15 1110223024625155D-15 3053113317719178D-15 97144514654701 18D- 15 2 77 5 557 5615628890-16 9999999999999995D 00 8 32 667 2 68468 86710-16 1804112 4150158770-15 2 2 20446049 2 50311 D-l 5 15543122 344752170-14 9999999999999992D 00 2 220446049 2 50311 D-l 5 11 10223024625155D-14 8H817841970012 50D-15 288 6579 8 6402540 50-14 7 6 3278 329429 79490-15 99999999999999900 00 19999999999999960 02 61062 2 663 54384550-14 1 99 840 144432 52 80D- 13 69 388 9390 3902 2 2 30-14 499600 36108 131 98 D-l 4 999200 72 2 162 6402 D-l 4 1999999999999997D 02 8 881784197001246D-14 2 2 20446049 2 503 10D-1 4 61062 2663 5438 35 50-14 1942 8902 9 309402 2 D-14 5551115123125776D-15 99999999999999970 02 1665334536937 73 3D- 14 80 M2 M2 M20 M20 M2 h20 M20 M20 M20 m20 M20 M40 to 40 to 40 i v i<+0 MA-0 h40 to