next up previous index
Next: Application Predicates Up: Grace Utility Predicates Previous: List Predicates

Matrix Predicates

When specifying matrix indexes and matrix sizes we have to face a notational inconsistency: On one hand, x coordinates always precede the y ones, the window width is always specified before its height and also the usual spreadsheet notation is e.g. C5, where C is the column (the x coordinate) and 5 the row ( y coordinate). On the other hand, in the usual matrix notation, the first index denotes the row and the second the column. As the following predicates are used for matrix manipulation including some usual operations like matrix multiplication, we have decided to use consistently the mathematic matrix notation, i.e. rows before columns and height before width.

 
matrix(+Height, +Width, +Domain, -Matrix)
Create a matrix of domain variables with the specified size and domains. The matrix is a list of Height row lists, each being Width long. Domain may have any form accepted by ::/2  . In addition, if Domain is random(Min, Max), the variables will be random integers from this range. This latter form is useful for generating random data.

 

matrix_list(+Matrix, -List)
Convert the matrix into a list by concatenating all rows.

 

transpose(+Matrix, -Trans)
Transpose the matrix Matrix.

 

diagonal(+Matrix, -Diag)
Diag is the main diagonal of the square matrix Matrix.

 

upper(+Matrix, -Upper)
Upper is the upper triangle of the matrix Matrix above its main diagonal. It is a list created as a concatenation of the rows of the triangle.

 

matrix_elem(+Row, +Col, +Matrix, -Elem)
Elem is the element of the matrix Matrix at the given position.

 

matrix_range(+Row1, +Row2, +Col1, +Col2, +Matrix, -SubMatrix)
Extract from the matrix Matrix a submatrix in the given range.

 

matrix_sorted_list(+Matrix, +RefMatrix, +Order, -List)
Convert the matrix Matrix into a list sorted by the values of another matrix RefMatrix by the relation Order. This is done by assigning each element of Matrix the corresponding element from RefMatrix as a key, converting it into a list and then sorting by the keys and relation Order as in sort/4  . A possible use for this predicate is to label variables in the order of their associated cost.

 

matrix_scalar_product(+Matrix1, +Matrix2, -Product)
Product is a structure which expresses the symbolic sum of pairwise scalar products of the rows of the two matrices:
m11*n11 + m12*n12 + ... + m21*n21 + m22*n22 + ...
This could also be expressed as the sum of the main diagonal elements of the matrix product of Matrix1 and transp(Matrix2).



next up previous index
Next: Application Predicates Up: Grace Utility Predicates Previous: List Predicates



Micha Meier
Tue Jul 2 10:07:34 MET DST 1996