Go to the previous, next section.

The `matrix`

class stores both the elements of the matrix and the
LU decomposition. A single `fract_matrix`

is used to store the
lower-triangular (L) and upper-triangular (U) matrices. The class also
keeps track of which columns are pivot columns, and which columns where
permuted to compute the LU decomposition. Whenever any of the elements
in the matrix are changed, the LU decomposition of the matrix is marked
invalid. Whenever the LU decomposition is needed, it is recalculated if
currently invalid. The `is_factored`

method checks if the LU
decomposition is up-to-date. The `factor`

method is called to
calculate the LU decomposition; it will only do the calculation if the
current decomposition is not valid.

The `is_pivot`

method returns `TRUE`

if its integer argument
is a pivot column in the LU decomposition. The `rank`

method
returns the integer rank of the matrix. Also, the methods
`full_row_rank`

and `full_column_rank`

check if the rank of
the matrix is equal to the number of row or columns, respectively.

The method `inverse`

returns the inverse of the current matrix.
(the matrix must be non-singular and square).

The method `range`

returns the `vector_space`

(see section Vector Spaces for Linear Algebra) that corresponds to the column space, or
range, of the matrix. The column space of a matrix contains all the
points that are combinations of its columns (i.e. all points `b`

such that `Ax = b`

). The method `kernel`

returns a
`vector_space`

representing the null-space, or kernel of the
matrix. The kernel of a matrix `A`

is the set of all vectors
`x`

such that `Ax = 0`

. If `A`

is an `m`

by
`n`

matrix with rank `r`

, then the kernel has dimension
`n - r`

. See section Vector Spaces for Linear Algebra.
For example, given the following matrix:

[ 1 4 0 ] [ 0 3 0 ]

The kernel is:

{(0, 0, 1)}

For the matrix `A`

, the method `particular_solution`

returns
the particular solution to the equation `Ax = b`

. If a single
solution exists to this equation, then the particular solution is simply
the one solution. If infinite solutions exist, then the particular
solution is the solution with all free variables set to 0. In general,
all possible solutions to the equation can be represented as the sum of
the particular solution and a solution to `Ax = 0`

. The method
takes as arguments the `fract_vector`

`b`

and a boolean valid
flag. If a solution was found, the flag is set to `TRUE`

and the
`fract_vector`

`x`

is returned. If no solution exists, then
the flag is set to `FALSE`

. For example given the equation:

[ 4 3 8 2 ] [ 1 ] [ 0 0 3 1 ] x = [ 4 ] [ 0 0 0 0 ] [ 0 ]

The particular solution is:

[ -29/12 ] [ 0 ] [ 4/3 ] [ 0 ]

Go to the previous, next section.