LIBRARY OF THE UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN 510. 84 Ilfcr no. 0)01- 612 cop. 2 for each non-returned lor os ^ materiais can Theft, «^&*%X£^*Z- A " ^^ t be causes ^f^^^o" Illinois Library are the ° Wned *, Y of the sS TaHllinais and are protected by P A S Vb Jh iScrimihal Law and 1 Procedure. Art.de IOB 333-8400. . UnWersi^^ When renewing by phone, write new due date below previous due date. v»; $>■ <* \/0. w JO* Report No. UHTCDCS-R-73-612 NSF - OCA - GJ-328 - 000001 DATA STRUCTURES AND OPERATOR FOR NEW ARRAY TYPES IN OL/2 by John Leonard Larson December 1973 DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN URBANA, ILLINOIS THE LIBRARY OF THE Digitized by the Internet Archive in 2013 http://archive.org/details/datastructuresop612lars Report No. UIUCDCS-R-7 3-612 DATA STRUCTURES AND OPERATOR FOR NEW ARRAY TYPES IN OL/2 by John Leonard Larson December 1973 Department of Computer Science University of Illinois at Urbana-Champaign Urbana, Illinois 61801 This work was supported in part by the National Science Foundation under Grant No. US NSF-GJ-328 and was submitted in partial ful- fillment of the requirements for the degree of Master of Science in Computer Science, February 1974. Ill ACKNOWLEDGMENT I wish to sincerely thank Professor J. Richard Phillips, who originated the OL/2 language, for his suggestion of this thesis topic, and for his advice and guidance toward its completion. I also wish to thank Mrs. Vivian Alsip, who did a fine job of typing this report, and to the National Science Foundation and the Department of Computer Science for their support. IV TABLE OF CONTENTS Page 1. INTRODUCTION 1 2. HESSENBURG FORM 2 2.1 OL/2 Background 2 2.2 Upper and Lower Hessenburg Arrays 2 2.3 Partitioning of Hessenburg Arrays 5 2.4 Compiler Tables for Arithmetic and "Part of" Operations 9 3. BAND FORM 14 3.1 Representation of Band Arrays 14 3 . 2 Partitioning of Band Arrays 21 3.3 Discussion of Arithmetic and "Part of" Operations. . 26 4. ROTATE OPERATOR 27 4.1 Introduction 27 4.2 The D. Group 28 4.3 Implementation 30 4.3.1 Backward Diagonal Array 30 4.3.2 Setting of Bits in CALL Statement 32 5. CONCLUSION 35 LIST OF REFERENCES 36 LIST OF FIGURES Page 1. Array control block 3 2. Partition control block 4 3. Hessenburg arrays and corresponding ACBs 6 4. Partitioning of Hessenburg arrays 7 5. Partitioning of a tridiagonal array 7 6. Geometric type of sum of two matrices 10 7. Geometric type of product of two matrices 11 8. Data structure for UT part of rectangular array 12 9. Rules for calculating y. (S) and u(S) . . . .' 13 10. Band array 15 11. Subarrays of band array defined by 6D 17 12. same as parent A RECT for j>i and UH parent j URC for i=j+l and UH parent LLC for j=i+l and LH parent other null 12 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Upper Hessenburg order (5) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 1 Lower Hessenburg order (5) ACB | | | | n = name | A = 2 | 1 1 1 I I I | t = UH | _ 2 b = max (n-2w+3 , 2w-n-l) for w >_ 2 . Clearly, the present 01/2 ACB structure is not sufficient to describe band arrays. How can band arrays be described? What ACB information is necessary? The answers to these questions are the goal of the following discussion. Band arrays consist of three subarrays in each of which 6D is con- stant. Let us define: a = min(w,n-w) 6 = max(w,n^w) 15 a 11 a 12 ' * * a 1w\ a 21 a 22 • \. • • \^ * n-w+-1,n ^ • • v Vl • • • • • \ n,n-vH-1 • • • cl nn Figure 10. Band array 16 then 5D=1 for 1 <_ row <_ a 6D=0 for a < row <_ $ 6D=-1 for 6 < row < n. See Figure 11. Given the row value, 6D is known, and therefore 6R(i) is known. See Figure 12. Care must be taken, however, when crossing over from one sub- array to another, and in the special cases when w=l and w=n. Of interest are the number of theoretically non-zero elements in each of these subarrays defined by 6D. Let Tl be the subarray in which 6D=1, T2 where 6D=0, T3 where 6D=-1. Let N(Ti) denote the number of elements in Ti. Then N(T1) = a(a+2w-l)/2 N(T2) = (n-2a)min(2w-l,n) N(T3) = N(T1) by symmetry. Of fundamental importance is the answer to the question, "Given a band array of order n and width w, what is the sequential storage location of A(i,j)?" First, it must be determined whether A(i,j) is a stored element. The subscripts of stored elements satisfy the relation: |i-j| £ (w-1) for 1 <_ i,j <_ n . Let us assume that A(i,j) is a stored element. Then the location of A(i,j) is given by one of the following formulas depending on the value of i: 17 Case 1. w < n - w _1 6D=1 6D=0 6D=-1 Case 2. w > n - w 6D=1 6D=0 6D=-1 n - w n - w Case 3. w = n - w _ l_____w 1 n_-_w 1 _ 6D=1 6D=-1 n - w Figure 11. Subarrays of band array defined by 6D 18 ii + 3 3 II II eg cm I I II II (N n I I 33 m Q) W 8 tO <0 i « Pi CM Pi pd Pi Pi co oo 3 I C A 3 8 v 3 + II II cm « + II II 9j ~£ H ^-. 6 (0 CM EH s 0) ii 1 Pi <0 CM •H En A o A A 19 for 1 < i < a (when w=n, no i will satisfy this relation) , LOC(A(i,j)) = L0C(A(1,1)) + (i-1) (i+2w-2)/2 + j - 1 for a < i £ 3 (when w=n-w, no i will satisfy this relation) , LOC(A(i / j)) =LX(A(1,1)) + N(T1) + (i-a-1) (min(2w-l,n) ) + j " * where x=l for a=n-w, and x=i-a+l for a=w for 6 < i < n (when w=n, no i will satisfy this relation) , LOC(A(i,j)) = L0C(A(1,1)) + N(T1) + N(T2) + (i-B-D (min(2w-l,n-l)) - (i-3-2) (i-3-l)/2 + j - i + w - 1 where L0C(A(1,1)) = 1 for the original array. Let us now assume that A(i,j) is not a stored element. Then it is necessary for partitioning, as shown later, to find the smallest value of i' (or j 1 ) for which A(i',j) (or A(i,j')) is stored. There are twD cases (Figure 13): for i-j > (w-1) 1 <_ i <_ a - not possible a < i <_ 6 ^ \ j' = i - w + 1 6 < i <_ n J for i-j < -(w-1) 1 <_ i <_ a \ i' = j - w + 1 a < i <_ 3 J 3 < i £ n - not possible. The sequential location of the stored element A(i',j) (or A(i,j')) can now be found by the previous formulas. 20 A(i.j) A(i.j) Case 2. i-j<-(w-1) Figure 13. Finding the nearest stored element in the same row or column 21 The previous discussion has exenplif ied the dependence of the repre- sentation of band arrays on n and w. Partitioning, as will again be shown, requires knowledge of absolute subscripts. From these considerations, the ACB structure for band arrays is proposed. See Figure 14. The r\, A, t, w, A., y., and p fields have the same interpretation as the corresponding fields in ex- isting ACBs. In place of the 6R and 6D fields are the w, s, n 1 , and w' fields. The w field, along with a y. field, describe the size and shape of the array. The s, n 1 , and w 1 fields describe the location of this array with respect to the original parent array (which may be itself) for the purpose of determining how 6D varies in this array. All of this ACB information for the original array is available from the array declaration. 3.2 Partitioning of Band Arrays The partitioning of band arrays is restricted, as is that for other non-rectangular arrays, to simultaneous identical row and column partition lines. Such partitioning gives rise to subarrays of three major types: band, null, and a new type, DB (diagonally bounded array) . An upper (or lower) EB array may be described as an nxm array in which all of the theoretically non-zero elements lie above (or below) one of n+m diagonal lines. Being a subarray of a band array, DB arrays inherit the problems of ACB representation, 6D and 6R, and origin calculation. Luckily, most of the information about band arrays can be carried over. The ACB struc- ture for DB arrays is given in Figure 15. The format of the ACB is the same as that for band arrays with only slightly different interpretation. The n, A, t, to, X., y., and p fields serve their same purposes. The w and y. fields describe the size and shape of the array. Here, though, w is not the width 22 n A T CO *1 Ml A 2 ^2 w S n' w' p where n - name of array A - dimensionality T - geometric type CD - origin A. 1 - lower bounds y i - upper bounds w - width s - (i,j) coordinates of upper left corner n' - order of oldest ancestor w' - width of oldest ancestor P - partition pointer Figure 14. ACB for band arrays 23 n A T CO *1 V»l x 2 P2 w S n' w 1 P where n - name of array A - dimensionality t - geometric type oo - origin X . - lower bounds 1 y . - upper bounds w - boundary line s - (i,j) coordinates of upper left corner n' - order of oldest ancestor w • _ width of oldest ancestor p - partition pointer Figure 15. ACB for diagonally bounded (DB) arrays 24 as in band arrays, but an integer designating the boundary line. See Figure 16. The s, n', and w 1 fields serve, as in band ACBs, to determine 6D and <5R. Most of the ACB information for subarrays is copied from the corre- sponding fields of the parent array ACB. For subarrays of band type, A, this includes A, t, n 1 , w' . The y. and s values are simple functions of the partition lines and the corresponding parent field. The value of w is IOC(A(s)) as computed by the formulas of the previous section. The width, w, is min(y. of subarray, w of parent array) . With the exception of the t, to, and w fields, the DB subarray ACB information is generated in the same manner as that for band subarrays. Given that s, the (i,j) coordinates (with respect to the original array) of the upper left corner of the DB subarray, has been found, t is determined by the rules: x = lower DB (LDB) if i < j t = upper DB (UDB) if i > j Next, it is ascertained whether s is a stored element. If it is, then to can be found. For UDB, the value of w is i-i'-l, where i 1 is the largest number greater than i such that A(i',j) is a stored element. Similarly, for LDB, w^j'-j+l. If s is not a stored element, then, for LDB, that i 1 > i is found such that A(i',j) is a stored element. Then w=LOC(A(i* , j) ) and w=i-i*. Similarly, for UDB, oy=LOC(A(i, j ') ) and w=j'-j. This procedure may be applied to any non-band subarray, null subarrays being discovered when the "nearest" stored element lies outside the bounds of the subarray. The partitioning of subarrays of band type follows the same pro- cedure as that for the original band array. For DB subarrays, where arbitrary row and column partitioning is allowable, all subarrays are assumed to be the 25 m-2 m-1 m n m Figure 16. Values of w for boundary lines 26 same type as the parent with null subarrays being found by the same procedure as outlined above. 3.3 Discussion of Arithmetic and "Part of" Operations The sum or product of a band or DB matrix, and another matrix re- sults in a matrix whose type is dependent upon n and w (using either interpre- tation) . In the present system, this necessitates defaulting the type of the result to rectangular. This action is in contradiction to the philosophy of not storing theoretically zero elements. It is not known whether functions can be found to determine the desired array type of the result from the type, n, and w of the operands. The feature of taking "part of" has not been fully investigated for tend arrays. The triangular "part of" a band array may be considered as a DB subarray and be represented as such. The band "part of" a band array can be implemented due to the n, w, n', and w 1 fields. This would include taking the diagonal and tridiagonal "part of" since both of these arrays are band arrays in the general sense. The band "part of" an array whose 6D=1, or -1 may be implemented by making the band part seem as if it were in a subarray of a larger band array where 5D would have the same value. 27 4. ROTATE OPERATOR 4.1 Introduction In an array language it is desirable to have many different geo- metric array types. This feature of a programming language allows great flexibility for the user in the approach of his problem. To have too few array types may make it necessary for the user to complicate or obscure the logic of his program by building "unusual" arrays from smaller available types. In the worst case, he may have to change algorithms. Such restric- tions defeat the purpose of an array language. One approach to the addition of new geometric array types is to define them explicitly. This is a major task involving finding ACB fields which adequately and efficiently represent the new types. Some of the arrays desired do not have a constant 6D, and problems similar to those of band arrays arise. Origin calculation equations and representations of subarrays must be found. In effect, one must start anew for each array type to be added. Another consideration is that of the size and complexity of the compiler tables which describe the operations of addition, multiplication, taking "part of", etc., on ordered pairs of array types. For example, the geometric type of the product of a tridiagonal matrix and a lower triangular matrix is required in the ACB of the temporary matrix which holds the result. 2 For n array types, each of these tables is on the order of n . To double the number of array types, which is the intent, would increase the size of each table by a factor of four. From the above considerations, it becomes clear that another approach should be considered. In the next section, we will consider the use of a re- sult from group theory to simplify the problem of implementing additional geometric array types. 28 4.2 The D y Group In this approach, the new array types are not defined explicitly, but are generated from existing ones. All of the information regarding array representation by ACB nodes and PCB nodes, however, remains the same. The basis for this approach lies in the dihedral group of order four, D^. This group has a geometric analog in the rotations of a square [4]. See Figure 17. The elements of D^^ consist of a, b, c, and d, rotations in space about axes of symmetry; e, f , and g, clockwise rotations of 90 , 180 , and 270°, respectively, about the square's center in its plane; and h, the identity, no rotation. From the algebraic point of view, new array types could be obtained by operating on an available array type with an element or combination (product) of elements in D.. One need not implement all the elements of D^, explicitly. Savings are made by implementing a subset of D^^ and generating the other elements by taking products of elements in this subset. While certain pairs of elements in D. will generate the whole group, i.e., {a,c}, the subset {a,b,c} was chosen for ease and simplicity of implementation of the remaining elements. From the group table and the following equations, the elements of D u are shown to be generated by a, b, and c. a = a b = b c = c d = a*b*c e = b*c f = a-b g = a«c h = a«a 29 column reversal row reversal transpose reverse transpose 90° rotation 180° rotation 270° rotation a b c d e f g identity - no rotation h 9 h h f e g c b d a f h g e d a c b g e h f b d a c e g f h a c b d d c a b f g h b a d c g h e f c d b a h e f g a b c d e f g h Figure 17. Rotations of a square - the dihedral group, D. 30 Since D. is not Abelian, these operators mast be applied to an array from left to right: (d)(A) = (a.b-c)(A) = (b.c)(a(A)) = (c)(b(a(A))) This fact is crucial in the implementation. The set of array types resulting from operating on the current array types with elements of D^. may be divided into two classes. One class consists of arrays of the same type as those available previously, but with the elements rearranged within the general shape. This class may be characterized by 1) symmetry with respect to the main diagonal, or 2) a boundary line parallel to the main diagonal. The other class consists of the new array types. These arrays are characterized by 1) symmetry with respect to the backward main di- agonal, where the backward main diagonal is that line passing through the upper right and lower left corners of the array, or 2) a boundary line parallel to the backward main diagonal. 4.3 Implementation 4.3.1 Backward Diagonal Array From the previous discussion, the construction of new array types involves only the implementation of the elements a, b, and c of D.. Trans- position, c, is already implemented. This leaves a and b, column and row re- versal, respectively. These operations can be implemented with the use of a backward diagonal array. See Figure 18. A backward diagonal array is the identity array with the rows (or columns) reversed. Column reversal of a array, A, is accomplished in theory by post-multiplying A by a backward di- agonal matrix of order m, where m is the number of columns in A. Row reversal, n 31 n Figure 18. Backward diagonal array 32 similarly, is accomplished in theory by pre-multiplying A by a backward di- agonal matrix of order n, where n is the number of rows in A. Because of the special form of backward diagonal arrays, these multiplications may be imple- mented with special techniques. Notice also that the transpose of a backward diagonal array is also a backward diagonal array. This fact leads to sore simplification. An example for a 3x3 upper triangular array is given in Figure 19. Thus, the syntax for the rotate operator could be (A, < integer >) where describes how the array A is to be rotated, i.e., which ele- ment of D, is to be applied to A. The compiler could then replace this term with the appropriate equivalent expression in terms of A, backward diagonal arrays, and the transpose operator. Since the dimensions of A are dynamic, the dimensions of the backward diagonal arrays cannot be set until execution time. 4.3.2 Setting of Bits in CALL Statement The inplementation of the transpose operator in the current version of OL/2 is done by means of flags. An addition, multiplication, or assignment operation results in a call to a subroutine to carry out the desired task. Some of the parameters in the argument list of the subroutine are flags indi- cating whether their associated arrays are to be transposed before operating with than. A simplified example is: CALL MULT(A,0,B,1,C); T which forms A*B and assigns the result to C. The flag indicates how the ele- ments of its corresponding array are to be accessed. The elements are not physically transposed. A flag value of 1 designates that element A(i,j) of the 33 ED RESULT I x I I 1 I I 2 3 | 4 5 | 6 I X I I I 1 1 1 I I 3 2 I = I 5 4 I I 6 1 I I I 6 I 5 I 3 I a column reversal Ax ED ED A I = I 4 I 1 2 b row reversal EDxA 1 1 I 1 ! I 1 I I 1 I I 2 3 | 4 5 | 6 I ED A' ED C I 1 I transpose = I 2 4 | " A' I 3 5 6 | d as a«b*c 1 |1 I 1| |653| reverse transpose I 1 | x | 2 4 I x I 1 l=l 42| (EDxAxED)' = ED'xA'xED' II | J 3 5 6 | | 1 II 11 = EDxA'xED ED e = b»c 11 || 111 11 90° rotation 124 | x | 1 |=| 4 2 | (EDxA)' = A'xED' I 3 5 6 I 11 I | 6 5 3 | = A'xED ED A ED f = a»b 11 11231 I 11 |6 | 180° rotation I 1 | x | 4 5 | x | 1 | = | 5 4 | EDxAxED II II 6||1 | |321| 13 5 6 1 270° rotation = 12 4 | (AxED) 1 = ED'xA" I 1 I = EDxA' Figure 19. Eackward diagonal method applied to UT 3x3 array 3a transposed matrix is actually stored in location A(j,i) of the original array. Both row reversal and column reversal can be implemented in a similar manner. Let there be two more flags associated with each array in a CALL statement. These flags are then used to indicate whether the array's rows or columns, or both, are to be reversed before operating with it. Again the elements would not be physically moved. For row reversal, element A(i,j) of the new array is actually located in A(n-i+l,j) of the original array. Similarly, for column reversal, A(i, j) is actually in A(i,m-j+l) , where the original array is mxn. Combinations of these twD flags and the transpose flag exhaust all the elements of LV. Note again that because LV is not Abelian, a, b, and c must be used, when applicable, in precisely that order. This second approach seems much more appealing. No multiplications need be performed. In the backward diagonal array method, the result of the rotation must be stored in a rectangular temporary matrix and any further operations must use the zeros which are generated, whereas in the second meth- od no additional storage is required and computational efficiency is retained. Finally, because of the similarity of the second method to the already imple- mented transpose operator, little additional program logic is required for its implementation . 35 5. CONCLUSION The preceding sections have shown the feasibility of adding Hes- senburg and band arrays, and a rotate operator to the OL/2 language. Most, if not all, of the necessary information for the implementation of Hessen- burg arrays has been given and such implementation should therefore be straightforward. The same optimism is felt for the realization of the ro- tate operator, due to its similarity with the already implemented transpose operator. The implementation of band arrays, on the other hand, is expected to present some problems, caused in most part by the new ACB representation. All in all, with the inclusion of these new features, the user of the 01/2 language will hopefully find a shorter and easier path to the solution of his problems. 36 LIST OF REFERENCES [1] Phillips, J. R., "The Structure and Design Philosophy of 01/2 — An Array Language — Part I: Language Overview," University of Illinois at Urbana-Champaign, Department of Computer Science Report No. 544, December 1972, [2] Phillips, J. R. , "The Structure and Design Philosophy of 0L/2 — An Array Language — Part II: Algorithms for Dynamic Parti- tioning," University of Illinois at Urbana-Champaign, Department of Computer Science Report No. 420, September 1971. [3] Phillips, J. R. , "Dynamic Partitioning for Array Languages," Com- munications of the ACM , Vol. 15, No. 12, pp. 1023-1032, December 1972. [4] Wells, Mark B., Elements of Combinatorial Computing , Oxford, Per- gamon Press, 1971. 'bliocraphic data I'EET 1. Report No. UIUCDCS-R-73-612 jTkle and Subtitle DATA STRUCTURES AND OPERATOR FOR NEW ARRAY TYPES IN OL/2 3. Recipient's Accession No. 5- Report Date December 1973 ; Author(s) John Leo: nard Larson 8. Performing Organization Rept. No - UIUCDCS-R-73-612 • Performing Organization Name and Address University of Illinois at Urbana-Champaign Department of Computer Science Urbana, Illinois 61801 10. Project/Task/Work Unit No. 11. Contract /Grant No. US NSF-GJ-328 . Sponsoring Organization Name and Address National Science Foundation Washington, D. C. 20550 13. Type of Report & Period Covered Master's Thesis 14. . Supplementary Notes . Abstracts This report is concerned with the addition of new array types to the 01/2 language. The necessary information for the implementation of Hessenburg arrays and their subarrays is given, including ACB representation and algorithms for parti- tioning. Modified data structures are proposed for describing band arrays and their subarrays, and new algorithms for partitioning are derived. Additional array types are realized by means of a rotate operator, which can generate new array types from the existing ones. Two possible implementations are suggested. '. Key Words and Document Analysis. 17a. Descriptors array control block array language array partitioning band arrays tessenburg arrays partition control block rotate operator r b. Identifiers/Open-Ended Terms re. COSATI Field/Group I. Availability Statement flhlimited 19. Security Class (This Report) UNCLASSIFIED 20. Security Class (This Page UNCLASSIFIED 21. No. of Pages 42 22. Price 3RM NTIS-35 (10-70) USCOMM-DC 40329-P7 1 1 '< Hi RH UNIVERSITY OF II LINOIS URBANA 3 0112 064441527