Abstract
Operations for performing LU-decomposition with partial (row) pivoting and
operations for solving systems of linear equations using the LU-decomposition
functionality. The module mk_lup is parameterised over an ordered
field. Examples of ordered fields include f64 and f32.
Synopsis
local module type lup = {
| ||||||||||||||||||||||||||
| module mk_lup | : | (T: ordered_field) -> lup with t = T.t | ||||||||||||||||||||||||
Description
- ↑local module type lup
- ↑type t
Type of elements
- ↑val lup [n]: (mat: *[n][n]t) -> ([n][n]t, perm.t [n])
Perform LU-decomposition with partial (row) pivoting. A call
lup Areturns a pair(LU,P)of a matrixLUand a permutationP, such thatpermute P A = matmul (lower LU) (upper LU). Notice that both the lower and upper triangular matrices are embedded in the resulting matrixLU; see the functionslowerandupperbelow.- ↑val forsolve [n]: [n][n]t -> [n]t -> [n]t
Forward solving. The expression
forsolve L bsolves (Lx = b,x), wherexandbare vectors andLis a lower-triangular matrix. Reads only lower part ofL, excluding the diagonal, and assumes implicit unit diagonal elements.- ↑val backsolve [n]: [n][n]t -> [n]t -> [n]t
Backward solving. The expression
backsolve U ysolves (Ux = y,x), wherexandyare vectors andUis an upper-triangular square matrix. Reads only upper part ofU, including the diagonal.- ↑val ols [n]: *[n][n]t -> *[n]t -> *[n]t
Solve a linear system using LU-decomposition with partial (row) pivoting.
- ↑val lu [n]: (mat: *[n][n]t) -> [n][n]t
Perform LU-decomposition without pivoting. A call
lu Areturns a matrixLUcontaining the lower and upper parts of the decomposition. Due to the lack of pivoting, this function is unstable. Perhaps use thelupfunction instead. On success, iflu A = LUthenA = matmul (lower LU) (upper LU).- ↑val lower [n]: [n][n]t -> [n][n]t
Return the unit-lower matrix embedded in the argument matrix. Extracts all lower, non-diagonel elements and returns a matrix containing the unit element in diagonal entries and the zero element in strict-upper entries.
- ↑val upper [n]: [n][n]t -> [n][n]t
Return the upper matrix embedded in the argument matrix. Extracts all upper elements, including the diagonal elements. The resulting matrix has the zero element in all strict-lower entries.