4.1 Fractional Matrix Operations

A fractional matrix is a collection of numerical values, the matrix elements allocated contiguously in memory, with the first element at the lowest memory address. One word of memory is used to store the value of each element, and this quantity must be interpreted as a fractional number represented in the 1.31 format.

A pointer addressing the first element of the matrix is used as a handle which provides access to each of the matrix values. The address of the first element is referred to as the base address (BA) of the matrix. Because each element of the matrix is 32-bits, the base address must be aligned to two or four, respectively.

The two-dimensional arrangement of a matrix is emulated in the memory storage area by placing its elements organized in row major order. Thus, the first value in memory is the first element of the first row. It is followed by the rest of the elements of the first row. Then, the elements of the second row are stored, and so on, until all the rows are in memory. This way, the element at row r and column c of a matrix with R rows and C columns is located from the matrix base address (BA) at:

BA + 4 * (C(r - 1) + c - 1), for 1 ≤ r ≤ R, 1 ≤ c ≤ C.

Unary and binary fractional matrix operations are implemented in this library. The operand matrix in a unary operation is called the source matrix. In a binary operation the first operand is referred to as the source one matrix and the second matrix as the source two matrix. Each operation applies some computation to one or several elements of the source matrix(ces). The operations result in a matrix, referred to as the destination matrix.

Some operations resulting in a matrix allow computation in place. This means the results of the operation are placed back into the source matrix (or the source one matrix for a binary operation). In this case, the destination matrix is said to (physically) replace the source (one) matrix. If an operation can be computed in place, it is indicated as such in the comments provided with the function description.

For some binary operations, the two operands can be the same (physical) source matrix, which means the operation is applied to the source matrix and itself. If this type of computation is possible for a given operation, it is indicated as such in the comments provided with the function description.

Some operations can be self-applicable and computed in place.

All fractional matrix operations in this library take as arguments to the number of rows and the number of columns of the operand matrix(ces). Based on the values of these arguments, the following assumptions are made:

  1. The sum of sizes of all the matrices involved in a particular operation falls within the range of available data memory for the target device.
  2. In the case of binary operations, the number of rows and columns of the operand matrices must obey the rules of vector algebra (i.e., For matrix addition and subtraction, the two matrices must have the same number of rows and columns, while for matrix multiplication, the number of columns of the first operand must be the same as the number of rows of the second operand.). The source matrix to the inversion operation must be square (the same number of rows and columns) and non-singular (its determinant different than zero).

The destination matrix must be large enough to accept the results of an operation.