📄 mf_lud.hlp
字号:
{smcl}
{* 25mar2005}{...}
{cmd:help mata lud()}
{hline}
{* index LU decomposition}{...}
{* index lud()}{...}
{* index _lud()}{...}
{* index _lud_la()}{...}
{* index LAPACK}{...}
{* index decomposition}{...}
{title:Title}
{p 4 8 2}
{bf:[M-5] lud() -- LU decomposition}
{title:Syntax}
{p 8 8 2}
{it:void}{bind: }
{cmd:lud(}{it:numeric matrix A}{cmd:,} {it:L}{cmd:,} {it:U}{cmd:,}
{it:p}{cmd:)}
{p 8 8 2}
{it:void}
{cmd:_lud(}{it:numeric matrix L}{cmd:,} {it:U}{cmd:,}
{it:p}{cmd:)}
{p 8 8 2}
{it:void}
{cmd:_lud_la(}{it:numeric matrix A}, {it:r}{cmd:)}
{p 4 4 2}
where
{p 8 12 2}
1. {it:A} may be real or complex, and need not be square.
{p 8 12 2}
2. The type of {it:L}, {it:U}, and {it:p} are irrelevant;
results are returned there.
{title:Description}
{p 4 4 2}
{cmd:lud(}{it:A}{cmd:,} {it:L}{cmd:,} {it:U}{cmd:,} {it:p}{cmd:)}
returns the LU decomposition (with partial pivoting) of {it:A} in {it:L} and
{it:U} along with a permutation vector {it:p}. The returned results are such
that {it:A} = {it:L}{cmd:[}{it:p}{cmd:,.]}*{it:U} up to roundoff error.
{p 4 4 2}
{cmd:_lud(}{it:L}{cmd:,} {it:U}{cmd:,} {it:p}{cmd:)} is similar to
{cmd:lud()}, except that it conserves memory. The matrix to be decomposed is
passed in {it:L}, and the same storage location is overwritten with the
calculated {it:L} matrix.
{p 4 4 2}
{cmd:_lud_la(}{it:A}, {it:r}{cmd:)} is the
{bf:{help m1_lapack:[M-1] LAPACK}} routine that
the above functions use to calculate the
LU decomposition.
See {it:LAPACK routine} below.
{title:Remarks}
{p 4 4 2}
Remarks are presented under the headings
{bf:LU decomposition}
{bf:LAPACK routine}
{title:LU decomposition}
{p 4 4 2}
The LU decomposition of matrix {it:A} can be written
{it:P}'{it:A} = {it:L}{it:U}
{p 4 4 2}
where {it:P}' is a permutation matrix that permutes the rows of {it:A}.
{it:L} is lower triangular and {it:U} is upper triangular.
The decomposition can also be written
{it:A} = {it:P}{it:L}{it:U}
{p 4 4 2}
because, given that {it:P} is a permutation matrix, {it:P}^(-1) = {it:P}'.
{p 4 4 2}
Note that, rather than returning {it:P} directly, returned is {it:p}
corresponding to {it:P}. Lowercase {it:p} is a
column vector that contains the subscripts of the rows in the desired
order. That is,
{it:P}{it:L} = {it:L}{cmd:[}{it:p}{cmd:,.]}
{p 4 4 2}
The advantage of this is that {it:p} requires less memory than {it:P} and
the reorganization, should it be desired, can be performed more quickly;
see {bf:{help m1_permutation:[M-1] permutation}}.
In any case, the formula defining the LU decomposition can be written
{it:A} = {it:L}{cmd:[}{it:p}{cmd:,.]}*{it:U}
{p 4 4 2}
Alternatively, one can write
{it:B} = {it:L}{it:U}, where {it:B}{cmd:[}{it:p}{cmd:,.]} = {it:A}
{title:LAPACK routine}
{p 4 4 2}
{cmd:_lud_la(}{it:A}, {it:r}{cmd:)} is the interface into the
{bf:{help m1_lapack:[M-1] LAPACK}} routines
that the above functions use to calculate the LU decomposition. You may use
it directly if you wish.
{p 4 4 2}
Matrix {it:A} is decomposed,
and the decomposition is placed back in {it:A}.
{it:U} is stored in the upper triangle (including the diagonal) of {it:A}.
{it:L} is stored in the lower triangle of {it:A}, and it is understood that
{it:L} is supposed to have ones on its diagonal. {it:r} is a column vector
recording the row swaps that account for the pivoting. This is the same
information as stored in {it:p}, but in a different format.
{p 4 4 2}
{it:r} records the row swaps to be made. For instance, {it:r} = (1\2\2)
means that (start at the end) the third row is to be swapped with the
second row, then the second row is to stay where it is, and finally the
first row is to stay where it is. {it:r} can be converted into {it:p}
by the following logic:
{it:p}{cmd: = 1::rows(}{it:r}{cmd:)}
{cmd:for (i=rows(}{it:r}{cmd:); i>=1; i--) {c -(}}
{cmd:hold = }{it:p}{cmd:[i]}
{it:p}{cmd:[i] = }{it:p}{cmd:[}{it:r}{cmd:[i]]}
{it:p}{cmd:[}{it:r}{cmd:[i]] = hold}
{cmd:{c )-}}
{title:Conformability}
{p 4 8 2}
{cmd:lud(}{it:A}{cmd:,} {it:L}{cmd:,} {it:U}{cmd:,}
{it:p}{cmd:)}:
{p_end}
{it:input:}
{it:A}: {it:r x c}
{it:output:}
{it:L}: {it:r x m}, {it:m} = min({it:r}, {it:c})
{it:U}: {it:m x c}
{it:p}: {it:r x} 1
{p 4 8 2}
{cmd:_lud(}{it:L}{cmd:,} {it:U}{cmd:,}
{it:p}{cmd:)}:
{p_end}
{it:input:}
{it:L}: {it:r x c}
{it:output:}
{it:L}: {it:r x m}, {it:m} = min({it:r}, {it:c})
{it:U}: {it:m x c}
{it:p}: {it:r x} 1
{p 4 8 2}
{cmd:_lud_la(}{it:A}, {it:r}{cmd:)}
{p_end}
{it:input:}
{it:L}: {it:r x c}
{it:output:}
{it:L}: {it:r x c}
{it:p}: {it:r x} 1
{title:Diagnostics}
{p 4 4 2}
{cmd:lud(}{it:A}{cmd:,} {it:L}{cmd:,} {it:U}{cmd:,} {it:p}{cmd:)}
returns missing results if {it:A} contains missing values;
{it:L} will have missing values below the diagonal, 1s on the diagonal,
and 0s above the diagonal;
{it:U} will have missing values on and above the diagonal and 0s below.
Thus if there are missing values, {it:U}[1,1] will contain missing.
{p 4 4 2}
{cmd:_lud(}{it:L}{cmd:,} {it:U}{cmd:,} {it:p}{cmd:)} sets {it:L} and
{it:U} as described above if {it:A} contains missing values.
{p 4 4 2}
{cmd:_lud_la(}{it:A}, {it:r}{cmd:)}
aborts with error if {it:A} is a view.
{title:Source code}
{p 4 4 2}
{view lud.mata, adopath asis:lud.mata},
{view _lud.mata, adopath asis:_lud.mata};
{cmd:_lud_la()} is built-in.
{title:Also see}
{p 4 13 2}
Manual: {hi:[M-5] lud()}
{p 4 13 2}
Online: help for
{bf:{help mf_det:[M-5] det()}},
{bf:{help mf_lusolve:[M-5] lusolve()}};
{bf:{help m4_matrix:[M-4] matrix}}
{p_end}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -