|
|
1.1 root 1: .ds xl MATLAB Installation
2: .hy 0
3: .de pp
4: .sp
5: .ti +5
6: ..
7: .de hd
8: 'sp 2
9: .if \\n%-1 'tl '\*(xl, page %'
10: .if !\\n%-1 'tl '\n(mo/\n(dy/\n(yr'
11: 'sp 3
12: 'ns
13: ..
14: .de fo
15: 'bp
16: ..
17: .wh 0 hd
18: .wh -7 fo
19: \
20: .sp 3
21: .ce 2
22: MATLAB Installation Guide
23: November, 1983
24: .sp 2
25: .ce 3
26: Cleve Moler
27: Department of Computer Science
28: University of New Mexico
29: .sp 2
30: .pp
31: The MATLAB tape is usually in one of two formats -- a UNIX "tar" tape,
32: or a "generic" tape with the following parameters:
33:
34: 9 track
35: 1600 bits per inch
36: no label
37: 80 characters per record
38: 1600 characters per block
39: 18 files in ASCII, followed by 18 files in EBCDIC
40: .pp
41: There are 36 files on the generic tape. The names of the first 18, and their
42: approximate sizes, are:
43:
44: 1. INSTALL 1100 lines
45: 2. MAT 3900 lines
46: 3. LIB 3339 lines
47: 4. HELPER.66 75 lines
48: 5. HELPER.77 120 lines
49: 6. HELP 750 lines
50: 7. SYS.UNIX 900 lines
51: 8. SYS.VMS 260 lines
52: 9. SYS.TSO 200 lines
53: 10. SYS.CMS 350 lines
54: 11. SYS.DEC10 250 lines
55: 12. SYS.CDC 200 lines
56: 13. SYS.PRIME 350 lines
57: 14. DOC 3960 lines
58: 15. DEMO 21 lines
59: 16. DOC.NROFF 3250 lines
60: 17. MAT.SNGL 3850 lines
61: 18. LIB.SNGL 3339 lines
62:
63: where a line is one 80 character record.
64: .pp
65: The first 18 files are in the ASCII character set.
66: The remaining 18 files are copies of the first 18 in EBCDIC.
67: .pp
68: INSTALL is this document. You can skip over it if you have this hard copy.
69: .pp
70: MAT, LIB, one of the versions of HELPER and one of the versions of SYS
71: together constitute the complete source code for the
72: double precision version of MATLAB.
73: .pp
74: The subroutines in MAT make up the parser and interpreter.
75: They include a COMMON statement which can be
76: changed to change the amount of memory allocated to variables.
77: .pp
78: The subroutines in LIB include modified versions of
79: the necessary routines from LINPACK, EISPACK and the BLAS.
80: These do not contain any COMMON statements and do not have to be
81: changed if the size of the stack is changed.
82: .pp
83: There are two versions of HELPER, the subroutine
84: which manages the help facility.
85: The version in HELPER.66 is written in Fortran 66 and
86: uses sequential i/o.
87: The version in HELPER.77 is written in Fortran 77 and uses
88: character variables and direct access i/o.
89: If your system supports
90: both versions, you will probably want to choose the direct access one --
91: it should be much faster.
92: If you choose the direct access version, you will have to run
93: a preprocessor named HELPSET, which is also in file HELPER.77.
94: .pp
95: HELP is the source text for the help facility. It is read by the
96: sequential version of HELPER, or preprocessed by HELPSET into two files which
97: are then read by the direct access version of HELPER. HELP is also included as
98: an appendix in the User's Guide.
99: .pp
100: The subroutines in one of the versions of SYS
101: may have to be modified for your particular
102: operating system. They involve file access and floating point word format.
103: I have included versions that should work on several different
104: operating systems. Pick the version that is closest to your own
105: system and make any changes you need.
106: There are no machine dependent constants.
107: .pp
108: DOC is a report entitled "MATLAB Users' Guide".
109: It should be printed on a nice printer with upper and lower case;
110: there are 66 lines per page.
111: Make as many copies as you need, or order copies from us at New Mexico.
112: .pp
113: DEMO contains a demonstration exec file which can be accessed
114: by the exec command in MATLAB.
115: On most systems, all that is required is
116: EXEC('DEMO') or EXEC('DEMO',7).
117: On some systems, like TSO and NOS, it will be necessary
118: to attach file DEMO to unit 2 and then EXEC(2) or EXEC(2,7).
119: .pp
120: DOC.NROFF is the input to the UNIX text processing system
121: that was used to produce DOC. This may be useful if you want
122: to print the users' guide in a different format.
123: .pp
124: MAT.SNGL and LIB.SNGL are the single precision versions of MAT and LIB.
125: It is suggested that these be used only on systems with long words
126: (48 bit floating point fraction) or small memories.
127: .pp
128: The first thing to worry about is the character set.
129: The use of an upper-lower case character set is highly desirable,
130: but not essential.
131: Read the tape
132: and look at the first 50 or so lines of MAT.
133: This is the subroutine MATLAB, a listing
134: of which is included in this document.
135: Check the comments near the beginning to see if the special characters
136: are ok. The ones we have had trouble with include:
137: SEMI ; BSLASH \\ COLON : LESS < GREAT >
138: .br
139: Any characters which are not ok should be changed in the comment and
140: in the data statement which follows.
141: The alternate character set includes the lower case letters as well
142: as substitutes for some of the special characters, such as \\ and :,
143: which are not on some terminals.
144: Do not worry too much about the alternate character set now.
145: These data statements in subroutine MATLAB are the only place in the
146: source code where the special characters occur.
147: (If you want to get fancy, there is a data statement involving BEL
148: in subroutine ERROR near the end of file MAT.
149: Change 1H-blank to 1H-control G to get your terminal to ring its
150: bell for any error.)
151: .pp
152: The files DOC and HELP are full of special characters, including
153: < > [ ] : ; \\ |
154: .br
155: If they are not ok, I hope it is not too difficult to fix them up.
156: .pp
157: I have used several FORTRAN constructions which are only semi-standard,
158: and which may have to be changed for some systems:
159: Single quote (') in FORMATS instead of a tribute to Hollerith.
160: Entire arrays initialized in DATA statements.
161: Use of END= in READ statements.
162: .br
163: I have not asked PFORT to tell me what else is non-standard.
164: .pp
165: Some interactive FORTRAN systems use column 1 for carriage control and
166: others don't. If your system does not, edit file MAT and delete
167: all "1X," . There are 131 occurrences.
168: .pp
169: The main program in file SYS simply calls MATLAB.
170: It may have to be modified to control the printing of
171: underflow and overflow messages.
172: The ground rules are: Underflows are possible, but are harmless if
173: they are quietly set to zero.
174: Overflows are error conditions. It would be nice to print a message
175: and continue.
176: .pp
177: A listing of a typical version of SYS,
178: using some Fortran 77 for clarity, is included in this document.
179: I hope it is fairly easy to see what the various subroutines
180: do and how they have to be revised for your system.
181: Please send me copies of versions appropriate for your system.
182: .pp
183: The amount of memory required can be altered by a global text edit on MAT
184: which changes the matrix element stack length from
185: 5005 to something else. Be sure to get the statement
186: VSIZE = 5005
187: .br
188: in the subroutine MATLAB.
189: With this setting of the stack length, MATLAB requires about a 300K byte
190: region on an IBM system.
191: The length has to be reduced somewhat to get MATLAB to fit
192: into a 64K word region on a CDC system.
193: Since each matrix element occupies two double or single precision words,
194: an increase of 1000 in the stack length requires an additional
195: 16K bytes or 2000 words.
196: .pp
197: It is possible to get by with less memory if you use overlays.
198: The simplest way to do this is the following.
199:
200: .ne 5
201: ROOT
202: |
203: -------------------------------
204: | | | | | |
205: S0 S1 S2 S3 S4 S5
206:
207: Only ROOT plus one of the segments S0 through S5 need be in
208: memory at any one time. The segments do not call each other,
209: but return to the root. All the relevant calls are near the end
210: of subroutine MATLAB in the root.
211: There are five labeled COMMON blocks which are shared by the
212: root and all the segments.
213: The various segments consist of:
214:
215: .ne 7
216: ROOT:
217: MAIN MATLAB STACK1
218: PRINT PRNTID FUNS
219: STACKP ERROR FILES
220: HELPER PYTHAG FORMZ
221: FLOP PROMPT
222: Plus everything in file LIB not mentioned below.
223:
224: .ne 6
225: S0:
226: PARSE COMAND CLAUSE
227: EXPR TERM FACTOR
228: STACKG STACK2 GETSYM
229: GETLIN GETCH GETVAL
230: EDIT XCHAR
231:
232: .ne 4
233: S1:
234: MATFN1 WGECO WGEFA
235: WGESL WGEDI WPOFA
236: RREF HILBER
237:
238: .ne 3
239: S2:
240: MATFN2 CORTH COMQR3
241: HTRIDI HTRIBK IMTQL2
242:
243: .ne 2
244: S3:
245: MATFN3 WSVDC
246:
247: .ne 2
248: S4:
249: MATFN4 WQRDC WQRSL
250:
251: .ne 4
252: S5:
253: MATFN5 MATFN6 MAGIC
254: SAVLOD RAT USER
255: PLOT
256:
257: If you have enough room, combine ROOT and S0.
258: With more room, combine ROOT, S0 and S5.
259: If you use some overlay structure, please send me a description of
260: how it is done on your system.
261: .pp
262: In case anybody needs to know, here are the changes necessary
263: to convert from double to single precision. They can all be
264: safely accomplished by simple global text changes in MAT, LIB
265: and an appropriate version of SYS.
266:
267: DOUBLE PRECISION REAL
268: DOUBLE- REAL-
269: DSQRT SQRT
270: DLOG ALOG
271: DEXP EXP
272: DSIN SIN
273: DCOS COS
274: DATAN ATAN
275: DABS ABS
276: DMAX1 AMAX1
277: DMIN1 AMIN1
278: IDINT IFIX
279: DSIGN SIGN
280: DMOD AMOD
281: D0 E0
282: D1 E1
283: D2 E2
284: D9 E9
285:
286: .pp
287: Here are some additional comments that apply to individual systems.
288: .sp 2
289: VAX UNIX.
290: .pp
291: If you have read the "tar" format tape, see file README and
292: the makefile. Ignore the rest of this section.
293: .pp
294: It is essential to change the single backslash \\ in the data
295: statement near the beginning of file MAT to a double backslash \\\\.
296: If this is not done, the F77 compiler produces an obscure error message
297: about "dataalpha" being too long.
298: .pp
299: Increase the size of the stack to take advantage of the virtual memory.
300: Eliminate all the "1X," in formats.
301: Change the statement
302: CASE = 0 in MATLAB to CASE = 1 to get lower case file names.
303: All these changes can be accomplished
304: by applying the following ed or vi commands to file MAT.
305:
306: 1,$s/\\/\\\\/g
307: 1,$s/5005/50005/g
308: 1,$s/1X,/0X,/g
309: 1,$s/CASE = 0/CASE = 1/
310: 1,$s/BEL\/1H /BEL\/1H^G/
311: 1,$s/LCT(2) = 25/LCT(2) = 25000/
312: .pp
313: The compilation should suppress warnings about initializing non-character
314: variables with Hollerith and should use the Berkeley version of the
315: i/o support routines. This can be accomplished with:
316:
317: % f77 -w66 mat.f lib.f helper.f sys.f -lI77uc
318: .pp
319: Gary Klimowicz and Lee Ward of UNM have developed a overflow fault handler
320: for use with VAX UNIX. A copy of their C program in included in SYS.UNIX
321: and on the "tar" tape.
322: .sp 3
323: VAX VMS
324: .pp
325: SYS.VMS contains an extra subroutine for proper handling of floating
326: point overflow. The main program includes a call to the system
327: which initializes this handling.
328: .pp
329: Integer overflow is expected in the the print routine and in
330: random number generator.
331: The integer overflow messages can be turned off by
332:
333: FORTRAN/NOCHECK MAT.FOR,LIB.FOR
334: .sp 3
335: IBM (TSO)
336: .br
337: (Thanks to Jack Dongarra at Argonne.)
338: .pp
339: The main program in SYS.TSO includes the appropriate calls
340: to the IBM system utility ERRSET that turns off verbose
341: underflow and overflow messages.
342: .pp
343: Unfortunately, TSO does not have a mechanism for opening
344: files during execution. It is necessary to use file numbers with SAVE,
345: LOAD and EXEC.
346: .pp
347: We have to specify LRECL=80 for terminal input
348: on unit 5 to get blanks added to input lines. It is a good
349: idea to set up a clist something like the following.
350:
351: FREE FILE(FT05F001 FT06F001 FT09F001 FT01F001 FT02F001)
352: FREE ATTRLIST(AT80)
353: ATTR AT80 LRECL(80) BLKSIZE(80) RECFM(F)
354: ALLOC FILE(FT05F001) DA(*) USING(AT80)
355: ALLOC FILE(FT06F001) DA(*)
356: ALLOC FILE(FT09F001) DA('MATLAB.HELP.DATA')
357: ALLOC FILE(FT01F001) DA(SAVLOD.DATA)
358: ALLOC FILE(FT02F001) DA('MATLAB.DEMO.DATA')
359: CALL 'MATLAB.LOAD(MATMOD)'
360:
361: With this arrangement, the DEMO file can be executed by exec(2).
362: .sp 3
363: IBM (CMS)
364: .br
365: (Thanks to Jack Dongarra at Argonne and David Gay at MIT.)
366: .pp
367: Entering a blank line in response to the MATLAB prompt generates
368: an end-of-file from terminal input (Fortran unit FT05F001).
369: This results in a call from GETLIN to FILES with LUNIT = -5.
370: The terminal is "rewound" and control eventually returned to PARSE
371: which prints another prompt. I hope this works.
372: .pp
373: An assembly language routine used to attach files with names generated
374: by MATLAB to Fortran unit numbers is included in SYS.CMS.
375: .sp 3
376: DEC-10
377: .br
378: (Thanks to Stan Eisenstat and Craig Douglas at Yale.)
379: .pp
380: The hyperbolic trig functions SINH and COSH are not available
381: on the DEC system. Fortran subroutines are included in the SYS.DEC10 file.
382: .sp 3
383: PRIME 400
384: .br
385: (Thanks to Richard Franke and Drexel University.)
386: .pp
387: The terminal is Fortran I/O unit number 1.
388: Subroutine MATLAB has to be changed so that
389: RTE = 5 becomes RTE = 1
390: WTE = 6 becomes WTE = 1
391: .br
392: Subroutine MATFN5 has to be changed so that
393: WIO = 1 becomes WIO = 8
394: LUNIT = 1 becomes LUNIT = 8 (in two places).
395: .sp 3
396: CDC
397: .pp
398: CDC systems offer exciting challenges as far as portability is concerned.
399: The first question is: which character set should be used?
400: An easy approach is to convert everything to the venerable 6-bit character set.
401: Even so, you may have trouble
402: with the colon, which is a pretty important MATLAB character.
403: It is far more fun to try to use upper and lower case and all
404: the special symbols.
405: I have succeeded in doing this
406: with the 6/12-bit setup used on the NOS system at Sandia,
407: but have given up with the 6/18-bit coding on LTSS at Los Alamos.
408: .pp
409: In "ASCII" mode on NOS, lower case characters are represented by
410: 12 bits -- the first 6 bits are octal 76 and the last 6 are the
411: corresponding upper case character. They count as two characters.
412: So, the following changes are required in file MAT. Several of
413: the mixed case strings in FORMAT statements extend beyond
414: column 72. You might as well convert these to all upper case.
415: All the 80A1's in FORMATS should be changed to 132A1's and
416: all the DATA statements initializing LRECL should be changed from 80 to 132.
417: The DATA statement for ALPHB in subroutine MATLAB can be changed to
418: have all upper case alphabetic characters because subroutine XCHAR
419: will catch the prefix octal 76.
420: .pp
421: An important change involves our friend the colon, which becomes
422: a 12-bit octal 7404. In the DATA statement for ALPHA, make the
423: element just before 1H+ into a 1H(percent sign).
424: And, in the DATA statement for ALPHB, make the corresponding element
425: into a 2H(colon).
426: Then read the comments in subroutine XCHAR in file SYS.CDC and make
427: sure that the DATA statements there are correct.
428: .pp
429: The FTN5 compiler should take MATLAB pretty much is it is.
430: The older FTN compiler requires two familiar changes to the
431: entire source code. First, the END= in the READ statements have
432: to be replaced by IF (EOF) GO TO ... .
433: Second, the single quotes in FORMATS have to be replaced with
434: asterisks.
435: .sp 3
436: Good luck. Please let me know what difficulties you have, and what
437: I have left out of this guide. You can call me at:
438: 505-268-8631 (home)
439: 505-277-3112 (office)
440:
441: ------------
442: .pp
443: The support of the National Science Foundation and the use of
444: facilities at Argonne National Laboratory, Los Alamos National Laboratory
445: and Stanford Linear Accelerator Center is gratefully acknowledged.
446: So is the assistance of the many people who have installed early
447: versions of MATLAB.
448: .bp
449: .ll 80
450: .nf
451: Contents of file MAT:
452:
453: SUBROUTINE MATLAB(INIT)
454: SUBROUTINE PARSE
455: SUBROUTINE COMAND(ID)
456: SUBROUTINE CLAUSE
457: SUBROUTINE EXPR
458: SUBROUTINE TERM
459: SUBROUTINE FACTOR
460: SUBROUTINE FUNS(ID)
461: SUBROUTINE STACKP(ID)
462: SUBROUTINE STACKG(ID)
463: SUBROUTINE STACK1(OP)
464: SUBROUTINE STACK2(OP)
465: SUBROUTINE PRINT(ID,K)
466: SUBROUTINE PRNTID(ID,ARGCNT)
467: SUBROUTINE GETSYM
468: SUBROUTINE GETLIN
469: SUBROUTINE GETCH
470: SUBROUTINE GETVAL(S)
471: SUBROUTINE MATFN1
472: SUBROUTINE MATFN2
473: SUBROUTINE MATFN3
474: SUBROUTINE MATFN4
475: SUBROUTINE MATFN5
476: SUBROUTINE MATFN6
477: SUBROUTINE ERROR(N)
478: DOUBLE PRECISION FUNCTION PYTHAG(A,B)
479: SUBROUTINE RAT(X,LEN,MAXD,D)
480:
481: Contents of file HELPER.66:
482:
483: SUBROUTINE HELPER(H) -- Sequential version
484:
485: Contents of file HELPER.77:
486:
487: PROGRAM HLPSET -- Direct access setup
488: SUBROUTINE HELPER(H) -- Direct access version
489:
490: Contents of file SYS:
491:
492: PROGRAM MAIN
493: SUBROUTINE FILES(LUNIT,NAME)
494: SUBROUTINE SAVLOD(LUNIT,ID,M,N,IMG,JOB,XREAL,XIMAG)
495: SUBROUTINE FORMZ(LUNIT,X,Y)
496: DOUBLE PRECISION FUNCTION FLOP(X)
497: SUBROUTINE XCHAR(BUF,K)
498: SUBROUTINE USER(A,M,N,S,T)
499: SUBROUTINE PROMPT(PAUSE)
500: SUBROUTINE PLOT(LUNIT,X,Y,N,P,K,BUF)
501: SUBROUTINE EDIT(BUF,N)
502: .bp
503: Contents of file LIB:
504:
505: SUBROUTINE WGECO(AR,AI,LDA,N,IPVT,RCOND,ZR,ZI)
506: SUBROUTINE WGEFA(AR,AI,LDA,N,IPVT,INFO)
507: SUBROUTINE WGESL(AR,AI,LDA,N,IPVT,BR,BI,JOB)
508: SUBROUTINE WGEDI(AR,AI,LDA,N,IPVT,DETR,DETI,WORKR,WORKI,JOB)
509: SUBROUTINE WPOFA(AR,AI,LDA,N,INFO)
510: SUBROUTINE RREF(AR,AI,LDA,M,N,EPS)
511: SUBROUTINE HILBER(A,LDA,N)
512: SUBROUTINE HTRIDI(NM,N,AR,AI,D,E,E2,TAU)
513: SUBROUTINE HTRIBK(NM,N,AR,AI,TAU,M,ZR,ZI)
514: SUBROUTINE IMTQL2(NM,N,D,E,Z,IERR,JOB)
515: SUBROUTINE CORTH(NM,N,LOW,IGH,AR,AI,ORTR,ORTI)
516: SUBROUTINE COMQR3(NM,N,LOW,IGH,ORTR,ORTI,HR,HI,WR,WI,ZR,ZI,IERR
517: SUBROUTINE WSVDC(XR,XI,LDX,N,P,SR,SI,ER,EI,UR,UI,LDU,VR,VI,LDV,
518: SUBROUTINE WQRDC(XR,XI,LDX,N,P,QRAUXR,QRAUXI,JPVT,WORKR,WORKI,
519: SUBROUTINE WQRSL(XR,XI,LDX,N,K,QRAUXR,QRAUXI,YR,YI,QYR,QYI,QTYR,
520: SUBROUTINE MAGIC(A,LDA,N)
521: SUBROUTINE BASE(X,B,EPS,S,N)
522: DOUBLE PRECISION FUNCTION URAND(IY)
523: SUBROUTINE WMUL(AR,AI,BR,BI,CR,CI)
524: SUBROUTINE WDIV(AR,AI,BR,BI,CR,CI)
525: SUBROUTINE WSIGN(XR,XI,YR,YI,ZR,ZI)
526: SUBROUTINE WSQRT(XR,XI,YR,YI)
527: SUBROUTINE WLOG(XR,XI,YR,YI)
528: SUBROUTINE WATAN(XR,XI,YR,YI)
529: DOUBLE PRECISION FUNCTION WNRM2(N,XR,XI,INCX)
530: DOUBLE PRECISION FUNCTION WASUM(N,XR,XI,INCX)
531: INTEGER FUNCTION IWAMAX(N,XR,XI,INCX)
532: SUBROUTINE WRSCAL(N,S,XR,XI,INCX)
533: SUBROUTINE WSCAL(N,SR,SI,XR,XI,INCX)
534: SUBROUTINE WAXPY(N,SR,SI,XR,XI,INCX,YR,YI,INCY)
535: DOUBLE PRECISION FUNCTION WDOTUR(N,XR,XI,INCX,YR,YI,INCY)
536: DOUBLE PRECISION FUNCTION WDOTUI(N,XR,XI,INCX,YR,YI,INCY)
537: DOUBLE PRECISION FUNCTION WDOTCR(N,XR,XI,INCX,YR,YI,INCY)
538: DOUBLE PRECISION FUNCTION WDOTCI(N,XR,XI,INCX,YR,YI,INCY)
539: SUBROUTINE WCOPY(N,XR,XI,INCX,YR,YI,INCY)
540: SUBROUTINE WSET(N,XR,XI,YR,YI,INCY)
541: SUBROUTINE WSWAP(N,XR,XI,INCX,YR,YI,INCY)
542: SUBROUTINE RSET(N,DX,DY,INCY)
543: SUBROUTINE RSWAP(N,X,INCX,Y,INCY)
544: SUBROUTINE RROT(N,DX,INCX,DY,INCY,C,S)
545: SUBROUTINE RROTG(DA,DB,C,S)
546: LOGICAL FUNCTION EQID(X,Y)
547: SUBROUTINE PUTID(X,Y)
548: DOUBLE PRECISION FUNCTION ROUND(X)
549: .bp
550: First subroutine in file MAT:
551:
552: SUBROUTINE MATLAB(INIT)
553: C INIT = 0 FOR ORDINARY FIRST ENTRY
554: C = POSITIVE FOR SUBSEQUENT ENTRIES
555: C = NEGATIVE FOR SILENT INITIALIZATION (SEE MATZ)
556: C
557: DOUBLE PRECISION STKR(5005),STKI(5005)
558: INTEGER IDSTK(4,48),LSTK(48),MSTK(48),NSTK(48),VSIZE,LSIZE,BOT,TOP
559: INTEGER ALFA(52),ALFB(52),ALFL,CASE
560: INTEGER IDS(4,32),PSTK(32),RSTK(32),PSIZE,PT,PTZ
561: INTEGER DDT,ERR,FMT,LCT(4),LIN(1024),LPT(6),RIO,WIO,RTE,WTE,HIO
562: INTEGER SYM,SYN(4),BUF(256),CHAR,FLP(2),FIN,FUN,LHS,RHS,RAN(2)
563: COMMON /VSTK/ STKR,STKI,IDSTK,LSTK,MSTK,NSTK,VSIZE,LSIZE,BOT,TOP
564: COMMON /ALFS/ ALFA,ALFB,ALFL,CASE
565: COMMON /RECU/ IDS,PSTK,RSTK,PSIZE,PT,PTZ
566: COMMON /IOP/ DDT,ERR,FMT,LCT,LIN,LPT,RIO,WIO,RTE,WTE,HIO
567: COMMON /COM/ SYM,SYN,BUF,CHAR,FLP,FIN,FUN,LHS,RHS,RAN
568: C
569: DOUBLE PRECISION S,T
570: INTEGER EPS(4),FLOPS(4),EYE(4),RAND(4)
571: C
572: C CHARACTER SET
573: C 0 10 20 30 40 50
574: C
575: C 0 0 A K U COLON : LESS <
576: C 1 1 B L V PLUS + GREAT >
577: C 2 2 C M W MINUS -
578: C 3 3 D N X STAR *
579: C 4 4 E O Y SLASH /
580: C 5 5 F P Z BSLASH \\
581: C 6 6 G Q BLANK EQUAL =
582: C 7 7 H R LPAREN ( DOT .
583: C 8 8 I S RPAREN ) COMMA ,
584: C 9 9 J T SEMI ; QUOTE '
585: C
586: INTEGER ALPHA(52),ALPHB(52)
587: DATA ALPHA /1H0,1H1,1H2,1H3,1H4,1H5,1H6,1H7,1H8,1H9,
588: $ 1HA,1HB,1HC,1HD,1HE,1HF,1HG,1HH,1HI,1HJ,
589: $ 1HK,1HL,1HM,1HN,1HO,1HP,1HQ,1HR,1HS,1HT,
590: $ 1HU,1HV,1HW,1HX,1HY,1HZ,1H ,1H(,1H),1H;,
591: $ 1H:,1H+,1H-,1H*,1H/,1H\\,1H=,1H.,1H,,1H',
592: $ 1H<,1H>/
593: C
594: C ALTERNATE CHARACTER SET
595: C
596: DATA ALPHB /1H0,1H1,1H2,1H3,1H4,1H5,1H6,1H7,1H8,1H9,
597: $ 1Ha,1Hb,1Hc,1Hd,1He,1Hf,1Hg,1Hh,1Hi,1Hj,
598: $ 1Hk,1Hl,1Hm,1Hn,1Ho,1Hp,1Hq,1Hr,1Hs,1Ht,
599: $ 1Hu,1Hv,1Hw,1Hx,1Hy,1Hz,1H ,1H(,1H),1H;,
600: $ 1H|,1H+,1H-,1H*,1H/,1H$,1H=,1H.,1H,,1H",
601: $ 1H[,1H]/
602: C
603: DATA EPS/14,25,28,36/,FLOPS/15,21,24,25/
604: DATA EYE/14,34,14,36/,RAND/27,10,23,13/
605: C
606: IF (INIT .GT. 0) GO TO 90
607: C
608: C RTE = UNIT NUMBER FOR TERMINAL INPUT
609: C WTE = UNIT NUMBER FOR TERMINAL OUTPUT
610: C HIO = UNIT NUMBER FOR HELP FILE
611: RTE = 5
612: WTE = 6
613: HIO = 9
614: C
615: IF (INIT .GE. 0) WRITE(WTE,100)
616: 100 FORMAT(//1X,' < M A T L A B >'
617: $ /1X,' Version of --/--/--')
618: C
619: C ASK HELPER TO OPEN HELP FILE
620: BUF(1) = 0
621: CALL HELPER(BUF)
622: C
623: C RANDOM NUMBER SEED
624: RAN(1) = 0
625: C
626: C INITIAL LINE LIMIT
627: LCT(2) = 25
628: C
629: ALFL = 52
630: CASE = 1
631: C CASE = 1 for file names in lower case
632: DO 20 I = 1, ALFL
633: ALFA(I) = ALPHA(I)
634: ALFB(I) = ALPHB(I)
635: 20 CONTINUE
636: C
637: VSIZE = 50005
638: LSIZE = 48
639: PSIZE = 32
640: BOT = LSIZE-3
641: CALL WSET(5,0.0D0,0.0D0,STKR(VSIZE-4),STKI(VSIZE-4),1)
642: CALL PUTID(IDSTK(1,LSIZE-3),EPS)
643: LSTK(LSIZE-3) = VSIZE-4
644: MSTK(LSIZE-3) = 1
645: NSTK(LSIZE-3) = 1
646: S = 1.0D0
647: 30 S = S/2.0D0
648: T = 1.0D0 + S
649: IF (T .GT. 1.0D0) GO TO 30
650: STKR(VSIZE-4) = 2.0D0*S
651: CALL PUTID(IDSTK(1,LSIZE-2),FLOPS)
652: LSTK(LSIZE-2) = VSIZE-3
653: MSTK(LSIZE-2) = 1
654: NSTK(LSIZE-2) = 2
655: CALL PUTID(IDSTK(1,LSIZE-1), EYE)
656: LSTK(LSIZE-1) = VSIZE-1
657: MSTK(LSIZE-1) = -1
658: NSTK(LSIZE-1) = -1
659: STKR(VSIZE-1) = 1.0D0
660: CALL PUTID(IDSTK(1,LSIZE), RAND)
661: LSTK(LSIZE) = VSIZE
662: MSTK(LSIZE) = 1
663: NSTK(LSIZE) = 1
664: FMT = 1
665: FLP(1) = 0
666: FLP(2) = 0
667: DDT = 0
668: RAN(2) = 0
669: PTZ = 0
670: PT = PTZ
671: ERR = 0
672: RIO = RTE
673: WIO = 0
674: IF (INIT .LT. 0) RETURN
675: C
676: 90 CALL PARSE
677: IF (FUN .EQ. 1) CALL MATFN1
678: IF (FUN .EQ. 2) CALL MATFN2
679: IF (FUN .EQ. 3) CALL MATFN3
680: IF (FUN .EQ. 4) CALL MATFN4
681: IF (FUN .EQ. 5) CALL MATFN5
682: IF (FUN .EQ. 6) CALL MATFN6
683: IF (FUN .EQ. 21) CALL MATFN1
684: IF (FUN .NE. 99) GO TO 90
685: RETURN
686: END
687: .bp
688: Typical file SYS (Nonstandard stuff in lower case):
689:
690: C PROGRAM MAIN
691: call overflow-control
692: CALL MATLAB(0)
693: STOP
694: END
695:
696:
697: SUBROUTINE FILES(LUNIT,NAME)
698: INTEGER LUNIT,NAME(32)
699: C
700: C SYSTEM DEPENDENT ROUTINE TO ALLOCATE FILES
701: C LUNIT = LOGICAL UNIT NUMBER
702: C NAME = FILE NAME, 1 CHARACTER PER WORD
703: C
704: character*32 nam
705: c
706: c close exec, save, load and print files
707: if (lunit .lt. 0) then
708: close(unit=-lunit)
709: return
710: end if
711: c
712: c Fortran 77 internal file conversion from 32a1 to character*32
713: write(nam,'(32a1)') name
714: c
715: c formatted i/o for exec and print
716: if (lunit .gt. 2) open(unit=lunit,file=nam)
717: c
718: c unformatted i/o for save and load
719: if (lunit .le. 2) open(unit=lunit,file=nam,form='unformatted')
720: c
721: c rewind all except diary
722: if (lunit .ne. 8) rewind lunit
723: c
724: RETURN
725: END
726:
727:
728: SUBROUTINE SAVLOD(LUNIT,ID,M,N,IMG,JOB,XREAL,XIMAG)
729: INTEGER LUNIT,ID(4),M,N,IMG,JOB
730: DOUBLE PRECISION XREAL(1),XIMAG(1)
731: C
732: C IMPLEMENT SAVE AND LOAD
733: C LUNIT = LOGICAL UNIT NUMBER
734: C ID = NAME, FORMAT 4A1
735: C M, N = DIMENSIONS
736: C IMG = NONZERO IF XIMAG IS NONZERO
737: C JOB = 0 FOR SAVE
738: C = SPACE AVAILABLE FOR LOAD
739: C XREAL, XIMAG = REAL AND OPTIONAL IMAGINARY PARTS
740: C
741: C THIS VERSION USES UNFORMATTED READ AND WRITE
742: C
743: IF (JOB .GT. 0) GO TO 20
744: C
745: C SAVE
746: 10 WRITE(LUNIT) ID,M,N,IMG
747: DO 15 J = 1, N
748: K = (J-1)*M+1
749: L = J*M
750: WRITE(LUNIT) (XREAL(I),I=K,L)
751: IF (IMG .NE. 0) WRITE(LUNIT) (XIMAG(I),I=K,L)
752: 15 CONTINUE
753: RETURN
754: C
755: C LOAD
756: 20 READ(LUNIT,END=30) ID,M,N,IMG
757: IF (M*N .GT. JOB) GO TO 30
758: DO 25 J = 1, N
759: K = (J-1)*M+1
760: L = J*M
761: READ(LUNIT,END=30) (XREAL(I),I=K,L)
762: IF (IMG .NE. 0) READ(LUNIT,END=30) (XIMAG(I),I=K,L)
763: 25 CONTINUE
764: RETURN
765: C
766: C END OF FILE
767: 30 M = 0
768: N = 0
769: RETURN
770: END
771:
772:
773: SUBROUTINE FORMZ(LUNIT,X,Y)
774: DOUBLE PRECISION X,Y
775: C
776: C SYSTEM DEPENDENT ROUTINE TO PRINT WITH Z FORMAT
777: C
778: IF (Y .NE. 0.0D0) WRITE(LUNIT,10) X,Y
779: IF (Y .EQ. 0.0D0) WRITE(LUNIT,10) X
780: 10 format(2z18)
781: RETURN
782: END
783:
784:
785: DOUBLE PRECISION FUNCTION FLOP(X)
786: DOUBLE PRECISION X
787: C SYSTEM DEPENDENT FUNCTION
788: C COUNT AND POSSIBLY CHOP EACH FLOATING POINT OPERATION
789: C FLP(1) IS FLOP COUNTER
790: C FLP(2) IS NUMBER OF PLACES TO BE CHOPPED
791: C
792: INTEGER SYM,SYN(4),BUF(256),CHAR,FLP(2),FIN,FUN,LHS,RHS,RAN(2)
793: COMMON /COM/ SYM,SYN,BUF,CHAR,FLP,FIN,FUN,LHS,RHS,RAN
794: C
795: double precision mask(14),xx,mm
796: real mas(2,14)
797: logical lx(2),lm(2)
798: equivalence (lx(1),xx),(lm(1),mm)
799: equivalence (mask(1),mas(1))
800: data mas/
801: $ z'ffffffff',z'fff0ffff',
802: $ z'ffffffff',z'ff00ffff',
803: $ z'ffffffff',z'f000ffff',
804: $ z'ffffffff',z'0000ffff',
805: $ z'ffffffff',z'0000fff0',
806: $ z'ffffffff',z'0000ff00',
807: $ z'ffffffff',z'0000f000',
808: $ z'ffffffff',z'00000000',
809: $ z'fff0ffff',z'00000000',
810: $ z'ff00ffff',z'00000000',
811: $ z'f000ffff',z'00000000',
812: $ z'0000ffff',z'00000000',
813: $ z'0000fff0',z'00000000',
814: $ z'0000ff80',z'00000000'/
815: C
816: FLP(1) = FLP(1) + 1
817: K = FLP(2)
818: FLOP = X
819: IF (K .LE. 0) RETURN
820: FLOP = 0.0D0
821: IF (K .GE. 15) RETURN
822: XX = X
823: MM = MASK(K)
824: LX(1) = and(LX(1),LM(1))
825: LX(2) = and(LX(2),LM(2))
826: FLOP = XX
827: RETURN
828: END
829:
830:
831: SUBROUTINE XCHAR(BUF,K)
832: INTEGER BUF(1),K
833: C
834: C SYSTEM DEPENDENT ROUTINE TO HANDLE SPECIAL CHARACTERS
835: C
836: INTEGER DDT,ERR,FMT,LCT(4),LIN(1024),LPT(6),RIO,WIO,RTE,WTE
837: COMMON /IOP/ DDT,ERR,FMT,LCT,LIN,LPT,RIO,WIO,RTE,WTE
838: write(WTE,10) buf(1)
839: 10 format(A1,' is not a MATLAB character.')
840: RETURN
841: END
842:
843:
844: SUBROUTINE USER(A,M,N,S,T)
845: DOUBLE PRECISION A(M,N),S,T
846: C
847: INTEGER A3(9)
848: DATA A3 /-149,537,-27,-50,180,-9,-154,546,-25/
849: IF (A(1,1) .NE. 3.0D0) RETURN
850: DO 10 I = 1, 9
851: A(I,1) = A3(I)
852: 10 CONTINUE
853: M = 3
854: N = 3
855: RETURN
856: END
857:
858:
859: SUBROUTINE PROMPT(PAUSE)
860: INTEGER PAUSE
861: C
862: C ISSUE MATLAB PROMPT WITH OPTIONAL PAUSE
863: C
864: INTEGER DDT,ERR,FMT,LCT(4),LIN(1024),LPT(6),RIO,WIO,RTE,WTE
865: COMMON /IOP/ DDT,ERR,FMT,LCT,LIN,LPT,RIO,WIO,RTE,WTE
866: WRITE(WTE,10)
867: IF (WIO .NE. 0) WRITE(WIO,10)
868: 10 FORMAT(1X,/'<>')
869: IF (PAUSE .EQ. 1) READ(RTE,20) DUMMY
870: 20 FORMAT(A1)
871: RETURN
872: END
873:
874:
875: SUBROUTINE PLOT(LUNIT,X,Y,N,P,K,BUF)
876: DOUBLE PRECISION X(N),Y(N),P(1)
877: INTEGER BUF(79)
878: C
879: C PLOT X VS. Y ON LUNIT
880: C IF K IS NONZERO, THEN P(1),...,P(K) ARE EXTRA PARAMETERS
881: C BUF IS WORK SPACE
882: C
883: DOUBLE PRECISION XMIN,YMIN,XMAX,YMAX,DY,DX,Y1,Y0
884: INTEGER AST,BLANK,H,W
885: DATA AST/1H*/,BLANK/1H /,H/20/,W/79/
886: C
887: C H = HEIGHT, W = WIDTH
888: C
889: XMIN = X(1)
890: XMAX = X(1)
891: YMIN = Y(1)
892: YMAX = Y(1)
893: DO 10 I = 1, N
894: XMIN = DMIN1(XMIN,X(I))
895: XMAX = DMAX1(XMAX,X(I))
896: YMIN = DMIN1(YMIN,Y(I))
897: YMAX = DMAX1(YMAX,Y(I))
898: 10 CONTINUE
899: DX = XMAX - XMIN
900: IF (DX .EQ. 0.0D0) DX = 1.0D0
901: DY = YMAX - YMIN
902: WRITE(LUNIT,35)
903: DO 40 L = 1, H
904: DO 20 J = 1, W
905: BUF(J) = BLANK
906: 20 CONTINUE
907: Y1 = YMIN + (H-L+1)*DY/H
908: Y0 = YMIN + (H-L)*DY/H
909: JMAX = 1
910: DO 30 I = 1, N
911: IF (Y(I) .GT. Y1) GO TO 30
912: IF (L.NE.H .AND. Y(I).LE.Y0) GO TO 30
913: J = 1 + (W-1)*(X(I) - XMIN)/DX
914: BUF(J) = AST
915: JMAX = MAX0(JMAX,J)
916: 30 CONTINUE
917: WRITE(LUNIT,35) (BUF(J),J=1,JMAX)
918: 35 FORMAT(1X,79A1)
919: 40 CONTINUE
920: RETURN
921: END
922:
923:
924: SUBROUTINE EDIT(BUF,N)
925: INTEGER BUF(N)
926: C
927: C CALLED AFTER INPUT OF A SINGLE BACKSLASH
928: C BUF CONTAINS PREVIOUS INPUT LINE, ONE CHAR PER WORD
929: C ENTER LOCAL EDITOR IF POSSIBLE
930: C
931: character*256 s
932: open(7,file='----')
933: write(7,10) (buf(i),i=1,n)
934: 10 format(256a1)
935: close(7)
936: call system('edit ----')
937: open(7,file='----')
938: rewind 7
939: read(7,'(a)') s
940: close(7)
941: call system('remove ----')
942: n = 0
943: do 20 i = 1, 256
944: if (s(i:i) .ne. ' ') n = i
945: 20 continue
946: read(s,10) (buf(i),i=1,n)
947: RETURN
948: END
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.