lufact
.. lufact(A [,pivot=Val{true}]) -> F
Compute the LU factorization of ``A``. The return type of ``F`` depends on the type of ``A``. In most cases, if ``A`` is a subtype ``S`` of AbstractMatrix with an element type ``T`` supporting ``+``, ``-``, ``*`` and ``/`` the return type is ``LU{T,S{T}}``. If pivoting is chosen (default) the element type should also support ``abs`` and ``<``. When ``A`` is sparse and have element of type ``Float32``, ``Float64``, ``Complex{Float32}``, or ``Complex{Float64}`` the return type is ``UmfpackLU``. Some examples are shown in the table below.
======================= ========================= ========================================
Type of input ``A`` Type of output ``F`` Relationship between ``F`` and ``A``
======================= ========================= ========================================
:func:`Matrix` ``LU`` ``F[:L]*F[:U] == A[F[:p], :]``
:func:`Tridiagonal` ``LU{T,Tridiagonal{T}}`` ``F[:L]*F[:U] == A[F[:p], :]``
:func:`SparseMatrixCSC` ``UmfpackLU`` ``F[:L]*F[:U] == (F[:Rs] .* A)[F[:p], F[:q]]``
======================= ========================= ========================================
The individual components of the factorization ``F`` can be accessed by indexing:
=========== ======================================= ====== ======================== =============
Component Description ``LU`` ``LU{T,Tridiagonal{T}}`` ``UmfpackLU``
=========== ======================================= ====== ======================== =============
``F[:L]`` ``L`` (lower triangular) part of ``LU`` ✓ ✓ ✓
``F[:U]`` ``U`` (upper triangular) part of ``LU`` ✓ ✓ ✓
``F[:p]`` (right) permutation ``Vector`` ✓ ✓ ✓
``F[:P]`` (right) permutation ``Matrix`` ✓ ✓
``F[:q]`` left permutation ``Vector`` ✓
``F[:Rs]`` ``Vector`` of scaling factors ✓
``F[:(:)]`` ``(L,U,p,q,Rs)`` components ✓
=========== ======================================= ====== ======================== =============
================== ====== ======================== =============
Supported function ``LU`` ``LU{T,Tridiagonal{T}}`` ``UmfpackLU``
================== ====== ======================== =============
``/`` ✓
``\`` ✓ ✓ ✓
``cond`` ✓ ✓
``det`` ✓ ✓ ✓
``logdet`` ✓ ✓
``logabsdet`` ✓ ✓
``size`` ✓ ✓
================== ====== ======================== =============
Examples
The lufact
function in Julia computes the LU factorization of a given matrix A
. The return type of F
depends on the type of A
. Here are some examples of its usage:
-
LU factorization of a matrix:
julia> A = [1 2; 3 4]; julia> F = lufact(A);
In this example, the LU factorization of the matrix
A
is computed, and the result is stored inF
. -
LU factorization of a tridiagonal matrix:
julia> T = Tridiagonal([1, 2, 3], [4, 5, 6], [7, 8, 9]); julia> F = lufact(T);
Here, the LU factorization of a tridiagonal matrix
T
is computed. - LU factorization of a sparse matrix:
julia> using SparseArrays julia> S = sprand(5, 5, 0.5); julia> F = lufact(S);
In this example, the LU factorization of a sparse matrix
S
is computed using the UMFPACK library.
You can access the individual components of the factorization F
using indexing. Here are some examples:
-
Accessing the lower triangular part:
julia> F[:L]
-
Accessing the upper triangular part:
julia> F[:U]
-
Accessing the permutation vector
p
:julia> F[:p]
-
Accessing the left permutation vector
q
(only applicable forUmfpackLU
):julia> F[:q]
- Accessing the scaling factors
Rs
(only applicable forUmfpackLU
):julia> F[:Rs]
Note that the availability of these components depends on the type of F
.
Supported operations and functions for the different factorization types are as follows:
- Division:
F / b
- Conditioning:
cond(F)
- Determinant:
det(F)
- Log-determinant:
logdet(F)
- Log-absolute-determinant:
logabsdet(F)
- Size:
size(F)
Please note that the specific functionality may vary depending on the factorization type.
That covers the basic usage and components of the lufact
function in Julia.
See Also
User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.