﻿ILMath.lu Method (InArray(complex), OutArray(complex), OutArray(complex)) ILNumerics Ultimate VS Documentation
ILNumerics - Technical Application Development
Decompose matrix A into uper and lower triangular matrices. Also generates pivoting permutation matrix.

[ILNumerics Computing Engine]

Namespace:  ILNumerics
Assembly:  ILNumerics.Computing (in ILNumerics.Computing.dll) Version: 5.5.0.0 (5.5.7503.3146)
Syntax

```public static RetArray<complex> lu(
InArray<complex> A,
OutArray<complex> U,
OutArray<complex> P = null
)```

#### Parameters

A
Type: ILNumericsInArraycomplex
Input matrix. Size [m x n].
U
Type: ILNumericsOutArraycomplex
[Output] Upper triangular matrix. Size [min(m,n) x n]. This can be null.
P (Optional)
Type: ILNumericsOutArraycomplex
[Output, optional] Permutation matrix P. Size [m x m]. Default: (null) do not compute the permutation matrix. L is ordered propery before the function returns.

#### Return Value

Type: RetArraycomplex
Lower triangular matrix L. Size [m x min(m,n)].
Exceptions

ExceptionCondition
ArgumentException if input A is not a matrix.
Remarks

A is decomposed into L and U so that the equation ILMath.multiply(L,U) == ILMath.multiply(P,A) holds within the range of round off errors.

The matrix L returned is a lower triangular matrix with unit diagonal. Depending on P the rows of L may be reordered due to pivoting during the triangulation. If P is not null on entry (i.e.: the permutation matrix P is computed and returned from lu(InArraycomplex, OutArraycomplex, OutArraycomplex)) L is truely lower triangular. In this case the equation ILMath.multiply(L,U) == ILMath.multiply(P,A) holds. Note, that the result of matrix multiplying L with U yields a version of A having its rows reordered. P permutes the rows of A accordingly. Note further, that P is suitable to be multiplied to A, while some other systems return P-1 for reordering the result L**U instead.

If P is null on entry (i.e.: the permutation matrix P is not requested and thus not returned) any permutation performed in the triangulation is reversed before returning L so that the matrix L returned is not guranteed to be lower triangular. Instead, the rows of L are reordered by P-1**L. In this case the simplified equation ILMath.multiply(L,U) == ILMath.multiply(A) holds (default).

U is a strictly upper triangular matrix. Any permutation is performed on L and not on U. Thus, the order of rows of U does not depend on P.

Examples

<code> // Construct a matrix A: Array<complex> A = new complex[,]{ {1, 2, 3}, {4, 4, 4}, {5, 6, 7} }; // A // <Double> [3x3] order: - //(:,:) // 1 2 3 // 4 4 4 // 5 6 7 // // define arrays serving as output arrays for U and P Array<complex> U = 1, P = 1; Array<complex> L = ILMath.lu(A, U, P); // L // <Double> [3,3] 1...1 order:| // 1 0 0 // 0,800000 1 0 // 0,200000 -1,000000 1 // // U //<Double> [3,3] 5...1,11022302462516E-15 order:| // 5 6 7 // 0 -0,800000 -1,600000 // 0 0 0,000000 // //P //<Double> [3,3] 0...0 order:| // 0 0 1 // 0 1 0 // 1 0 0 </code> L and U are triangular matrices. P is returned as well. The result of L**U gives:
```multiply(L,U)
5          6          7
4          4          4
1          2          3```
This result matches a reordered version of A, which can be computed by help of P: multiply(P,A) 5 6 7 4 4 4 1 2 3
Examples

// Computing the LU factorization of A without returning the permutation matrix P: <code> L = lu(A,U); // L // <Double> [3,3] 1...1 order:| // 0,200000 -1,000000 1 // 0,800000 1 0 // 1 0 0 // // U //<Double> [3,3] 5...1,11022302462516E-15 order:| // 5 6 7 // 0 -0,800000 -1,600000 // 0 0 0,000000 // </code> This time, while U did not change, L is not triangular but a reordered version of a lower triangular matrix. However, multiplying L ** U gives A directly: <code> multiply(L,U) 1 2 3 4 4 4 5 6 7 </code>

lu uses the Lapack function ?getrf.

The input matrix A is not altered.

Either of U and/or P can be null on entry. If U is null the upper triangular matrix will be computed but not returned. Instead, the compressed form of L and U is returned as created by the LAPACK function ?getrf:

```:'''''''|
|1 \    |
| 1 \ R |
|  1 \  |
| L 1 \ |
|    1 \|
'''''''''```

If P is null on entry and U is not null the permutation matrix is not computed but rows of L are reordered accordingly in order to fullfill the equation 'A = L**U'.

[ILNumerics Computing Engine]
{"ft_lang_label":"__label__en","ft_lang_prob":0.7949233,"math_prob":0.9763026,"size":2720,"snap":"2022-27-2022-33","text_gpt3_token_len":709,"char_repetition_ratio":0.14653903,"word_repetition_ratio":0.04017857,"special_character_ratio":0.25183824,"punctuation_ratio":0.14954954,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99706566,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-06-27T10:56:41Z\",\"WARC-Record-ID\":\"<urn:uuid:4997bc60-114a-4497-aa49-838c9ef2a8ce>\",\"Content-Length\":\"22955\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:da82cb40-faf5-4f70-9a78-61915a94d4c1>\",\"WARC-Concurrent-To\":\"<urn:uuid:c97b237a-239e-4198-9b72-68bca1614c3f>\",\"WARC-IP-Address\":\"85.10.192.68\",\"WARC-Target-URI\":\"https://ilnumerics.net/apidoc/html/M_ILNumerics_ILMath_lu_1.htm\",\"WARC-Payload-Digest\":\"sha1:CFDHEIHZE7SRZEZIITP4RRKZ3XIHF2TF\",\"WARC-Block-Digest\":\"sha1:2URFNYIAUNMPWFEWVSK4G2LFTNDXRXR2\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-27/CC-MAIN-2022-27_segments_1656103331729.20_warc_CC-MAIN-20220627103810-20220627133810-00376.warc.gz\"}"}