home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / apps / math / matricks / matricks.doc next >
Text File  |  1989-04-30  |  22KB  |  515 lines

  1.  
  2. =======================================================
  3.  
  4.                   M A T R I C K S
  5.                   
  6.              A Linear Algebra Package
  7.                         by
  8.                   Victor Eijkhout
  9.  
  10. =======================================================
  11.  
  12. =======================================================
  13.                 U S E R   M A N U A L
  14. ===================Introduction========================
  15.  
  16. 'MaTricks' is a linear algebra package for purposes of research 
  17. and education. It is not meant to be a high precision numerical 
  18. library. Emphasis is on ease of input and ease of inspection of 
  19. results (filling in a Hilbert matrix takes literally 8 
  20. keystrokes, and matrices are in full view most of the time).
  21. While most of the common matrix operations are included, there 
  22. exists the possibility to add user-defined modules to the 
  23. package. 'MaTricks' operates completely in text mode, and it 
  24. has extensive on-line help. It was written in STPascal version 2.0 of 
  25. CCD-D.Beyelstein.
  26.  
  27. A bit of history---------------------------------
  28. I wrote a first version of this program when doing 
  29. research together with Ben Polman on band matrices (this has 
  30. since then been published in Linear Algebra and its 
  31. Applications, vol. 109), and I needed a tool to test my 
  32. hypotheses quickly. Originally written for the Ibm-pc, 
  33. 'MaTricks' has recently been ported to the Atari and extended 
  34. considerably. I am contemplating the possibility of
  35. a back-port.
  36.  
  37. The concept of shareware--------------------------
  38. This program is shareware. This means that you are free to check 
  39. out this program to see if you like it. In case you want to 
  40. continue using it, I ask for a small contribution, say $10. 
  41. Your sense of honour is the only compulsion for obliging me. 
  42. There are advantages to registring yourself as a user, however. 
  43. See the section on user modules.
  44.  
  45. Send your shareware contribution to
  46.           Victor Eijkhout
  47.           Dingostraat 53
  48.           6531 PA Nijmegen
  49.           the Netherlands.
  50. Questions, suggestions and bug reports can be sent to the
  51. same address, or by email to
  52.           u641000@hnykun11.Bitnet     <- preferably this one
  53. or        eykhout@wn2.sci.kun.nl      (that's uucp).
  54.  
  55. You are invited to give this program to other people who
  56. might be interested, with the restriction that this
  57. manual is also passed in its entirity. The shareware rules
  58. hold for any recipients of the program and manual.
  59.  
  60. About this manual-----------------------------------------
  61. The MaTricks program has quite a lot of on-line help. 
  62. It should be quite possible to use the program
  63. without ever referring to this manual. In fact, the only
  64. thing found exclusively in this manual is the information
  65. about interfacing the program to user-defined modules.
  66. The other topics only get treated more elaborately in this
  67. manual.
  68.  
  69. Note that this manual is not a linear algebra course.
  70. It only describes how to perform certain operations,
  71. that you supposedly know, by means of this program.
  72.  
  73. Disclaimer------------------------------------------------
  74. Matricks is rather a harmless program. 
  75. It is purely for legal reasons that I include the following:
  76.      "I make no warranty with respect to this manual, or the
  77.       program it describes, and disclaim any implied or explicit
  78.       suggestions of usefulness for any particular purpose.
  79.       Use this program only if you are willing to assume all 
  80.       risks, and damages, if any, arising as a result, even if
  81.       they are caused by negligence or other fault."
  82.       
  83.  
  84.  
  85. ==================Data Limitations=========================
  86.  
  87. The main data structure of 'MaTricks' is an array of 10 
  88. matrices, the maximal size of which has arbitrarily been set to 
  89. 37. While this is rather limited for real world computation, it 
  90. is probably sufficient for the purposes for which the program 
  91. was designed.
  92.  
  93. All ten matrices are square and of the same dimension, and there 
  94. are no vectors. After all, rectangular matrices are special 
  95. cases of square ones, and so are vectors.
  96.  
  97.  
  98.  
  99. =====================The Menus=======================
  100.  
  101. The program is structured around a number of menus (three at the 
  102. moment; this does not include the view screen) 
  103. that have one character commands. 
  104.  
  105. Command lists-----------------------------------
  106. A command can be chosen by typing the corresponding 
  107. character directly at the keyboard. Alternately 
  108. one can move through the list of commands using the 
  109. space bar, which moves the cursor down cyclically. 
  110. When the cursor has been positioned like this, the 
  111. command can be chosen by hitting <Return>. Typing <?> gives a 
  112. short description of the command.
  113.  
  114. Commands that have a matrix argument take the 'current matrix' 
  115. as its first or only argument. When the program prompts for an 
  116. argument, you can abort the command by entering an empty line.
  117.  
  118. If a command is in a submenu, the program returns to the main 
  119. menu after execution of the command. The submenus contain a 
  120. 'quit to the main menu' command, in case you change your mind 
  121. about selecting a command from the submenu.
  122.  
  123.  
  124. The Matrix List---------------------------------
  125. In all menus the lower right corner of the screen displays a 
  126. short inventory of the ten matrices. 
  127. - An arrow indicates the 'current matrix'. 
  128. - Typing any of the digits 0--9 changes the 
  129.   number of the current matrix. 
  130. - Matrices that have been filled (either in view mode, or as the
  131.   result of some operation) are marked with 'X'.
  132. - To prevent you from losing track of your own actions, there is
  133.   a facility for naming the matrices.
  134.   
  135.  
  136.  
  137. ==========================View Mode==========================
  138.  
  139. The most important feature of 'MaTricks' is undoubtedly its full 
  140. screen view mode. A nine-by-nine portion of the matrix is 
  141. displayed here. Input of matrices is also done here.
  142.  
  143.  
  144. Information Lines--------------------------------
  145. In view mode, the lower lines of the screen give information 
  146. about the current matrix.
  147. - The cursor position (in (i,j) coordinates) is always visible,
  148. - if the matrix has been named its name is visible,
  149. - the key <:> is a toggle for full-precision display of the 
  150. element under the cursor,
  151. - the key <;> toggles the display of the current 'decay factor', 
  152. i.e., the current element divided by its neighbour. You are 
  153. prompted for the direction in which the neighbour is taken 
  154. (nsew). Choosing <o> will switch off decay factor display.
  155.  
  156. For matrices that have been filled using an operation in the 
  157. 'iterative methods' menu, a topline is added to the screen, 
  158. displaying the status of the first couple of columns of the 
  159. matrix.
  160.  
  161.  
  162. Cursor Movement---------------------------------------
  163. There are three ways to move the cursor through the screen  
  164. across elements. 
  165. - First of all the cursor keys have been implemented.
  166. - Secondly, in order to move along cross-directions, the 1--9 
  167. key of the keypad (excepting the 5) are also cursor movements.
  168. - Thirdly, for touch typists the combination of control and the 
  169. basic positions of the right hand (uio, jkl, m,.) double the 
  170. keypad functions.
  171.  
  172. Adding the <control>-key to the first two possibilities gives 
  173. movement across nine-by-nine chunks. 
  174.  
  175. The <home> key makes the cursor move to the (1,1)-element of the 
  176. matrix, <control>-<home> performs a similar jump to the 
  177. (n,n)-element.
  178.  
  179.  
  180. Operations-----------------------------------------
  181. Already in the view mode some matrix operations are possible.
  182. s - symmetrise the matrix by taking its symmetric part,
  183. a - anti-symmetrise the matrix in a like manner,
  184. p - zero all elements (i,j) for which |i-j|>p 
  185.     (the quantity p is prompted for),
  186. P - zero all elements (i,j) for which |i-j|<=p 
  187.     (again the quantity p is prompted for)
  188. # - some elementary statistics on the current matrix.
  189.  
  190. Input------------------------------------------
  191. Filling the matrix is done by positioning the cursor (if 
  192. necessary) and typing one of the following keys:
  193. e - fill the element under the cursor,
  194. r - fill the row on which the cursor stands,
  195. c - fill the column in which the cursor stands,
  196. d - fill the sub, super, or main diagonal on which the cursor 
  197.     stands, (if the matrix has been partitioned into block form
  198.     this will fill the diagonal as far as it is part of the
  199.     block-diagonal)
  200. u - fill the upper triangle of the matrix (main diagonal not 
  201.     included),
  202. l - fill the lower triangle of the matrix (main diagonal not 
  203.     included),
  204. m - fill the whole matrix.
  205.  
  206. After hitting any of these keys, you are prompted for input. 
  207. This input can have a number of forms. 
  208. Input can be
  209. - numeric:  
  210.                       type 3.1415 ; 
  211.   thus a few keystrokes suffice to fill 
  212.   a Toeplitz matrix,
  213. - symbolic: 
  214.                       type 1/3
  215.                       or   (20+2)/(10-3) ;
  216. - with infix dyadic operators: 
  217.   '|' for maximum, 
  218.   '_' for minimum, 
  219.   '^' for ordinary exponentiation (of nonnegative numbers); 
  220.                thus typing 2^3 gives 8
  221.   'e' for integer powers (negative base permitted)
  222.                       type (-1)e5 ;
  223. - with prefix monadic operators: 
  224.   's' for sine, 
  225.   'c' for cosine, 
  226.   'a' for absolute value;
  227.       this requires brackets most of the time: 
  228.       for instance calculate distance from the main diagonal by 
  229.                            a(i-j) ,
  230. - referring to matrix coordinates i,j,n; 
  231.   thus a Hilbert matrix 
  232.   is generated by          1/(i+j-1) ,
  233. - referring to elements of the matrix: 
  234.                       type [i,j]
  235.                        or  [i+1,j-1] 
  236.   (non-existing elements are taken as zero); 
  237.   thus you fill in a symmetric matrix by filling the 
  238.   lower triangle, and specifying the upper triangle 
  239.                         as [j,i] ,
  240. - using choices: an if-then-else-fi clause has the following 
  241.   form: 
  242.                    {       :         :       }
  243.                     if-part then-part else-part
  244.   thus the above 'p' operation (for p=2) is equivalent to
  245.                            {a(i-j)>2:0:[i,j]}
  246.   The if-part can use the logical operators 
  247.                          > , < , =  and  ! 
  248.   (the exclamation mark stands for not-equal).
  249.   The else-part was intended to be [i,j] when ommited. 
  250.   It sometimes is. This is a known bug.
  251.   
  252.  
  253. The Input Line Editor---------------------------------
  254. A maximum of forty input expression is remembered in a 
  255. history buffer. This buffer can be traversed circularly
  256. using the up and down arrow keys (think of the buffer 
  257. as a stack, the keys then indicate the direction from old to new, 
  258. or conversely; the latest contributions are added on top
  259. of the stack).
  260.  
  261. For easy modification of old expressions (or for correcting
  262. errors when you are typing something in) there is a simple line
  263. editor built in.
  264. - clear the whole line with the <Escape>-key,
  265. - move through the line using left and right arrow keys,
  266. - insert characters, and
  267. - delete characters using <Backspace> and <Delete>.
  268.  
  269. Errors in the input------------------------------------
  270. Error handling is not optimal; faulty input may give
  271. several messages. If the screen is not updated correctly
  272. after an error, give ',' to force a redraw.
  273.  
  274. Partitioning-------------------------------------------
  275. Block matrices have been implemented. In order to specify the
  276. location of the blocks the following keys are available:
  277. -                             < 
  278.   the current column indicates the start of a block;
  279. -                             ^ 
  280.   the current row indicates the start of a block;
  281. -                             ~ 
  282.   clear all blocks.
  283. There is always an implicit block starting at the (1,1)-element
  284. of the matrix, so you needn't partition there.
  285. If a partitioning has been given, the input 'd' operation
  286. is limited to the block diagonal in which the cursor stands.
  287. Block matrices allow block factorisations, and block iterative
  288. methods (see below).
  289.  
  290.  
  291.  
  292. ================the Manipulation Menu======================
  293.  
  294. The manipulation menu contains some of the most common matrix
  295. operation.
  296. - Addition, subtraction, multiplication are pretty standard.
  297. - Inversion is performed using row interchanges. (This is subject
  298.   to a toggle, in case you might want to compare accuracy with
  299.   and without) Feel free to write your own much more 
  300.   sophisticated inversion routine.
  301. - Factorisation is of LU type, with the diagonal of L all ones,
  302.   and the pivots stored on the diagonal of the U factor.
  303.   The l,u,d commands extract the factors and the pivots from
  304.   a factorised matrix.
  305.   Block factorisation uses the partitioning specified in view
  306.   mode, or, if none has been specified, reduces to point 
  307.   factorisation. Again the L factor has an identity diagonal.
  308.   The L,U,D extraction commands give block factors and a
  309.   block diagonal matrix containing the block pivots.
  310.   
  311. Note that the block factorisation is a way of computing
  312. Schur complements.
  313.  
  314.  
  315.  
  316. =============the Iterative Methods Menu=====================
  317.  
  318. The iterative methods menu contains two methods for the
  319. solution of linear systems, the power method for computing
  320. the dominant eigenvalue of a matrix (and its eigenvector thereto),
  321. and the Jacobi method for approximating the eigenvalues (in general
  322. eigenvalues cannot be computed exactly for matrix dimensions
  323. exceeding five. This is a corollary of Galois theory).
  324.  
  325. If a partitioning has been specified, the iterative methods
  326. become block methods.
  327.  
  328. All iterative methods need a matrix dimension of at least 3.
  329.  
  330. - Gauss-Jacobi/Gauss-Seidel. The righthand side vector of
  331.   the linear system has to be stored in the first column of
  332.   the matrix that is passed as the second argument to this
  333.   command. The second column is used as initial vector, and
  334.   the iterates overwrite this column. It needed not be filled
  335.   initially. Upon completion of the iterative process, 
  336.   the third column of the matrix contains the product of the 
  337.   matrix and the last iterate. It takes only a column operation
  338.   in view mode (to wit: [i,3]-[i,1] in the fourth column) to
  339.   compute the residual from this.
  340.  
  341. - The power method computes succesive products with an initial
  342.   matrix given in the first column of another matrix. 
  343.   Iterates are written into the second column, and Raleigh
  344.   quotients are in the third, with the most recently computed one
  345.   in the first row.
  346.  
  347. - The Jacobi method computes approximations to the eigenvalues
  348.   of a symmetric matrix (your input is symmetrised first), by
  349.   means of plane rotations that zero the maximal off-diagonal
  350.   element of the matrix.
  351.   
  352.  
  353. =================Dump to File===============================
  354.  
  355. It is possible to write matrices to an external file, or
  356. to read them from a file. A write operation will dump
  357. all filled matrices to the file specified, a read operation
  358. will read all matrices contained in a file, but will attempt
  359. not to overwrite the matrices that have been filled already.
  360.  
  361. As the file format is rather simple, it is perfectly possible
  362. to accept input that has been prepared by another program.
  363.  
  364. For the location of input or output files a file selector
  365. box is used, which is described in the next section.
  366.  
  367. The file format is as follows.
  368. - The first line in the file contains a notice indicating the
  369.   version of the file format.
  370. - The second line has the (user-specified) dimension of the
  371.   matrices and the number of matrices in the file, 
  372.   seperated by a space.
  373. - The next line contains a zero if no partitioning was in effect
  374.   when the file was written, or the number of non-trivial (that
  375.   is, excluding the (1,1)-point) splits, followed by these
  376.   splits, all seperated by spaces.
  377.   
  378. After this, for each matrix there is
  379. - one line containing
  380.   - a one-character description of the matrix, at the moment only
  381.     'f' (which stands for 'full matrix' is supported)
  382.   - one space, followed by the name of the matrix. Names have
  383.     8 characters maximum.
  384. - the elements of the matrix, stored by row, seperated by spaces,
  385.   on any number of lines (one if you have Emacs, more if you 
  386.   have some less sophisticated editor that puts a limit 
  387.   on the line length).
  388.  
  389.  
  390. ====================User Modules============================
  391.  
  392. As it is impossible for a matrix package to embody
  393. every matrix operation known to man, I have decided to
  394. make 'MaTricks' user-extendible. The package can call
  395. external programs and pass to them the address of its
  396. internal data structures.
  397.  
  398. Below you find full documentation on the data structures
  399. and just what is a Real. The easiest way to ensure compatibility
  400. is of course to program in lovely STPascal of CCD.
  401. Be sure to use the 'STPasage' shell of Ben Polman!
  402.  
  403.  
  404. Calling External Programs---------------------------
  405. A total of twenty external programs can be called using the
  406. ten function keys, and the shift-function key combinations.
  407. These stand for monadic and dyadic matrix operations respectively,
  408. i.e., MaTricks will ask you for the number of the output matrix, 
  409. or the numbers of the other argument and the output matrix.
  410. The external program is of course at liberty to disregard
  411. these numbers.
  412.  
  413. After execution of the external program the output matrix is
  414. made the current matrix and the output matrix is marked as
  415. filled.
  416.  
  417.  
  418. Program Selection---------------------------------------
  419. Initially no programs are bound to the function keys. The first time
  420. a key is used a file selector screen appears, enabling the user 
  421. to select an external program. This screen displays
  422. - the available drives. Switch drives by typing one of the
  423.   drive letters;
  424. - the current path, and in the first column the folders therein.
  425.   Move to a folder using arrow keys, and choose it by typing <Return>;
  426.   the '.' stands for root of the disc, and '..' for close the current
  427.   folder.
  428. - the programs (.TOS, .PRG, and .TTP) in the current folder. Move
  429.   to them using arrow keys, and choose them by typing <Return>.
  430.   You will be asked for confirmation.
  431. Abort the file selector by hitting <Undo>.
  432.  
  433. Saving the List of Modules----------------------------------
  434. As soon as you have external modules, MaTricks will write a
  435. file 'matricks.mxp' containing the names and locations of the
  436. modules (the format is quite easy to figure out, in case you
  437. are interested). You are allowed to rename this file.
  438. In order to load it into the program, you have to 
  439. pass it as a parameter. This is easy working from a command shell;
  440. if you work with the desktop you can install MaTricks to
  441. be invoked by files with the '.mxp' extension.
  442. Note that you have to install it as 'Tos Takes Parameters'.
  443. For those lucky ones using STFinder: install this program 
  444. with options 'set default path to current', 'pass file as argument',
  445. and 'don't include path in argument'.
  446.  
  447.  
  448. Writing Your Own Modules------------------------------------
  449. User modules can be called from within MaTricks; they are given 
  450. the address of the internal data structure of MaTricks. 
  451. This address is written in
  452. hexadecimal notation and converted to a string. Your module
  453. can retrieve it using 'argv' or 'cmd_getarg' or whatever 
  454. this function is called in your system. 
  455. At this address in memory stands the
  456. 'Com_blk' structure defined as follows:
  457.  
  458. Type Matrix_ptr  = ^Array[0..9]Of Array[1..37,1..37]Of Real;
  459.      Fill_ptr    = ^Array[0..9]Of Boolean;
  460.      Com_blk     = Record magic : Integer;
  461.                           mats  : Matrix_ptr;
  462.                           fils  : Fill_ptr;
  463.                           mdim,size,cur,out,other
  464.                                 : Integer;
  465.                           reserve1,reserve2,reserve3,reserve4
  466.                                 : Long_integer;
  467.                    End;
  468.  
  469. This Pascal Record corresponds to a 'struct' in C.
  470.  
  471. - The magic int is 31415 (ints are two bytes); it is included 
  472.   to facilitate your debugging.
  473. - The matrices are stored by row. Important: in STPascal a Real
  474.   is a 6-byte structure: first 40 bits of mantissa, then 8 bit 
  475.   exponent. To the exponent an offset of $80 has been added.
  476.   A null exponent denotes the number zero.
  477.   As the mantissa is always normalised, its most significant
  478.   bit is used for the sign, it is set for negative numbers.
  479. - The row of Booleans indicates which of the ten matrices have
  480.   been filled by the user. You are free to use empty matrices
  481.   (or filled ones, for that matter) as working space.
  482.   For C-programmers: a Boolean is a 16-bit word; it is 'True' 
  483.   (i.e., the corresponding matrix has been filled) if its 
  484.   least significant bit has been set.
  485. - The integers have the following meaning:
  486.   mdim  : matrices are allocated as 37-by-37 arrays. You can use this
  487.           fact but if you want your module to be compatible with
  488.           later versions of MaTricks (which may have a different
  489.           size) you can use this parameter.
  490.           It has the value 37 at the moment.
  491.   size  : the matrix dimension as indicated by the user.
  492.   cur   : the current matrix. This is at the same time the first
  493.           argument that the user indicated for
  494.           the function in your module.
  495.   out   : the number of the matrix where the user wants you to
  496.           put the results.
  497.   other : if the module defines a dyadic operation this indicates the
  498.           second input argument.
  499.   the four Long_Integers at the end are reserved for future extensions
  500.           to the MaTricks package.
  501.          
  502. ====================This program is Shareware=======================
  503. Remember that this program is not free: it is shareware. Therefore
  504. you ought to register if you want to keep using it, 
  505. if only to ease your conscience.
  506. However, there is an added bonus to registering: within certain
  507. bounds I might be willing to comply with requests from
  508. registered users for specific external modules for this program.
  509. (Note that I consider 'how about computing all eigenvalues and
  510. eigenvectors' not a reasonable request. If you are an algebra 
  511. teacher, get some students to do this; if you are an algebra
  512. student, let's hope your teacher doesn't read this.......)
  513.  
  514.  
  515.