# Module matrice

This module provides matrixes of vector rows. A matrix is a compound with varying number of vectors. A vector can be accessed by the predicate []/3. The first vector has the index one. An element can be accessed by the predicate []/4. The first element in each vector has the index one. The arity of the matrix can be queried by the predicate len/2. Vectors can be created by the two special forms [_ | _] and {_ | _} introduced in the module element.

Examples:
`?- X is [[A,B],[C,D]], Y is X[2][1].X is [[A,B],[C,D]],Y is C?- X is [[A,B],[C,D]], Y is X[2,1].X is [[A,B],[C,D]],Y is C`

This module provides arithmetic for matrixes. Besides change sign, addition and subtraction, we also find multiplication, division and power. The multiplication uses the usual multiplication sign (*)/2 despite the fact that matrix multiplication is not commutative. Power is defined for an integer exponent. Operations such as transposing are currently not provided.

Examples:
`?- X is [[1,1/2],[1/2,1/3]], Y is X^(-1).X is [[1,1/2],[1/2,1/3]],Y is [[4,-6],[-6,12]]?- X is [[1,1/A],[1,1]], Y is X^(-1).X is [[1,1/A],[1,1]],Y is [[-A/(1-A),1/(1-A)],[A/(1-A),-A/(1-A)]]`

The matrix inversion is implemented by an exchange step method. It works for constant and symbol expression elements. We have not yet implemented pivot search so that the current implementation might not find an inversion even if there exists one. Error handling is rudi-mentary. Cancellation does not yet generate non-zero side conditions.

The following matrix predicates are defined:

X[Y, Z]:
The predicate succeeds in Z with the Y-the vector of the matrix X.
X[Y, Z, T]:
The predicate succeeds in T with the Z-the element of the Y-the vector of X.
len(X, Y):
The predicate succeeds in Y with the number of vectors in the matrix X.
-(X, Y):
The predicate succeeds in Y with the sign changed matrix X.
+(X, Y, Z):
The predicate succeeds in Z with the sum of the matrix X and the matrix Y.
-(X, Y, Z):
The predicate succeeds in Z with the matrix X subtracted by the matrix Y.
*(X, Y, Z):
The predicate unifies Z with the product of the matrix X followed by the matrix Y.
/(X, Y, Z):
The predicate succeeds in Z with the matrix X divided by the matrix Y.
^(X, Y, Z):
The predicate succeeds in Z with the Y-the power of the matrix X.