## [Standard functions](#Standard-functions)
```julia-repl
julia> A = Float64[1 4 5; 3 9 2]; B = Float64[1 4 2; 3 4 2; 8 7 1];

julia> X = A / B
2×3 Matrix{Float64}:
 -0.65   3.75  -1.2
  3.25  -2.75   1.0

julia> isapprox(A, X*B)
true

julia> isapprox(X, A*pinv(B))
true
```
```julia
SingularException
```
Exception thrown when the input matrix has one or more zero-valued eigenvalues, and is not invertible. A linear solve involving such a matrix cannot be computed. The `info` field indicates the location of (one of) the singular value(s).
```julia
PosDefException
```
Exception thrown when the input matrix was not [positive definite](https://en.wikipedia.org/wiki/Definiteness_of_a_matrix). Some linear algebra functions and factorizations are only applicable to positive definite matrices. The `info` field indicates the location of (one of) the eigenvalue(s) which is (are) less than/equal to 0.
```julia
ZeroPivotException <: Exception
```
Exception thrown when a matrix factorization/solve encounters a zero in a pivot (diagonal) position and cannot proceed. This may *not* mean that the matrix is singular: it may be fruitful to switch to a different factorization such as pivoted LU that can re-order variables to eliminate spurious zero pivots. The `info` field indicates the location of (one of) the zero pivot(s).
```julia
RankDeficientException
```


## [Standard functions](#Standard-functions)
Exception thrown when the input matrix is [rank deficient](https://en.wikipedia.org/wiki/Rank_(linear_algebra)). Some linear algebra functions, such as the Cholesky decomposition, are only applicable to matrices that are not rank deficient. The `info` field indicates the computed rank of the matrix.
```julia
LAPACKException
```
Generic LAPACK exception thrown either during direct calls to the [LAPACK functions](#man-linalg-lapack-functions) or during calls to other functions that use the LAPACK functions internally but lack specialized error handling. The `info` field contains additional information on the underlying error and depends on the LAPACK function that was invoked.
```julia
dot(x, y)
x ⋅ y
```
Compute the dot product between two vectors. For complex vectors, the first vector is conjugated.
`dot` also works on arbitrary iterable objects, including arrays of any dimension, as long as `dot` is defined on the elements.
`dot` is semantically equivalent to `sum(dot(vx,vy) for (vx,vy) in zip(x, y))`, with the added restriction that the arguments must have equal lengths.
`x ⋅ y` (where `⋅` can be typed by tab-completing `\cdot` in the REPL) is a synonym for `dot(x, y)`.
**Examples**
```julia-repl
julia> dot([1; 1], [2; 3])
5

julia> dot([im; im], [1; 1])
0 - 2im

julia> dot(1:5, 2:6)
70

julia> x = fill(2., (5,5));

julia> y = fill(3., (5,5));

julia> dot(x, y)
150.0
```
```julia
dot(x, A, y)
```


## [Standard functions](#Standard-functions)
Compute the generalized dot product `dot(x, A*y)` between two vectors `x` and `y`, without storing the intermediate result of `A*y`. As for the two-argument [`dot(_,_)`](#LinearAlgebra.dot), this acts recursively. Moreover, for complex vectors, the first vector is conjugated.
Three-argument `dot` requires at least Julia 1.4.
**Examples**
```julia-repl
julia> dot([1; 1], [1 2; 3 4], [2; 3])
26

julia> dot(1:5, reshape(1:25, 5, 5), 2:6)
4850

julia> ⋅(1:5, reshape(1:25, 5, 5), 2:6) == dot(1:5, reshape(1:25, 5, 5), 2:6)
true
```
```julia
cross(x, y)
×(x,y)
```
Compute the cross product of two 3-vectors.
**Examples**
```julia-repl
julia> a = [0;1;0]
3-element Vector{Int64}:
 0
 1
 0

julia> b = [0;0;1]
3-element Vector{Int64}:
 0
 0
 1

julia> cross(a,b)
3-element Vector{Int64}:
 1
 0
 0
```
```julia
axpy!(α, x::AbstractArray, y::AbstractArray)
```
Overwrite `y` with `x * α + y` and return `y`. If `x` and `y` have the same axes, it's equivalent with `y .+= x .* a`.
**Examples**
```julia-repl
julia> x = [1; 2; 3];

julia> y = [4; 5; 6];

julia> axpy!(2, x, y)
3-element Vector{Int64}:
  6
  9
 12
```
```julia
axpby!(α, x::AbstractArray, β, y::AbstractArray)
```
Overwrite `y` with `x * α + y * β` and return `y`. If `x` and `y` have the same axes, it's equivalent with `y .= x .* a .+ y .* β`.
**Examples**
```julia-repl
julia> x = [1; 2; 3];

julia> y = [4; 5; 6];

julia> axpby!(2, x, 2, y)
3-element Vector{Int64}:
 10
 14
 18
```
```julia
rotate!(x, y, c, s)
```


## [Standard functions](#Standard-functions)
Overwrite `x` with `c*x + s*y` and `y` with `-conj(s)*x + c*y`. Returns `x` and `y`.
`rotate!` requires at least Julia 1.5.
```julia
reflect!(x, y, c, s)
```
Overwrite `x` with `c*x + s*y` and `y` with `conj(s)*x - c*y`. Returns `x` and `y`.
`reflect!` requires at least Julia 1.5.
```julia
factorize(A)
```
Compute a convenient factorization of `A`, based upon the type of the input matrix. `factorize` checks `A` to see if it is symmetric/triangular/etc. if `A` is passed as a generic matrix. `factorize` checks every element of `A` to verify/rule out each property. It will short-circuit as soon as it can rule out symmetry/triangular structure. The return value can be reused for efficient solving of multiple systems. For example: `A=factorize(A); x=A\b; y=A\C`.


## [Standard functions](#Standard-functions)
| Properties of `A`          | type of factorization                                             |
|:---------------------------|:------------------------------------------------------------------|
| Positive-definite          | Cholesky (see [`cholesky`](#LinearAlgebra.cholesky))              |
| Dense Symmetric/Hermitian  | Bunch-Kaufman (see [`bunchkaufman`](#LinearAlgebra.bunchkaufman)) |
| Sparse Symmetric/Hermitian | LDLt (see [`ldlt`](#LinearAlgebra.ldlt))                          |
| Triangular                 | Triangular                                                        |
| Diagonal                   | Diagonal                                                          |
| Bidiagonal                 | Bidiagonal                                                        |
| Tridiagonal                | LU (see [`lu`](#LinearAlgebra.lu))                                |
| Symmetric real tridiagonal | LDLt (see [`ldlt`](#LinearAlgebra.ldlt))                          |
| General square             | LU (see [`lu`](#LinearAlgebra.lu))                                |
| General non-square         | QR (see [`qr`](#LinearAlgebra.qr))                                |
If `factorize` is called on a Hermitian positive-definite matrix, for instance, then `factorize` will return a Cholesky factorization.
**Examples**


## [Standard functions](#Standard-functions)
```julia-repl
julia> A = Array(Bidiagonal(fill(1.0, (5, 5)), :U))
5×5 Matrix{Float64}:
 1.0  1.0  0.0  0.0  0.0
 0.0  1.0  1.0  0.0  0.0
 0.0  0.0  1.0  1.0  0.0
 0.0  0.0  0.0  1.0  1.0
 0.0  0.0  0.0  0.0  1.0

julia> factorize(A) # factorize will check to see that A is already factorized
5×5 Bidiagonal{Float64, Vector{Float64}}:
 1.0  1.0   ⋅    ⋅    ⋅
  ⋅   1.0  1.0   ⋅    ⋅
  ⋅    ⋅   1.0  1.0   ⋅
  ⋅    ⋅    ⋅   1.0  1.0
  ⋅    ⋅    ⋅    ⋅   1.0
```
This returns a `5×5 Bidiagonal{Float64}`, which can now be passed to other linear algebra functions (e.g. eigensolvers) which will use specialized methods for `Bidiagonal` types.
```julia
Diagonal(V::AbstractVector)
```
Construct a lazy matrix with `V` as its diagonal.
See also [`UniformScaling`](#LinearAlgebra.UniformScaling) for the lazy identity matrix `I`, [`diagm`](#LinearAlgebra.diagm) to make a dense matrix, and [`diag`](#LinearAlgebra.diag) to extract diagonal elements.
**Examples**
```julia-repl
julia> d = Diagonal([1, 10, 100])
3×3 Diagonal{Int64, Vector{Int64}}:
 1   ⋅    ⋅
 ⋅  10    ⋅
 ⋅   ⋅  100

julia> diagm([7, 13])
2×2 Matrix{Int64}:
 7   0
 0  13

julia> ans + I
2×2 Matrix{Int64}:
 8   0
 0  14

julia> I(2)
2×2 Diagonal{Bool, Vector{Bool}}:
 1  ⋅
 ⋅  1
```
A one-column matrix is not treated like a vector, but instead calls the method `Diagonal(A::AbstractMatrix)` which extracts 1-element `diag(A)`:


## [Standard functions](#Standard-functions)
```julia-repl
julia> A = transpose([7.0 13.0])
2×1 transpose(::Matrix{Float64}) with eltype Float64:
  7.0
 13.0

julia> Diagonal(A)
1×1 Diagonal{Float64, Vector{Float64}}:
 7.0
```
```julia
Diagonal(A::AbstractMatrix)
```
Construct a matrix from the principal diagonal of `A`. The input matrix `A` may be rectangular, but the output will be square.
**Examples**
```julia-repl
julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> D = Diagonal(A)
2×2 Diagonal{Int64, Vector{Int64}}:
 1  ⋅
 ⋅  4

julia> A = [1 2 3; 4 5 6]
2×3 Matrix{Int64}:
 1  2  3
 4  5  6

julia> Diagonal(A)
2×2 Diagonal{Int64, Vector{Int64}}:
 1  ⋅
 ⋅  5
```
```julia
Diagonal{T}(undef, n)
```
Construct an uninitialized `Diagonal{T}` of length `n`. See `undef`.
```julia
Bidiagonal(dv::V, ev::V, uplo::Symbol) where V <: AbstractVector
```
Constructs an upper (`uplo=:U`) or lower (`uplo=:L`) bidiagonal matrix using the given diagonal (`dv`) and off-diagonal (`ev`) vectors. The result is of type `Bidiagonal` and provides efficient specialized linear solvers, but may be converted into a regular matrix with [`convert(Array, _)`](../../base/base/#Base.convert) (or `Array(_)` for short). The length of `ev` must be one less than the length of `dv`.
**Examples**


## [Standard functions](#Standard-functions)
```julia-repl
julia> dv = [1, 2, 3, 4]
4-element Vector{Int64}:
 1
 2
 3
 4

julia> ev = [7, 8, 9]
3-element Vector{Int64}:
 7
 8
 9

julia> Bu = Bidiagonal(dv, ev, :U) # ev is on the first superdiagonal
4×4 Bidiagonal{Int64, Vector{Int64}}:
 1  7  ⋅  ⋅
 ⋅  2  8  ⋅
 ⋅  ⋅  3  9
 ⋅  ⋅  ⋅  4

julia> Bl = Bidiagonal(dv, ev, :L) # ev is on the first subdiagonal
4×4 Bidiagonal{Int64, Vector{Int64}}:
 1  ⋅  ⋅  ⋅
 7  2  ⋅  ⋅
 ⋅  8  3  ⋅
 ⋅  ⋅  9  4
```
```julia
Bidiagonal(A, uplo::Symbol)
```
Construct a `Bidiagonal` matrix from the main diagonal of `A` and its first super- (if `uplo=:U`) or sub-diagonal (if `uplo=:L`).
**Examples**
```julia-repl
julia> A = [1 1 1 1; 2 2 2 2; 3 3 3 3; 4 4 4 4]
4×4 Matrix{Int64}:
 1  1  1  1
 2  2  2  2
 3  3  3  3
 4  4  4  4

julia> Bidiagonal(A, :U) # contains the main diagonal and first superdiagonal of A
4×4 Bidiagonal{Int64, Vector{Int64}}:
 1  1  ⋅  ⋅
 ⋅  2  2  ⋅
 ⋅  ⋅  3  3
 ⋅  ⋅  ⋅  4

julia> Bidiagonal(A, :L) # contains the main diagonal and first subdiagonal of A
4×4 Bidiagonal{Int64, Vector{Int64}}:
 1  ⋅  ⋅  ⋅
 2  2  ⋅  ⋅
 ⋅  3  3  ⋅
 ⋅  ⋅  4  4
```
```julia
SymTridiagonal(dv::V, ev::V) where V <: AbstractVector
```
Construct a symmetric tridiagonal matrix from the diagonal (`dv`) and first sub/super-diagonal (`ev`), respectively. The result is of type `SymTridiagonal` and provides efficient specialized eigensolvers, but may be converted into a regular matrix with [`convert(Array, _)`](../../base/base/#Base.convert) (or `Array(_)` for short).


## [Standard functions](#Standard-functions)
For `SymTridiagonal` block matrices, the elements of `dv` are symmetrized. The argument `ev` is interpreted as the superdiagonal. Blocks from the subdiagonal are (materialized) transpose of the corresponding superdiagonal blocks.
**Examples**
```julia-repl
julia> dv = [1, 2, 3, 4]
4-element Vector{Int64}:
 1
 2
 3
 4

julia> ev = [7, 8, 9]
3-element Vector{Int64}:
 7
 8
 9

julia> SymTridiagonal(dv, ev)
4×4 SymTridiagonal{Int64, Vector{Int64}}:
 1  7  ⋅  ⋅
 7  2  8  ⋅
 ⋅  8  3  9
 ⋅  ⋅  9  4

julia> A = SymTridiagonal(fill([1 2; 3 4], 3), fill([1 2; 3 4], 2));

julia> A[1,1]
2×2 Symmetric{Int64, Matrix{Int64}}:
 1  2
 2  4

julia> A[1,2]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> A[2,1]
2×2 Matrix{Int64}:
 1  3
 2  4
```
```julia
SymTridiagonal(A::AbstractMatrix)
```
Construct a symmetric tridiagonal matrix from the diagonal and first superdiagonal of the symmetric matrix `A`.
**Examples**
```julia-repl
julia> A = [1 2 3; 2 4 5; 3 5 6]
3×3 Matrix{Int64}:
 1  2  3
 2  4  5
 3  5  6

julia> SymTridiagonal(A)
3×3 SymTridiagonal{Int64, Vector{Int64}}:
 1  2  ⋅
 2  4  5
 ⋅  5  6

julia> B = reshape([[1 2; 2 3], [1 2; 3 4], [1 3; 2 4], [1 2; 2 3]], 2, 2);

julia> SymTridiagonal(B)
2×2 SymTridiagonal{Matrix{Int64}, Vector{Matrix{Int64}}}:
 [1 2; 2 3]  [1 3; 2 4]
 [1 2; 3 4]  [1 2; 2 3]
```
```julia
Tridiagonal(dl::V, d::V, du::V) where V <: AbstractVector
```


## [Standard functions](#Standard-functions)
Construct a tridiagonal matrix from the first subdiagonal, diagonal, and first superdiagonal, respectively. The result is of type `Tridiagonal` and provides efficient specialized linear solvers, but may be converted into a regular matrix with [`convert(Array, _)`](../../base/base/#Base.convert) (or `Array(_)` for short). The lengths of `dl` and `du` must be one less than the length of `d`.
The subdiagonal `dl` and the superdiagonal `du` must not be aliased to each other. If aliasing is detected, the constructor will use a copy of `du` as its argument.
**Examples**
```julia-repl
julia> dl = [1, 2, 3];

julia> du = [4, 5, 6];

julia> d = [7, 8, 9, 0];

julia> Tridiagonal(dl, d, du)
4×4 Tridiagonal{Int64, Vector{Int64}}:
 7  4  ⋅  ⋅
 1  8  5  ⋅
 ⋅  2  9  6
 ⋅  ⋅  3  0
```
```julia
Tridiagonal(A)
```
Construct a tridiagonal matrix from the first sub-diagonal, diagonal and first super-diagonal of the matrix `A`.
**Examples**
```julia-repl
julia> A = [1 2 3 4; 1 2 3 4; 1 2 3 4; 1 2 3 4]
4×4 Matrix{Int64}:
 1  2  3  4
 1  2  3  4
 1  2  3  4
 1  2  3  4

julia> Tridiagonal(A)
4×4 Tridiagonal{Int64, Vector{Int64}}:
 1  2  ⋅  ⋅
 1  2  3  ⋅
 ⋅  2  3  4
 ⋅  ⋅  3  4
```
```julia
Symmetric(A::AbstractMatrix, uplo::Symbol=:U)
```
Construct a `Symmetric` view of the upper (if `uplo = :U`) or lower (if `uplo = :L`) triangle of the matrix `A`.


## [Standard functions](#Standard-functions)
`Symmetric` views are mainly useful for real-symmetric matrices, for which specialized algorithms (e.g. for eigenproblems) are enabled for `Symmetric` types. More generally, see also [`Hermitian(A)`](#LinearAlgebra.Hermitian) for Hermitian matrices `A == A'`, which is effectively equivalent to `Symmetric` for real matrices but is also useful for complex matrices. (Whereas complex `Symmetric` matrices are supported but have few if any specialized algorithms.)
To compute the symmetric part of a real matrix, or more generally the Hermitian part `(A + A') / 2` of a real or complex matrix `A`, use [`hermitianpart`](#LinearAlgebra.hermitianpart).
**Examples**
```julia-repl
julia> A = [1 2 3; 4 5 6; 7 8 9]
3×3 Matrix{Int64}:
 1  2  3
 4  5  6
 7  8  9

julia> Supper = Symmetric(A)
3×3 Symmetric{Int64, Matrix{Int64}}:
 1  2  3
 2  5  6
 3  6  9

julia> Slower = Symmetric(A, :L)
3×3 Symmetric{Int64, Matrix{Int64}}:
 1  4  7
 4  5  8
 7  8  9

julia> hermitianpart(A)
3×3 Hermitian{Float64, Matrix{Float64}}:
 1.0  3.0  5.0
 3.0  5.0  7.0
 5.0  7.0  9.0
```
Note that `Supper` will not be equal to `Slower` unless `A` is itself symmetric (e.g. if `A == transpose(A)`).
```julia
Hermitian(A::AbstractMatrix, uplo::Symbol=:U)
```
Construct a `Hermitian` view of the upper (if `uplo = :U`) or lower (if `uplo = :L`) triangle of the matrix `A`.
To compute the Hermitian part of `A`, use [`hermitianpart`](#LinearAlgebra.hermitianpart).
**Examples**


## [Standard functions](#Standard-functions)
```julia-repl
julia> A = [1 2+2im 3-3im; 4 5 6-6im; 7 8+8im 9]
3×3 Matrix{Complex{Int64}}:
 1+0im  2+2im  3-3im
 4+0im  5+0im  6-6im
 7+0im  8+8im  9+0im

julia> Hupper = Hermitian(A)
3×3 Hermitian{Complex{Int64}, Matrix{Complex{Int64}}}:
 1+0im  2+2im  3-3im
 2-2im  5+0im  6-6im
 3+3im  6+6im  9+0im

julia> Hlower = Hermitian(A, :L)
3×3 Hermitian{Complex{Int64}, Matrix{Complex{Int64}}}:
 1+0im  4+0im  7+0im
 4+0im  5+0im  8-8im
 7+0im  8+8im  9+0im

julia> hermitianpart(A)
3×3 Hermitian{ComplexF64, Matrix{ComplexF64}}:
 1.0+0.0im  3.0+1.0im  5.0-1.5im
 3.0-1.0im  5.0+0.0im  7.0-7.0im
 5.0+1.5im  7.0+7.0im  9.0+0.0im
```
Note that `Hupper` will not be equal to `Hlower` unless `A` is itself Hermitian (e.g. if `A == adjoint(A)`).
All non-real parts of the diagonal will be ignored.
```julia
Hermitian(fill(complex(1,1), 1, 1)) == fill(1, 1, 1)
```
```julia
LowerTriangular(A::AbstractMatrix)
```
Construct a `LowerTriangular` view of the matrix `A`.
**Examples**
```julia-repl
julia> A = [1.0 2.0 3.0; 4.0 5.0 6.0; 7.0 8.0 9.0]
3×3 Matrix{Float64}:
 1.0  2.0  3.0
 4.0  5.0  6.0
 7.0  8.0  9.0

julia> LowerTriangular(A)
3×3 LowerTriangular{Float64, Matrix{Float64}}:
 1.0   ⋅    ⋅
 4.0  5.0   ⋅
 7.0  8.0  9.0
```
```julia
UpperTriangular(A::AbstractMatrix)
```
Construct an `UpperTriangular` view of the matrix `A`.
**Examples**


## [Standard functions](#Standard-functions)
```julia-repl
julia> A = [1.0 2.0 3.0; 4.0 5.0 6.0; 7.0 8.0 9.0]
3×3 Matrix{Float64}:
 1.0  2.0  3.0
 4.0  5.0  6.0
 7.0  8.0  9.0

julia> UpperTriangular(A)
3×3 UpperTriangular{Float64, Matrix{Float64}}:
 1.0  2.0  3.0
  ⋅   5.0  6.0
  ⋅    ⋅   9.0
```
```julia
UnitLowerTriangular(A::AbstractMatrix)
```
Construct a `UnitLowerTriangular` view of the matrix `A`. Such a view has the [`oneunit`](../../base/numbers/#Base.oneunit) of the [`eltype`](../../base/collections/#Base.eltype) of `A` on its diagonal.
**Examples**
```julia-repl
julia> A = [1.0 2.0 3.0; 4.0 5.0 6.0; 7.0 8.0 9.0]
3×3 Matrix{Float64}:
 1.0  2.0  3.0
 4.0  5.0  6.0
 7.0  8.0  9.0

julia> UnitLowerTriangular(A)
3×3 UnitLowerTriangular{Float64, Matrix{Float64}}:
 1.0   ⋅    ⋅
 4.0  1.0   ⋅
 7.0  8.0  1.0
```
```julia
UnitUpperTriangular(A::AbstractMatrix)
```
Construct an `UnitUpperTriangular` view of the matrix `A`. Such a view has the [`oneunit`](../../base/numbers/#Base.oneunit) of the [`eltype`](../../base/collections/#Base.eltype) of `A` on its diagonal.
**Examples**
```julia-repl
julia> A = [1.0 2.0 3.0; 4.0 5.0 6.0; 7.0 8.0 9.0]
3×3 Matrix{Float64}:
 1.0  2.0  3.0
 4.0  5.0  6.0
 7.0  8.0  9.0

julia> UnitUpperTriangular(A)
3×3 UnitUpperTriangular{Float64, Matrix{Float64}}:
 1.0  2.0  3.0
  ⋅   1.0  6.0
  ⋅    ⋅   1.0
```
```julia
UpperHessenberg(A::AbstractMatrix)
```
Construct an `UpperHessenberg` view of the matrix `A`. Entries of `A` below the first subdiagonal are ignored.
This type was added in Julia 1.3.


## [Standard functions](#Standard-functions)
Efficient algorithms are implemented for `H \ b`, `det(H)`, and similar.
See also the [`hessenberg`](#LinearAlgebra.hessenberg) function to factor any matrix into a similar upper-Hessenberg matrix.
If `F::Hessenberg` is the factorization object, the unitary matrix can be accessed with `F.Q` and the Hessenberg matrix with `F.H`. When `Q` is extracted, the resulting type is the `HessenbergQ` object, and may be converted to a regular matrix with [`convert(Array, _)`](../../base/base/#Base.convert) (or `Array(_)` for short).
Iterating the decomposition produces the factors `F.Q` and `F.H`.
**Examples**
```julia-repl
julia> A = [1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16]
4×4 Matrix{Int64}:
  1   2   3   4
  5   6   7   8
  9  10  11  12
 13  14  15  16

julia> UpperHessenberg(A)
4×4 UpperHessenberg{Int64, Matrix{Int64}}:
 1   2   3   4
 5   6   7   8
 ⋅  10  11  12
 ⋅   ⋅  15  16
```
```julia
UniformScaling{T<:Number}
```
Generically sized uniform scaling operator defined as a scalar times the identity operator, `λ*I`. Although without an explicit `size`, it acts similarly to a matrix in many cases and includes support for some indexing. See also [`I`](#LinearAlgebra.I).
Indexing using ranges is available as of Julia 1.6.
**Examples**
```julia-repl
julia> J = UniformScaling(2.)
UniformScaling{Float64}
2.0*I

julia> A = [1. 2.; 3. 4.]
2×2 Matrix{Float64}:
 1.0  2.0
 3.0  4.0

julia> J*A
2×2 Matrix{Float64}:
 2.0  4.0
 6.0  8.0

julia> J[1:2, 1:2]
2×2 Matrix{Float64}:
 2.0  0.0
 0.0  2.0
```
```julia
I
```


## [Standard functions](#Standard-functions)
An object of type [`UniformScaling`](#LinearAlgebra.UniformScaling), representing an identity matrix of any size.
**Examples**
```julia-repl
julia> fill(1, (5,6)) * I == fill(1, (5,6))
true

julia> [1 2im 3; 1im 2 3] * I
2×3 Matrix{Complex{Int64}}:
 1+0im  0+2im  3+0im
 0+1im  2+0im  3+0im
```
```julia
(I::UniformScaling)(n::Integer)
```
Construct a `Diagonal` matrix from a `UniformScaling`.
This method is available as of Julia 1.2.
**Examples**
```julia-repl
julia> I(3)
3×3 Diagonal{Bool, Vector{Bool}}:
 1  ⋅  ⋅
 ⋅  1  ⋅
 ⋅  ⋅  1

julia> (0.7*I)(3)
3×3 Diagonal{Float64, Vector{Float64}}:
 0.7   ⋅    ⋅
  ⋅   0.7   ⋅
  ⋅    ⋅   0.7
```
```julia
LinearAlgebra.Factorization
```
Abstract type for [matrix factorizations](https://en.wikipedia.org/wiki/Matrix_decomposition) a.k.a. matrix decompositions. See [online documentation](#man-linalg-factorizations) for a list of available matrix factorizations.
```julia
LU <: Factorization
```
Matrix factorization type of the `LU` factorization of a square matrix `A`. This is the return type of [`lu`](#LinearAlgebra.lu), the corresponding matrix factorization function.
The individual components of the factorization `F::LU` can be accessed via [`getproperty`](../../base/base/#Base.getproperty):


## [Standard functions](#Standard-functions)
| Component | Description                              |
|:----------|:-----------------------------------------|
| `F.L`     | `L` (unit lower triangular) part of `LU` |
| `F.U`     | `U` (upper triangular) part of `LU`      |
| `F.p`     | (right) permutation `Vector`             |
| `F.P`     | (right) permutation `Matrix`             |
Iterating the factorization produces the components `F.L`, `F.U`, and `F.p`.
**Examples**
```julia-repl
julia> A = [4 3; 6 3]
2×2 Matrix{Int64}:
 4  3
 6  3

julia> F = lu(A)
LU{Float64, Matrix{Float64}, Vector{Int64}}
L factor:
2×2 Matrix{Float64}:
 1.0       0.0
 0.666667  1.0
U factor:
2×2 Matrix{Float64}:
 6.0  3.0
 0.0  1.0

julia> F.L * F.U == A[F.p, :]
true

julia> l, u, p = lu(A); # destructuring via iteration

julia> l == F.L && u == F.U && p == F.p
true
```
```julia
lu(A::AbstractSparseMatrixCSC; check = true, q = nothing, control = get_umfpack_control()) -> F::UmfpackLU
```
Compute the LU factorization of a sparse matrix `A`.
For sparse `A` with real or complex element type, the return type of `F` is `UmfpackLU{Tv, Ti}`, with `Tv` = [`Float64`](../../base/numbers/#Core.Float64) or `ComplexF64` respectively and `Ti` is an integer type ([`Int32`](../../base/numbers/#Core.Int32) or [`Int64`](../../base/numbers/#Core.Int64)).
When `check = true`, an error is thrown if the decomposition fails. When `check = false`, responsibility for checking the decomposition's validity (via [`issuccess`](#LinearAlgebra.issuccess)) lies with the user.


## [Standard functions](#Standard-functions)
The permutation `q` can either be a permutation vector or `nothing`. If no permutation vector is provided or `q` is `nothing`, UMFPACK's default is used. If the permutation is not zero-based, a zero-based copy is made.
The `control` vector defaults to the Julia SparseArrays package's default configuration for UMFPACK (NB: this is modified from the UMFPACK defaults to disable iterative refinement), but can be changed by passing a vector of length `UMFPACK_CONTROL`, see the UMFPACK manual for possible configurations. For example to reenable iterative refinement:
```julia
umfpack_control = SparseArrays.UMFPACK.get_umfpack_control(Float64, Int64) # read Julia default configuration for a Float64 sparse matrix
SparseArrays.UMFPACK.show_umf_ctrl(umfpack_control) # optional - display values
umfpack_control[SparseArrays.UMFPACK.JL_UMFPACK_IRSTEP] = 2.0 # reenable iterative refinement (2 is UMFPACK default max iterative refinement steps)

Alu = lu(A; control = umfpack_control)
x = Alu \ b   # solve Ax = b, including UMFPACK iterative refinement
```
The individual components of the factorization `F` can be accessed by indexing:
| Component | Description                         |
|:----------|:------------------------------------|
| `L`       | `L` (lower triangular) part of `LU` |
| `U`       | `U` (upper triangular) part of `LU` |
| `p`       | right permutation `Vector`          |
| `q`       | left permutation `Vector`           |
| `Rs`      | `Vector` of scaling factors         |
| `:`       | `(L,U,p,q,Rs)` components           |


## [Standard functions](#Standard-functions)
The relation between `F` and `A` is
`F.L*F.U == (F.Rs .* A)[F.p, F.q]`
`F` further supports the following functions:
-   [`\`](../../base/math/#Base.:\\-Tuple%7BAny,%20Any%7D)
-   [`det`](#LinearAlgebra.det)
See also [`lu!`](#LinearAlgebra.lu!)
`lu(A::AbstractSparseMatrixCSC)` uses the UMFPACK<sup>[[ACM832\]](#footnote-ACM832)</sup> library that is part of [SuiteSparse](https://github.com/DrTimothyAldenDavis/SuiteSparse). As this library only supports sparse matrices with [`Float64`](../../base/numbers/#Core.Float64) or `ComplexF64` elements, `lu` converts `A` into a copy that is of type `SparseMatrixCSC{Float64}` or `SparseMatrixCSC{ComplexF64}` as appropriate.
```julia
lu(A, pivot = RowMaximum(); check = true, allowsingular = false) -> F::LU
```
Compute the LU factorization of `A`.
When `check = true`, an error is thrown if the decomposition fails. When `check = false`, responsibility for checking the decomposition's validity (via [`issuccess`](#LinearAlgebra.issuccess)) lies with the user.
By default, with `check = true`, an error is also thrown when the decomposition produces valid factors, but the upper-triangular factor `U` is rank-deficient. This may be changed by passing `allowsingular = true`.
In most cases, if `A` is a subtype `S` of `AbstractMatrix{T}` with an element type `T` supporting `+`, `-`, `*` and `/`, the return type is `LU{T,S{T}}`.


## [Standard functions](#Standard-functions)
In general, LU factorization involves a permutation of the rows of the matrix (corresponding to the `F.p` output described below), known as "pivoting" (because it corresponds to choosing which row contains the "pivot", the diagonal entry of `F.U`). One of the following pivoting strategies can be selected via the optional `pivot` argument:
-   `RowMaximum()` (default): the standard pivoting strategy; the pivot corresponds to the element of maximum absolute value among the remaining, to be factorized rows. This pivoting strategy requires the element type to also support [`abs`](../../base/math/#Base.abs) and [`<`](../../base/math/#Base.:%3C). (This is generally the only numerically stable option for floating-point matrices.)
-   `RowNonZero()`: the pivot corresponds to the first non-zero element among the remaining, to be factorized rows. (This corresponds to the typical choice in hand calculations, and is also useful for more general algebraic number types that support [`iszero`](../../base/numbers/#Base.iszero) but not `abs` or `<`.)
-   `NoPivot()`: pivoting turned off (will fail if a zero entry is encountered in a pivot position, even when `allowsingular = true`).
The individual components of the factorization `F` can be accessed via [`getproperty`](../../base/base/#Base.getproperty):


## [Standard functions](#Standard-functions)
| Component | Description                         |
|:----------|:------------------------------------|
| `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`        |
Iterating the factorization produces the components `F.L`, `F.U`, and `F.p`.
The relationship between `F` and `A` is
`F.L*F.U == A[F.p, :]`
`F` further supports the following functions:
| Supported function                                     | `LU` | `LU{T,Tridiagonal{T}}` |
|:-------------------------------------------------------|:-----|:-----------------------|
| [`/`](../../base/math/#Base.:/)                        | ✓    |                        |
| [`\`](../../base/math/#Base.:\\-Tuple%7BAny,%20Any%7D) | ✓    | ✓                      |
| [`inv`](../../base/math/#Base.inv-Tuple%7BNumber%7D)   | ✓    | ✓                      |
| [`det`](#LinearAlgebra.det)                            | ✓    | ✓                      |
| [`logdet`](#LinearAlgebra.logdet)                      | ✓    | ✓                      |
| [`logabsdet`](#LinearAlgebra.logabsdet)                | ✓    | ✓                      |
| [`size`](../../base/arrays/#Base.size)                 | ✓    | ✓                      |
The `allowsingular` keyword argument was added in Julia 1.11.
**Examples**


## [Standard functions](#Standard-functions)
```julia-repl
julia> A = [4 3; 6 3]
2×2 Matrix{Int64}:
 4  3
 6  3

julia> F = lu(A)
LU{Float64, Matrix{Float64}, Vector{Int64}}
L factor:
2×2 Matrix{Float64}:
 1.0       0.0
 0.666667  1.0
U factor:
2×2 Matrix{Float64}:
 6.0  3.0
 0.0  1.0

julia> F.L * F.U == A[F.p, :]
true

julia> l, u, p = lu(A); # destructuring via iteration

julia> l == F.L && u == F.U && p == F.p
true

julia> lu([1 2; 1 2], allowsingular = true)
LU{Float64, Matrix{Float64}, Vector{Int64}}
L factor:
2×2 Matrix{Float64}:
 1.0  0.0
 1.0  1.0
U factor (rank-deficient):
2×2 Matrix{Float64}:
 1.0  2.0
 0.0  0.0
```
```julia
lu!(F::UmfpackLU, A::AbstractSparseMatrixCSC; check=true, reuse_symbolic=true, q=nothing) -> F::UmfpackLU
```
Compute the LU factorization of a sparse matrix `A`, reusing the symbolic factorization of an already existing LU factorization stored in `F`. Unless `reuse_symbolic` is set to false, the sparse matrix `A` must have an identical nonzero pattern as the matrix used to create the LU factorization `F`, otherwise an error is thrown. If the size of `A` and `F` differ, all vectors will be resized accordingly.
When `check = true`, an error is thrown if the decomposition fails. When `check = false`, responsibility for checking the decomposition's validity (via [`issuccess`](#LinearAlgebra.issuccess)) lies with the user.
The permutation `q` can either be a permutation vector or `nothing`. If no permutation vector is provided or `q` is `nothing`, UMFPACK's default is used. If the permutation is not zero based, a zero based copy is made.


## [Standard functions](#Standard-functions)
See also [`lu`](#LinearAlgebra.lu)
`lu!(F::UmfpackLU, A::AbstractSparseMatrixCSC)` uses the UMFPACK library that is part of SuiteSparse. As this library only supports sparse matrices with [`Float64`](../../base/numbers/#Core.Float64) or `ComplexF64` elements, `lu!` will automatically convert the types to those set by the LU factorization or `SparseMatrixCSC{ComplexF64}` as appropriate.
`lu!` for `UmfpackLU` requires at least Julia 1.5.
**Examples**
```julia-repl
julia> A = sparse(Float64[1.0 2.0; 0.0 3.0]);

julia> F = lu(A);

julia> B = sparse(Float64[1.0 1.0; 0.0 1.0]);

julia> lu!(F, B);

julia> F \ ones(2)
2-element Vector{Float64}:
 0.0
 1.0
```
```julia
lu!(A, pivot = RowMaximum(); check = true, allowsingular = false) -> LU
```
`lu!` is the same as [`lu`](#LinearAlgebra.lu), but saves space by overwriting the input `A`, instead of creating a copy. An [`InexactError`](../../base/base/#Core.InexactError) exception is thrown if the factorization produces a number not representable by the element type of `A`, e.g. for integer types.
The `allowsingular` keyword argument was added in Julia 1.11.
**Examples**
```julia-repl
julia> A = [4. 3.; 6. 3.]
2×2 Matrix{Float64}:
 4.0  3.0
 6.0  3.0

julia> F = lu!(A)
LU{Float64, Matrix{Float64}, Vector{Int64}}
L factor:
2×2 Matrix{Float64}:
 1.0       0.0
 0.666667  1.0
U factor:
2×2 Matrix{Float64}:
 6.0  3.0
 0.0  1.0

julia> iA = [4 3; 6 3]
2×2 Matrix{Int64}:
 4  3
 6  3

julia> lu!(iA)
ERROR: InexactError: Int64(0.6666666666666666)
Stacktrace:
[...]
```


## [Standard functions](#Standard-functions)
```julia
Cholesky <: Factorization
```
Matrix factorization type of the Cholesky factorization of a dense symmetric/Hermitian positive definite matrix `A`. This is the return type of [`cholesky`](#LinearAlgebra.cholesky), the corresponding matrix factorization function.
The triangular Cholesky factor can be obtained from the factorization `F::Cholesky` via `F.L` and `F.U`, where `A ≈ F.U' * F.U ≈ F.L * F.L'`.
The following functions are available for `Cholesky` objects: [`size`](../../base/arrays/#Base.size), [`\`](../../base/math/#Base.:\\-Tuple%7BAny,%20Any%7D), [`inv`](../../base/math/#Base.inv-Tuple%7BNumber%7D), [`det`](#LinearAlgebra.det), [`logdet`](#LinearAlgebra.logdet) and [`isposdef`](#LinearAlgebra.isposdef).
Iterating the decomposition produces the components `L` and `U`.
**Examples**
```julia-repl
julia> A = [4. 12. -16.; 12. 37. -43.; -16. -43. 98.]
3×3 Matrix{Float64}:
   4.0   12.0  -16.0
  12.0   37.0  -43.0
 -16.0  -43.0   98.0

julia> C = cholesky(A)
Cholesky{Float64, Matrix{Float64}}
U factor:
3×3 UpperTriangular{Float64, Matrix{Float64}}:
 2.0  6.0  -8.0
  ⋅   1.0   5.0
  ⋅    ⋅    3.0

julia> C.U
3×3 UpperTriangular{Float64, Matrix{Float64}}:
 2.0  6.0  -8.0
  ⋅   1.0   5.0
  ⋅    ⋅    3.0

julia> C.L
3×3 LowerTriangular{Float64, Matrix{Float64}}:
  2.0   ⋅    ⋅
  6.0  1.0   ⋅
 -8.0  5.0  3.0

julia> C.L * C.U == A
true

julia> l, u = C; # destructuring via iteration

julia> l == C.L && u == C.U
true
```
```julia
CholeskyPivoted
```


## [Standard functions](#Standard-functions)
Matrix factorization type of the pivoted Cholesky factorization of a dense symmetric/Hermitian positive semi-definite matrix `A`. This is the return type of [`cholesky(_, ::RowMaximum)`](#LinearAlgebra.cholesky), the corresponding matrix factorization function.
The triangular Cholesky factor can be obtained from the factorization `F::CholeskyPivoted` via `F.L` and `F.U`, and the permutation via `F.p`, where `A[F.p, F.p] ≈ Ur' * Ur ≈ Lr * Lr'` with `Ur = F.U[1:F.rank, :]` and `Lr = F.L[:, 1:F.rank]`, or alternatively `A ≈ Up' * Up ≈ Lp * Lp'` with `Up = F.U[1:F.rank, invperm(F.p)]` and `Lp = F.L[invperm(F.p), 1:F.rank]`.
The following functions are available for `CholeskyPivoted` objects: [`size`](../../base/arrays/#Base.size), [`\`](../../base/math/#Base.:\\-Tuple%7BAny,%20Any%7D), [`inv`](../../base/math/#Base.inv-Tuple%7BNumber%7D), [`det`](#LinearAlgebra.det), and [`rank`](#LinearAlgebra.rank).
Iterating the decomposition produces the components `L` and `U`.
**Examples**
```julia-repl
julia> X = [1.0, 2.0, 3.0, 4.0];

julia> A = X * X';

julia> C = cholesky(A, RowMaximum(), check = false)
CholeskyPivoted{Float64, Matrix{Float64}, Vector{Int64}}
U factor with rank 1:
4×4 UpperTriangular{Float64, Matrix{Float64}}:
 4.0  2.0  3.0  1.0
  ⋅   0.0  6.0  2.0
  ⋅    ⋅   9.0  3.0
  ⋅    ⋅    ⋅   1.0
permutation:
4-element Vector{Int64}:
 4
 2
 3
 1

julia> C.U[1:C.rank, :]' * C.U[1:C.rank, :] ≈ A[C.p, C.p]
true

julia> l, u = C; # destructuring via iteration

julia> l == C.L && u == C.U
true
```


## [Standard functions](#Standard-functions)
```julia
cholesky(A, NoPivot(); check = true) -> Cholesky
```
Compute the Cholesky factorization of a dense symmetric positive definite matrix `A` and return a [`Cholesky`](#LinearAlgebra.Cholesky) factorization. The matrix `A` can either be a [`Symmetric`](#LinearAlgebra.Symmetric) or [`Hermitian`](#LinearAlgebra.Hermitian) [`AbstractMatrix`](../../base/arrays/#Base.AbstractMatrix) or a *perfectly* symmetric or Hermitian `AbstractMatrix`.
The triangular Cholesky factor can be obtained from the factorization `F` via `F.L` and `F.U`, where `A ≈ F.U' * F.U ≈ F.L * F.L'`.
The following functions are available for `Cholesky` objects: [`size`](../../base/arrays/#Base.size), [`\`](../../base/math/#Base.:\\-Tuple%7BAny,%20Any%7D), [`inv`](../../base/math/#Base.inv-Tuple%7BNumber%7D), [`det`](#LinearAlgebra.det), [`logdet`](#LinearAlgebra.logdet) and [`isposdef`](#LinearAlgebra.isposdef).
If you have a matrix `A` that is slightly non-Hermitian due to roundoff errors in its construction, wrap it in `Hermitian(A)` before passing it to `cholesky` in order to treat it as perfectly Hermitian.
When `check = true`, an error is thrown if the decomposition fails. When `check = false`, responsibility for checking the decomposition's validity (via [`issuccess`](#LinearAlgebra.issuccess)) lies with the user.
**Examples**


## [Standard functions](#Standard-functions)
```julia-repl
julia> A = [4. 12. -16.; 12. 37. -43.; -16. -43. 98.]
3×3 Matrix{Float64}:
   4.0   12.0  -16.0
  12.0   37.0  -43.0
 -16.0  -43.0   98.0

julia> C = cholesky(A)
Cholesky{Float64, Matrix{Float64}}
U factor:
3×3 UpperTriangular{Float64, Matrix{Float64}}:
 2.0  6.0  -8.0
  ⋅   1.0   5.0
  ⋅    ⋅    3.0

julia> C.U
3×3 UpperTriangular{Float64, Matrix{Float64}}:
 2.0  6.0  -8.0
  ⋅   1.0   5.0
  ⋅    ⋅    3.0

julia> C.L
3×3 LowerTriangular{Float64, Matrix{Float64}}:
  2.0   ⋅    ⋅
  6.0  1.0   ⋅
 -8.0  5.0  3.0

julia> C.L * C.U == A
true
```
```julia
cholesky(A, RowMaximum(); tol = 0.0, check = true) -> CholeskyPivoted
```
Compute the pivoted Cholesky factorization of a dense symmetric positive semi-definite matrix `A` and return a [`CholeskyPivoted`](#LinearAlgebra.CholeskyPivoted) factorization. The matrix `A` can either be a [`Symmetric`](#LinearAlgebra.Symmetric) or [`Hermitian`](#LinearAlgebra.Hermitian) [`AbstractMatrix`](../../base/arrays/#Base.AbstractMatrix) or a *perfectly* symmetric or Hermitian `AbstractMatrix`.
The triangular Cholesky factor can be obtained from the factorization `F` via `F.L` and `F.U`, and the permutation via `F.p`, where `A[F.p, F.p] ≈ Ur' * Ur ≈ Lr * Lr'` with `Ur = F.U[1:F.rank, :]` and `Lr = F.L[:, 1:F.rank]`, or alternatively `A ≈ Up' * Up ≈ Lp * Lp'` with `Up = F.U[1:F.rank, invperm(F.p)]` and `Lp = F.L[invperm(F.p), 1:F.rank]`.


## [Standard functions](#Standard-functions)
The following functions are available for `CholeskyPivoted` objects: [`size`](../../base/arrays/#Base.size), [`\`](../../base/math/#Base.:\\-Tuple%7BAny,%20Any%7D), [`inv`](../../base/math/#Base.inv-Tuple%7BNumber%7D), [`det`](#LinearAlgebra.det), and [`rank`](#LinearAlgebra.rank).
The argument `tol` determines the tolerance for determining the rank. For negative values, the tolerance is the machine precision.
If you have a matrix `A` that is slightly non-Hermitian due to roundoff errors in its construction, wrap it in `Hermitian(A)` before passing it to `cholesky` in order to treat it as perfectly Hermitian.
When `check = true`, an error is thrown if the decomposition fails. When `check = false`, responsibility for checking the decomposition's validity (via [`issuccess`](#LinearAlgebra.issuccess)) lies with the user.
**Examples**
```julia-repl
julia> X = [1.0, 2.0, 3.0, 4.0];

julia> A = X * X';

julia> C = cholesky(A, RowMaximum(), check = false)
CholeskyPivoted{Float64, Matrix{Float64}, Vector{Int64}}
U factor with rank 1:
4×4 UpperTriangular{Float64, Matrix{Float64}}:
 4.0  2.0  3.0  1.0
  ⋅   0.0  6.0  2.0
  ⋅    ⋅   9.0  3.0
  ⋅    ⋅    ⋅   1.0
permutation:
4-element Vector{Int64}:
 4
 2
 3
 1

julia> C.U[1:C.rank, :]' * C.U[1:C.rank, :] ≈ A[C.p, C.p]
true

julia> l, u = C; # destructuring via iteration

julia> l == C.L && u == C.U
true
```
```julia
cholesky(A::SparseMatrixCSC; shift = 0.0, check = true, perm = nothing) -> CHOLMOD.Factor
```


## [Standard functions](#Standard-functions)
Compute the Cholesky factorization of a sparse positive definite matrix `A`. `A` must be a [`SparseMatrixCSC`](../SparseArrays/#SparseArrays.SparseMatrixCSC) or a [`Symmetric`](#LinearAlgebra.Symmetric)/[`Hermitian`](#LinearAlgebra.Hermitian) view of a `SparseMatrixCSC`. Note that even if `A` doesn't have the type tag, it must still be symmetric or Hermitian. If `perm` is not given, a fill-reducing permutation is used. `F = cholesky(A)` is most frequently used to solve systems of equations with `F\b`, but also the methods [`diag`](#LinearAlgebra.diag), [`det`](#LinearAlgebra.det), and [`logdet`](#LinearAlgebra.logdet) are defined for `F`. You can also extract individual factors from `F`, using `F.L`. However, since pivoting is on by default, the factorization is internally represented as `A == P'*L*L'*P` with a permutation matrix `P`; using just `L` without accounting for `P` will give incorrect answers. To include the effects of permutation, it's typically preferable to extract "combined" factors like `PtL = F.PtL` (the equivalent of `P'*L`) and `LtP = F.UP` (the equivalent of `L'*P`).
When `check = true`, an error is thrown if the decomposition fails. When `check = false`, responsibility for checking the decomposition's validity (via [`issuccess`](#LinearAlgebra.issuccess)) lies with the user.


## [Standard functions](#Standard-functions)
Setting the optional `shift` keyword argument computes the factorization of `A+shift*I` instead of `A`. If the `perm` argument is provided, it should be a permutation of `1:size(A,1)` giving the ordering to use (instead of CHOLMOD's default AMD ordering).
**Examples**
In the following example, the fill-reducing permutation used is `[3, 2, 1]`. If `perm` is set to `1:3` to enforce no permutation, the number of nonzero elements in the factor is 6.
```julia-repl
julia> A = [2 1 1; 1 2 0; 1 0 2]
3×3 Matrix{Int64}:
 2  1  1
 1  2  0
 1  0  2

julia> C = cholesky(sparse(A))
SparseArrays.CHOLMOD.Factor{Float64, Int64}
type:    LLt
method:  simplicial
maxnnz:  5
nnz:     5
success: true

julia> C.p
3-element Vector{Int64}:
 3
 2
 1

julia> L = sparse(C.L);

julia> Matrix(L)
3×3 Matrix{Float64}:
 1.41421   0.0       0.0
 0.0       1.41421   0.0
 0.707107  0.707107  1.0

julia> L * L' ≈ A[C.p, C.p]
true

julia> P = sparse(1:3, C.p, ones(3))
3×3 SparseMatrixCSC{Float64, Int64} with 3 stored entries:
  ⋅    ⋅   1.0
  ⋅   1.0   ⋅
 1.0   ⋅    ⋅

julia> P' * L * L' * P ≈ A
true

julia> C = cholesky(sparse(A), perm=1:3)
SparseArrays.CHOLMOD.Factor{Float64, Int64}
type:    LLt
method:  simplicial
maxnnz:  6
nnz:     6
success: true

julia> L = sparse(C.L);

julia> Matrix(L)
3×3 Matrix{Float64}:
 1.41421    0.0       0.0
 0.707107   1.22474   0.0
 0.707107  -0.408248  1.1547

julia> L * L' ≈ A
true
```


## [Standard functions](#Standard-functions)
This method uses the CHOLMOD<sup>[[ACM887\]](#footnote-ACM887)[[DavisHager2009\]](#footnote-DavisHager2009)</sup> library from [SuiteSparse](https://github.com/DrTimothyAldenDavis/SuiteSparse). CHOLMOD only supports real or complex types in single or double precision. Input matrices not of those element types will be converted to these types as appropriate.
Many other functions from CHOLMOD are wrapped but not exported from the `Base.SparseArrays.CHOLMOD` module.
```julia
cholesky!(A::AbstractMatrix, NoPivot(); check = true) -> Cholesky
```
The same as [`cholesky`](#LinearAlgebra.cholesky), but saves space by overwriting the input `A`, instead of creating a copy. An [`InexactError`](../../base/base/#Core.InexactError) exception is thrown if the factorization produces a number not representable by the element type of `A`, e.g. for integer types.
**Examples**
```julia-repl
julia> A = [1 2; 2 50]
2×2 Matrix{Int64}:
 1   2
 2  50

julia> cholesky!(A)
ERROR: InexactError: Int64(6.782329983125268)
Stacktrace:
[...]
```
```julia
cholesky!(A::AbstractMatrix, RowMaximum(); tol = 0.0, check = true) -> CholeskyPivoted
```
The same as [`cholesky`](#LinearAlgebra.cholesky), but saves space by overwriting the input `A`, instead of creating a copy. An [`InexactError`](../../base/base/#Core.InexactError) exception is thrown if the factorization produces a number not representable by the element type of `A`, e.g. for integer types.
```julia
cholesky!(F::CHOLMOD.Factor, A::SparseMatrixCSC; shift = 0.0, check = true) -> CHOLMOD.Factor
```


## [Standard functions](#Standard-functions)
Compute the Cholesky ($LL'$) factorization of `A`, reusing the symbolic factorization `F`. `A` must be a [`SparseMatrixCSC`](../SparseArrays/#SparseArrays.SparseMatrixCSC) or a [`Symmetric`](#LinearAlgebra.Symmetric)/ [`Hermitian`](#LinearAlgebra.Hermitian) view of a `SparseMatrixCSC`. Note that even if `A` doesn't have the type tag, it must still be symmetric or Hermitian.
See also [`cholesky`](#LinearAlgebra.cholesky).
This method uses the CHOLMOD library from SuiteSparse, which only supports real or complex types in single or double precision. Input matrices not of those element types will be converted to these types as appropriate.
```julia
lowrankupdate(C::Cholesky, v::AbstractVector) -> CC::Cholesky
```
Update a Cholesky factorization `C` with the vector `v`. If `A = C.U'C.U` then `CC = cholesky(C.U'C.U + v*v')` but the computation of `CC` only uses `O(n^2)` operations.
```julia
lowrankupdate(F::CHOLMOD.Factor, C::AbstractArray) -> FF::CHOLMOD.Factor
```
Get an `LDLt` Factorization of `A + C*C'` given an `LDLt` or `LLt` factorization `F` of `A`.
The returned factor is always an `LDLt` factorization.
See also [`lowrankupdate!`](#LinearAlgebra.lowrankupdate!), [`lowrankdowndate`](#LinearAlgebra.lowrankdowndate), [`lowrankdowndate!`](#LinearAlgebra.lowrankdowndate!).
```julia
lowrankdowndate(C::Cholesky, v::AbstractVector) -> CC::Cholesky
```
Downdate a Cholesky factorization `C` with the vector `v`. If `A = C.U'C.U` then `CC = cholesky(C.U'C.U - v*v')` but the computation of `CC` only uses `O(n^2)` operations.


## [Standard functions](#Standard-functions)
```julia
lowrankdowndate(F::CHOLMOD.Factor, C::AbstractArray) -> FF::CHOLMOD.Factor
```
Get an `LDLt` Factorization of `A + C*C'` given an `LDLt` or `LLt` factorization `F` of `A`.
The returned factor is always an `LDLt` factorization.
See also [`lowrankdowndate!`](#LinearAlgebra.lowrankdowndate!), [`lowrankupdate`](#LinearAlgebra.lowrankupdate), [`lowrankupdate!`](#LinearAlgebra.lowrankupdate!).
```julia
lowrankupdate!(C::Cholesky, v::AbstractVector) -> CC::Cholesky
```
Update a Cholesky factorization `C` with the vector `v`. If `A = C.U'C.U` then `CC = cholesky(C.U'C.U + v*v')` but the computation of `CC` only uses `O(n^2)` operations. The input factorization `C` is updated in place such that on exit `C == CC`. The vector `v` is destroyed during the computation.
```julia
lowrankupdate!(F::CHOLMOD.Factor, C::AbstractArray)
```
Update an `LDLt` or `LLt` Factorization `F` of `A` to a factorization of `A + C*C'`.
`LLt` factorizations are converted to `LDLt`.
See also [`lowrankupdate`](#LinearAlgebra.lowrankupdate), [`lowrankdowndate`](#LinearAlgebra.lowrankdowndate), [`lowrankdowndate!`](#LinearAlgebra.lowrankdowndate!).
```julia
lowrankdowndate!(C::Cholesky, v::AbstractVector) -> CC::Cholesky
```
Downdate a Cholesky factorization `C` with the vector `v`. If `A = C.U'C.U` then `CC = cholesky(C.U'C.U - v*v')` but the computation of `CC` only uses `O(n^2)` operations. The input factorization `C` is updated in place such that on exit `C == CC`. The vector `v` is destroyed during the computation.


## [Standard functions](#Standard-functions)
```julia
lowrankdowndate!(F::CHOLMOD.Factor, C::AbstractArray)
```
Update an `LDLt` or `LLt` Factorization `F` of `A` to a factorization of `A - C*C'`.
`LLt` factorizations are converted to `LDLt`.
See also [`lowrankdowndate`](#LinearAlgebra.lowrankdowndate), [`lowrankupdate`](#LinearAlgebra.lowrankupdate), [`lowrankupdate!`](#LinearAlgebra.lowrankupdate!).
```julia
LDLt <: Factorization
```
Matrix factorization type of the `LDLt` factorization of a real [`SymTridiagonal`](#LinearAlgebra.SymTridiagonal) matrix `S` such that `S = L*Diagonal(d)*L'`, where `L` is a [`UnitLowerTriangular`](#LinearAlgebra.UnitLowerTriangular) matrix and `d` is a vector. The main use of an `LDLt` factorization `F = ldlt(S)` is to solve the linear system of equations `Sx = b` with `F\b`. This is the return type of [`ldlt`](#LinearAlgebra.ldlt), the corresponding matrix factorization function.
The individual components of the factorization `F::LDLt` can be accessed via `getproperty`:
| Component | Description                                 |
|:---------:|:--------------------------------------------|
|   `F.L`   | `L` (unit lower triangular) part of `LDLt`  |
|   `F.D`   | `D` (diagonal) part of `LDLt`               |
|  `F.Lt`   | `Lt` (unit upper triangular) part of `LDLt` |
|   `F.d`   | diagonal values of `D` as a `Vector`        |
**Examples**


## [Standard functions](#Standard-functions)
```julia-repl
julia> S = SymTridiagonal([3., 4., 5.], [1., 2.])
3×3 SymTridiagonal{Float64, Vector{Float64}}:
 3.0  1.0   ⋅
 1.0  4.0  2.0
  ⋅   2.0  5.0

julia> F = ldlt(S)
LDLt{Float64, SymTridiagonal{Float64, Vector{Float64}}}
L factor:
3×3 UnitLowerTriangular{Float64, SymTridiagonal{Float64, Vector{Float64}}}:
 1.0        ⋅         ⋅
 0.333333  1.0        ⋅
 0.0       0.545455  1.0
D factor:
3×3 Diagonal{Float64, Vector{Float64}}:
 3.0   ⋅        ⋅
  ⋅   3.66667   ⋅
  ⋅    ⋅       3.90909
```
```julia
ldlt(S::SymTridiagonal) -> LDLt
```
Compute an `LDLt` (i.e., $LDL^T$) factorization of the real symmetric tridiagonal matrix `S` such that `S = L*Diagonal(d)*L'` where `L` is a unit lower triangular matrix and `d` is a vector. The main use of an `LDLt` factorization `F = ldlt(S)` is to solve the linear system of equations `Sx = b` with `F\b`.
See also [`bunchkaufman`](#LinearAlgebra.bunchkaufman) for a similar, but pivoted, factorization of arbitrary symmetric or Hermitian matrices.
**Examples**
```julia-repl
julia> S = SymTridiagonal([3., 4., 5.], [1., 2.])
3×3 SymTridiagonal{Float64, Vector{Float64}}:
 3.0  1.0   ⋅
 1.0  4.0  2.0
  ⋅   2.0  5.0

julia> ldltS = ldlt(S);

julia> b = [6., 7., 8.];

julia> ldltS \ b
3-element Vector{Float64}:
 1.7906976744186047
 0.627906976744186
 1.3488372093023255

julia> S \ b
3-element Vector{Float64}:
 1.7906976744186047
 0.627906976744186
 1.3488372093023255
```
```julia
ldlt(A::SparseMatrixCSC; shift = 0.0, check = true, perm=nothing) -> CHOLMOD.Factor
```


## [Standard functions](#Standard-functions)
Compute the $LDL'$ factorization of a sparse matrix `A`. `A` must be a [`SparseMatrixCSC`](../SparseArrays/#SparseArrays.SparseMatrixCSC) or a [`Symmetric`](#LinearAlgebra.Symmetric)/[`Hermitian`](#LinearAlgebra.Hermitian) view of a `SparseMatrixCSC`. Note that even if `A` doesn't have the type tag, it must still be symmetric or Hermitian. A fill-reducing permutation is used. `F = ldlt(A)` is most frequently used to solve systems of equations `A*x = b` with `F\b`. The returned factorization object `F` also supports the methods [`diag`](#LinearAlgebra.diag), [`det`](#LinearAlgebra.det), [`logdet`](#LinearAlgebra.logdet), and [`inv`](../../base/math/#Base.inv-Tuple%7BNumber%7D). You can extract individual factors from `F` using `F.L`. However, since pivoting is on by default, the factorization is internally represented as `A == P'*L*D*L'*P` with a permutation matrix `P`; using just `L` without accounting for `P` will give incorrect answers. To include the effects of permutation, it is typically preferable to extract "combined" factors like `PtL = F.PtL` (the equivalent of `P'*L`) and `LtP = F.UP` (the equivalent of `L'*P`). The complete list of supported factors is `:L, :PtL, :D, :UP, :U, :LD, :DU, :PtLD, :DUP`.
When `check = true`, an error is thrown if the decomposition fails. When `check = false`, responsibility for checking the decomposition's validity (via [`issuccess`](#LinearAlgebra.issuccess)) lies with the user.


## [Standard functions](#Standard-functions)
Setting the optional `shift` keyword argument computes the factorization of `A+shift*I` instead of `A`. If the `perm` argument is provided, it should be a permutation of `1:size(A,1)` giving the ordering to use (instead of CHOLMOD's default AMD ordering).
This method uses the CHOLMOD<sup>[[ACM887\]](#footnote-ACM887)[[DavisHager2009\]](#footnote-DavisHager2009)</sup> library from [SuiteSparse](https://github.com/DrTimothyAldenDavis/SuiteSparse). CHOLMOD only supports real or complex types in single or double precision. Input matrices not of those element types will be converted to these types as appropriate.
Many other functions from CHOLMOD are wrapped but not exported from the `Base.SparseArrays.CHOLMOD` module.
```julia
ldlt!(S::SymTridiagonal) -> LDLt
```
Same as [`ldlt`](#LinearAlgebra.ldlt), but saves space by overwriting the input `S`, instead of creating a copy.
**Examples**
```julia-repl
julia> S = SymTridiagonal([3., 4., 5.], [1., 2.])
3×3 SymTridiagonal{Float64, Vector{Float64}}:
 3.0  1.0   ⋅
 1.0  4.0  2.0
  ⋅   2.0  5.0

julia> ldltS = ldlt!(S);

julia> ldltS === S
false

julia> S
3×3 SymTridiagonal{Float64, Vector{Float64}}:
 3.0       0.333333   ⋅
 0.333333  3.66667   0.545455
  ⋅        0.545455  3.90909
```
```julia
ldlt!(F::CHOLMOD.Factor, A::SparseMatrixCSC; shift = 0.0, check = true) -> CHOLMOD.Factor
```


## [Standard functions](#Standard-functions)
Compute the $LDL'$ factorization of `A`, reusing the symbolic factorization `F`. `A` must be a [`SparseMatrixCSC`](../SparseArrays/#SparseArrays.SparseMatrixCSC) or a [`Symmetric`](#LinearAlgebra.Symmetric)/[`Hermitian`](#LinearAlgebra.Hermitian) view of a `SparseMatrixCSC`. Note that even if `A` doesn't have the type tag, it must still be symmetric or Hermitian.
See also [`ldlt`](#LinearAlgebra.ldlt).
This method uses the CHOLMOD library from [SuiteSparse](https://github.com/DrTimothyAldenDavis/SuiteSparse), which only supports real or complex types in single or double precision. Input matrices not of those element types will be converted to these types as appropriate.
```julia
QR <: Factorization
```
A QR matrix factorization stored in a packed format, typically obtained from [`qr`](#LinearAlgebra.qr). If $A$ is an `m`×`n` matrix, then
\\\[A = Q R\\\]
where $Q$ is an orthogonal/unitary matrix and $R$ is upper triangular. The matrix $Q$ is stored as a sequence of Householder reflectors $v_i$ and coefficients $\\tau_i$ where:
\\\[Q = \\prod\_{i=1}^{\\min(m,n)} (I - \\tau_i v_i v_i^T).\\\]
Iterating the decomposition produces the components `Q` and `R`.
The object has two fields:
-   `factors` is an `m`×`n` matrix.
    -   The upper triangular part contains the elements of $R$, that is `R = triu(F.factors)` for a `QR` object `F`.
    -   The subdiagonal part contains the reflectors $v_i$ stored in a packed format where $v_i$ is the $i$th column of the matrix `V = I + tril(F.factors, -1)`.


## [Standard functions](#Standard-functions)
-   `τ` is a vector of length `min(m,n)` containing the coefficients $au_i$.
```julia
QRCompactWY <: Factorization
```
A QR matrix factorization stored in a compact blocked format, typically obtained from [`qr`](#LinearAlgebra.qr). If $A$ is an `m`×`n` matrix, then
\\\[A = Q R\\\]
where $Q$ is an orthogonal/unitary matrix and $R$ is upper triangular. It is similar to the [`QR`](#LinearAlgebra.QR) format except that the orthogonal/unitary matrix $Q$ is stored in *Compact WY* format <sup>[[Schreiber1989\]](#footnote-Schreiber1989)</sup>. For the block size $n_b$, it is stored as a `m`×`n` lower trapezoidal matrix $V$ and a matrix $T = (T_1 \\; T_2 \\; ... \\; T\_{b-1} \\; T_b')$ composed of $b = \\lceil \\min(m,n) / n_b \\rceil$ upper triangular matrices $T_j$ of size $n_b$×$n_b$ ($j = 1, ..., b-1$) and an upper trapezoidal $n_b$×$\\min(m,n) - (b-1) n_b$ matrix $T_b'$ ($j=b$) whose upper square part denoted with $T_b$ satisfying
\\\[Q = \\prod\_{i=1}^{\\min(m,n)} (I - \\tau_i v_i v_i^T) = \\prod\_{j=1}^{b} (I - V_j T_j V_j^T)\\\]
such that $v_i$ is the $i$th column of $V$, $\\tau_i$ is the $i$th element of `[diag(T_1); diag(T_2); …; diag(T_b)]`, and $(V_1 \\; V_2 \\; ... \\; V_b)$ is the left `m`×`min(m, n)` block of $V$. When constructed using [`qr`](#LinearAlgebra.qr), the block size is given by $n_b = \\min(m, n, 36)$.
Iterating the decomposition produces the components `Q` and `R`.
The object has two fields:
-   `factors`, as in the [`QR`](#LinearAlgebra.QR) type, is an `m`×`n` matrix.


## [Standard functions](#Standard-functions)
    -   The upper triangular part contains the elements of $R$, that is `R = triu(F.factors)` for a `QR` object `F`.
    -   The subdiagonal part contains the reflectors $v_i$ stored in a packed format such that `V = I + tril(F.factors, -1)`.
-   `T` is a $n_b$-by-$\\min(m,n)$ matrix as described above. The subdiagonal elements for each triangular matrix $T_j$ are ignored.
This format should not to be confused with the older *WY* representation <sup>[[Bischof1987\]](#footnote-Bischof1987)</sup>.
```julia
QRPivoted <: Factorization
```
A QR matrix factorization with column pivoting in a packed format, typically obtained from [`qr`](#LinearAlgebra.qr). If $A$ is an `m`×`n` matrix, then
\\\[A P = Q R\\\]
where $P$ is a permutation matrix, $Q$ is an orthogonal/unitary matrix and $R$ is upper triangular. The matrix $Q$ is stored as a sequence of Householder reflectors:
\\\[Q = \\prod\_{i=1}^{\\min(m,n)} (I - \\tau_i v_i v_i^T).\\\]
Iterating the decomposition produces the components `Q`, `R`, and `p`.
The object has three fields:
-   `factors` is an `m`×`n` matrix.
    -   The upper triangular part contains the elements of $R$, that is `R = triu(F.factors)` for a `QR` object `F`.
    -   The subdiagonal part contains the reflectors $v_i$ stored in a packed format where $v_i$ is the $i$th column of the matrix `V = I + tril(F.factors, -1)`.
-   `τ` is a vector of length `min(m,n)` containing the coefficients $au_i$.
-   `jpvt` is an integer vector of length `n` corresponding to the permutation $P$.


## [Standard functions](#Standard-functions)
```julia
qr(A::SparseMatrixCSC; tol=_default_tol(A), ordering=ORDERING_DEFAULT) -> QRSparse
```
Compute the `QR` factorization of a sparse matrix `A`. Fill-reducing row and column permutations are used such that `F.R = F.Q'*A[F.prow,F.pcol]`. The main application of this type is to solve least squares or underdetermined problems with [`\`](../../base/math/#Base.:\\-Tuple%7BAny,%20Any%7D). The function calls the C library SPQR<sup>[[ACM933\]](#footnote-ACM933)</sup>.
`qr(A::SparseMatrixCSC)` uses the SPQR library that is part of [SuiteSparse](https://github.com/DrTimothyAldenDavis/SuiteSparse). As this library only supports sparse matrices with [`Float64`](../../base/numbers/#Core.Float64) or `ComplexF64` elements, as of Julia v1.4 `qr` converts `A` into a copy that is of type `SparseMatrixCSC{Float64}` or `SparseMatrixCSC{ComplexF64}` as appropriate.
**Examples**
```julia-repl
julia> A = sparse([1,2,3,4], [1,1,2,2], [1.0,1.0,1.0,1.0])
4×2 SparseMatrixCSC{Float64, Int64} with 4 stored entries:
 1.0   ⋅
 1.0   ⋅
  ⋅   1.0
  ⋅   1.0

julia> qr(A)
SparseArrays.SPQR.QRSparse{Float64, Int64}
Q factor:
4×4 SparseArrays.SPQR.QRSparseQ{Float64, Int64}
R factor:
2×2 SparseMatrixCSC{Float64, Int64} with 2 stored entries:
 -1.41421    ⋅
   ⋅       -1.41421
Row permutation:
4-element Vector{Int64}:
 1
 3
 4
 2
Column permutation:
2-element Vector{Int64}:
 1
 2
```
```julia
qr(A, pivot = NoPivot(); blocksize) -> F
```


## [Standard functions](#Standard-functions)
Compute the QR factorization of the matrix `A`: an orthogonal (or unitary if `A` is complex-valued) matrix `Q`, and an upper triangular matrix `R` such that
\\\[A = Q R\\\]
The returned object `F` stores the factorization in a packed format:
-   if `pivot == ColumnNorm()` then `F` is a [`QRPivoted`](#LinearAlgebra.QRPivoted) object,
-   otherwise if the element type of `A` is a BLAS type ([`Float32`](../../base/numbers/#Core.Float32), [`Float64`](../../base/numbers/#Core.Float64), `ComplexF32` or `ComplexF64`), then `F` is a [`QRCompactWY`](#LinearAlgebra.QRCompactWY) object,
-   otherwise `F` is a [`QR`](#LinearAlgebra.QR) object.
The individual components of the decomposition `F` can be retrieved via property accessors:
-   `F.Q`: the orthogonal/unitary matrix `Q`
-   `F.R`: the upper triangular matrix `R`
-   `F.p`: the permutation vector of the pivot ([`QRPivoted`](#LinearAlgebra.QRPivoted) only)
-   `F.P`: the permutation matrix of the pivot ([`QRPivoted`](#LinearAlgebra.QRPivoted) only)
Each reference to the upper triangular factor via `F.R` allocates a new array. It is therefore advisable to cache that array, say, by `R = F.R` and continue working with `R`.
Iterating the decomposition produces the components `Q`, `R`, and if extant `p`.


## [Standard functions](#Standard-functions)
The following functions are available for the `QR` objects: [`inv`](../../base/math/#Base.inv-Tuple%7BNumber%7D), [`size`](../../base/arrays/#Base.size), and [`\`](../../base/math/#Base.:\\-Tuple%7BAny,%20Any%7D). When `A` is rectangular, `\` will return a least squares solution and if the solution is not unique, the one with smallest norm is returned. When `A` is not full rank, factorization with (column) pivoting is required to obtain a minimum norm solution.
Multiplication with respect to either full/square or non-full/square `Q` is allowed, i.e. both `F.Q*F.R` and `F.Q*A` are supported. A `Q` matrix can be converted into a regular matrix with [`Matrix`](../../base/arrays/#Base.Matrix). This operation returns the "thin" Q factor, i.e., if `A` is `m`×`n` with `m>=n`, then `Matrix(F.Q)` yields an `m`×`n` matrix with orthonormal columns. To retrieve the "full" Q factor, an `m`×`m` orthogonal matrix, use `F.Q*I` or `collect(F.Q)`. If `m<=n`, then `Matrix(F.Q)` yields an `m`×`m` orthogonal matrix.
The block size for QR decomposition can be specified by keyword argument `blocksize :: Integer` when `pivot == NoPivot()` and `A isa StridedMatrix{<:BlasFloat}`. It is ignored when `blocksize > minimum(size(A))`. See [`QRCompactWY`](#LinearAlgebra.QRCompactWY).
The `blocksize` keyword argument requires Julia 1.4 or later.
**Examples**


## [Standard functions](#Standard-functions)
```julia-repl
julia> A = [3.0 -6.0; 4.0 -8.0; 0.0 1.0]
3×2 Matrix{Float64}:
 3.0  -6.0
 4.0  -8.0
 0.0   1.0

julia> F = qr(A)
LinearAlgebra.QRCompactWY{Float64, Matrix{Float64}, Matrix{Float64}}
Q factor: 3×3 LinearAlgebra.QRCompactWYQ{Float64, Matrix{Float64}, Matrix{Float64}}
R factor:
2×2 Matrix{Float64}:
 -5.0  10.0
  0.0  -1.0

julia> F.Q * F.R == A
true
```
`qr` returns multiple types because LAPACK uses several representations that minimize the memory storage requirements of products of Householder elementary reflectors, so that the `Q` and `R` matrices can be stored compactly rather as two separate dense matrices.
```julia
qr!(A, pivot = NoPivot(); blocksize)
```
`qr!` is the same as [`qr`](#LinearAlgebra.qr) when `A` is a subtype of [`AbstractMatrix`](../../base/arrays/#Base.AbstractMatrix), but saves space by overwriting the input `A`, instead of creating a copy. An [`InexactError`](../../base/base/#Core.InexactError) exception is thrown if the factorization produces a number not representable by the element type of `A`, e.g. for integer types.
The `blocksize` keyword argument requires Julia 1.4 or later.
**Examples**


## [Standard functions](#Standard-functions)
```julia-repl
julia> a = [1. 2.; 3. 4.]
2×2 Matrix{Float64}:
 1.0  2.0
 3.0  4.0

julia> qr!(a)
LinearAlgebra.QRCompactWY{Float64, Matrix{Float64}, Matrix{Float64}}
Q factor: 2×2 LinearAlgebra.QRCompactWYQ{Float64, Matrix{Float64}, Matrix{Float64}}
R factor:
2×2 Matrix{Float64}:
 -3.16228  -4.42719
  0.0      -0.632456

julia> a = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> qr!(a)
ERROR: InexactError: Int64(3.1622776601683795)
Stacktrace:
[...]
```
```julia
LQ <: Factorization
```
Matrix factorization type of the `LQ` factorization of a matrix `A`. The `LQ` decomposition is the [`QR`](#LinearAlgebra.QR) decomposition of `transpose(A)`. This is the return type of [`lq`](#LinearAlgebra.lq), the corresponding matrix factorization function.
If `S::LQ` is the factorization object, the lower triangular component can be obtained via `S.L`, and the orthogonal/unitary component via `S.Q`, such that `A ≈ S.L*S.Q`.
Iterating the decomposition produces the components `S.L` and `S.Q`.
**Examples**
```julia-repl
julia> A = [5. 7.; -2. -4.]
2×2 Matrix{Float64}:
  5.0   7.0
 -2.0  -4.0

julia> S = lq(A)
LQ{Float64, Matrix{Float64}, Vector{Float64}}
L factor:
2×2 Matrix{Float64}:
 -8.60233   0.0
  4.41741  -0.697486
Q factor: 2×2 LinearAlgebra.LQPackedQ{Float64, Matrix{Float64}, Vector{Float64}}

julia> S.L * S.Q
2×2 Matrix{Float64}:
  5.0   7.0
 -2.0  -4.0

julia> l, q = S; # destructuring via iteration

julia> l == S.L &&  q == S.Q
true
```
```julia
lq(A) -> S::LQ
```


## [Standard functions](#Standard-functions)
Compute the LQ decomposition of `A`. The decomposition's lower triangular component can be obtained from the [`LQ`](#LinearAlgebra.LQ) object `S` via `S.L`, and the orthogonal/unitary component via `S.Q`, such that `A ≈ S.L*S.Q`.
Iterating the decomposition produces the components `S.L` and `S.Q`.
The LQ decomposition is the QR decomposition of `transpose(A)`, and it is useful in order to compute the minimum-norm solution `lq(A) \ b` to an underdetermined system of equations (`A` has more columns than rows, but has full row rank).
**Examples**
```julia-repl
julia> A = [5. 7.; -2. -4.]
2×2 Matrix{Float64}:
  5.0   7.0
 -2.0  -4.0

julia> S = lq(A)
LQ{Float64, Matrix{Float64}, Vector{Float64}}
L factor:
2×2 Matrix{Float64}:
 -8.60233   0.0
  4.41741  -0.697486
Q factor: 2×2 LinearAlgebra.LQPackedQ{Float64, Matrix{Float64}, Vector{Float64}}

julia> S.L * S.Q
2×2 Matrix{Float64}:
  5.0   7.0
 -2.0  -4.0

julia> l, q = S; # destructuring via iteration

julia> l == S.L &&  q == S.Q
true
```
```julia
lq!(A) -> LQ
```
Compute the [`LQ`](#LinearAlgebra.LQ) factorization of `A`, using the input matrix as a workspace. See also [`lq`](#LinearAlgebra.lq).
```julia
BunchKaufman <: Factorization
```


## [Standard functions](#Standard-functions)
Matrix factorization type of the Bunch-Kaufman factorization of a symmetric or Hermitian matrix `A` as `P'UDU'P` or `P'LDL'P`, depending on whether the upper (the default) or the lower triangle is stored in `A`. If `A` is complex symmetric then `U'` and `L'` denote the unconjugated transposes, i.e. `transpose(U)` and `transpose(L)`, respectively. This is the return type of [`bunchkaufman`](#LinearAlgebra.bunchkaufman), the corresponding matrix factorization function.
If `S::BunchKaufman` is the factorization object, the components can be obtained via `S.D`, `S.U` or `S.L` as appropriate given `S.uplo`, and `S.p`.
Iterating the decomposition produces the components `S.D`, `S.U` or `S.L` as appropriate given `S.uplo`, and `S.p`.
**Examples**


## [Standard functions](#Standard-functions)
```julia-repl
julia> A = Float64.([1 2; 2 3])
2×2 Matrix{Float64}:
 1.0  2.0
 2.0  3.0

julia> S = bunchkaufman(A) # A gets wrapped internally by Symmetric(A)
BunchKaufman{Float64, Matrix{Float64}, Vector{Int64}}
D factor:
2×2 Tridiagonal{Float64, Vector{Float64}}:
 -0.333333  0.0
  0.0       3.0
U factor:
2×2 UnitUpperTriangular{Float64, Matrix{Float64}}:
 1.0  0.666667
  ⋅   1.0
permutation:
2-element Vector{Int64}:
 1
 2

julia> d, u, p = S; # destructuring via iteration

julia> d == S.D && u == S.U && p == S.p
true

julia> S = bunchkaufman(Symmetric(A, :L))
BunchKaufman{Float64, Matrix{Float64}, Vector{Int64}}
D factor:
2×2 Tridiagonal{Float64, Vector{Float64}}:
 3.0   0.0
 0.0  -0.333333
L factor:
2×2 UnitLowerTriangular{Float64, Matrix{Float64}}:
 1.0        ⋅
 0.666667  1.0
permutation:
2-element Vector{Int64}:
 2
 1
```
```julia
bunchkaufman(A, rook::Bool=false; check = true) -> S::BunchKaufman
```
Compute the Bunch-Kaufman <sup>[[Bunch1977\]](#footnote-Bunch1977)</sup> factorization of a symmetric or Hermitian matrix `A` as `P'*U*D*U'*P` or `P'*L*D*L'*P`, depending on which triangle is stored in `A`, and return a [`BunchKaufman`](#LinearAlgebra.BunchKaufman) object. Note that if `A` is complex symmetric then `U'` and `L'` denote the unconjugated transposes, i.e. `transpose(U)` and `transpose(L)`.
Iterating the decomposition produces the components `S.D`, `S.U` or `S.L` as appropriate given `S.uplo`, and `S.p`.
If `rook` is `true`, rook pivoting is used. If `rook` is false, rook pivoting is not used.


## [Standard functions](#Standard-functions)
When `check = true`, an error is thrown if the decomposition fails. When `check = false`, responsibility for checking the decomposition's validity (via [`issuccess`](#LinearAlgebra.issuccess)) lies with the user.
The following functions are available for `BunchKaufman` objects: [`size`](../../base/arrays/#Base.size), `\`, [`inv`](../../base/math/#Base.inv-Tuple%7BNumber%7D), [`issymmetric`](#LinearAlgebra.issymmetric), [`ishermitian`](#LinearAlgebra.ishermitian), [`getindex`](../../base/collections/#Base.getindex).
**Examples**
```julia-repl
julia> A = Float64.([1 2; 2 3])
2×2 Matrix{Float64}:
 1.0  2.0
 2.0  3.0

julia> S = bunchkaufman(A) # A gets wrapped internally by Symmetric(A)
BunchKaufman{Float64, Matrix{Float64}, Vector{Int64}}
D factor:
2×2 Tridiagonal{Float64, Vector{Float64}}:
 -0.333333  0.0
  0.0       3.0
U factor:
2×2 UnitUpperTriangular{Float64, Matrix{Float64}}:
 1.0  0.666667
  ⋅   1.0
permutation:
2-element Vector{Int64}:
 1
 2

julia> d, u, p = S; # destructuring via iteration

julia> d == S.D && u == S.U && p == S.p
true

julia> S.U*S.D*S.U' - S.P*A*S.P'
2×2 Matrix{Float64}:
 0.0  0.0
 0.0  0.0

julia> S = bunchkaufman(Symmetric(A, :L))
BunchKaufman{Float64, Matrix{Float64}, Vector{Int64}}
D factor:
2×2 Tridiagonal{Float64, Vector{Float64}}:
 3.0   0.0
 0.0  -0.333333
L factor:
2×2 UnitLowerTriangular{Float64, Matrix{Float64}}:
 1.0        ⋅
 0.666667  1.0
permutation:
2-element Vector{Int64}:
 2
 1

julia> S.L*S.D*S.L' - A[S.p, S.p]
2×2 Matrix{Float64}:
 0.0  0.0
 0.0  0.0
```


## [Standard functions](#Standard-functions)
```julia
bunchkaufman!(A, rook::Bool=false; check = true) -> BunchKaufman
```
`bunchkaufman!` is the same as [`bunchkaufman`](#LinearAlgebra.bunchkaufman), but saves space by overwriting the input `A`, instead of creating a copy.
```julia
Eigen <: Factorization
```
Matrix factorization type of the eigenvalue/spectral decomposition of a square matrix `A`. This is the return type of [`eigen`](#LinearAlgebra.eigen), the corresponding matrix factorization function.
If `F::Eigen` is the factorization object, the eigenvalues can be obtained via `F.values` and the eigenvectors as the columns of the matrix `F.vectors`. (The `k`th eigenvector can be obtained from the slice `F.vectors[:, k]`.)
Iterating the decomposition produces the components `F.values` and `F.vectors`.
**Examples**
```julia-repl
julia> F = eigen([1.0 0.0 0.0; 0.0 3.0 0.0; 0.0 0.0 18.0])
Eigen{Float64, Float64, Matrix{Float64}, Vector{Float64}}
values:
3-element Vector{Float64}:
  1.0
  3.0
 18.0
vectors:
3×3 Matrix{Float64}:
 1.0  0.0  0.0
 0.0  1.0  0.0
 0.0  0.0  1.0

julia> F.values
3-element Vector{Float64}:
  1.0
  3.0
 18.0

julia> F.vectors
3×3 Matrix{Float64}:
 1.0  0.0  0.0
 0.0  1.0  0.0
 0.0  0.0  1.0

julia> vals, vecs = F; # destructuring via iteration

julia> vals == F.values && vecs == F.vectors
true
```
```julia
GeneralizedEigen <: Factorization
```


## [Standard functions](#Standard-functions)
Matrix factorization type of the generalized eigenvalue/spectral decomposition of `A` and `B`. This is the return type of [`eigen`](#LinearAlgebra.eigen), the corresponding matrix factorization function, when called with two matrix arguments.
If `F::GeneralizedEigen` is the factorization object, the eigenvalues can be obtained via `F.values` and the eigenvectors as the columns of the matrix `F.vectors`. (The `k`th eigenvector can be obtained from the slice `F.vectors[:, k]`.)
Iterating the decomposition produces the components `F.values` and `F.vectors`.
**Examples**
```julia-repl
julia> A = [1 0; 0 -1]
2×2 Matrix{Int64}:
 1   0
 0  -1

julia> B = [0 1; 1 0]
2×2 Matrix{Int64}:
 0  1
 1  0

julia> F = eigen(A, B)
GeneralizedEigen{ComplexF64, ComplexF64, Matrix{ComplexF64}, Vector{ComplexF64}}
values:
2-element Vector{ComplexF64}:
 0.0 - 1.0im
 0.0 + 1.0im
vectors:
2×2 Matrix{ComplexF64}:
  0.0+1.0im   0.0-1.0im
 -1.0+0.0im  -1.0-0.0im

julia> F.values
2-element Vector{ComplexF64}:
 0.0 - 1.0im
 0.0 + 1.0im

julia> F.vectors
2×2 Matrix{ComplexF64}:
  0.0+1.0im   0.0-1.0im
 -1.0+0.0im  -1.0-0.0im

julia> vals, vecs = F; # destructuring via iteration

julia> vals == F.values && vecs == F.vectors
true
```
```julia
eigvals(A; permute::Bool=true, scale::Bool=true, sortby) -> values
```
Return the eigenvalues of `A`.
For general non-symmetric matrices it is possible to specify how the matrix is balanced before the eigenvalue calculation. The `permute`, `scale`, and `sortby` keywords are the same as for [`eigen`](#LinearAlgebra.eigen).


## [Standard functions](#Standard-functions)
**Examples**
```julia-repl
julia> diag_matrix = [1 0; 0 4]
2×2 Matrix{Int64}:
 1  0
 0  4

julia> eigvals(diag_matrix)
2-element Vector{Float64}:
 1.0
 4.0
```
For a scalar input, `eigvals` will return a scalar.
**Examples**
```julia-repl
julia> eigvals(-2)
-2
```
```julia
eigvals(A, B) -> values
```
Compute the generalized eigenvalues of `A` and `B`.
**Examples**
```julia-repl
julia> A = [1 0; 0 -1]
2×2 Matrix{Int64}:
 1   0
 0  -1

julia> B = [0 1; 1 0]
2×2 Matrix{Int64}:
 0  1
 1  0

julia> eigvals(A,B)
2-element Vector{ComplexF64}:
 0.0 - 1.0im
 0.0 + 1.0im
```
```julia
eigvals(A::Union{SymTridiagonal, Hermitian, Symmetric}, irange::UnitRange) -> values
```
Return the eigenvalues of `A`. It is possible to calculate only a subset of the eigenvalues by specifying a [`UnitRange`](../../base/collections/#Base.UnitRange) `irange` covering indices of the sorted eigenvalues, e.g. the 2nd to 8th eigenvalues.
**Examples**
```julia-repl
julia> A = SymTridiagonal([1.; 2.; 1.], [2.; 3.])
3×3 SymTridiagonal{Float64, Vector{Float64}}:
 1.0  2.0   ⋅
 2.0  2.0  3.0
  ⋅   3.0  1.0

julia> eigvals(A, 2:2)
1-element Vector{Float64}:
 0.9999999999999996

julia> eigvals(A)
3-element Vector{Float64}:
 -2.1400549446402604
  1.0000000000000002
  5.140054944640259
```
```julia
eigvals(A::Union{SymTridiagonal, Hermitian, Symmetric}, vl::Real, vu::Real) -> values
```
Return the eigenvalues of `A`. It is possible to calculate only a subset of the eigenvalues by specifying a pair `vl` and `vu` for the lower and upper boundaries of the eigenvalues.


## [Standard functions](#Standard-functions)
**Examples**
```julia-repl
julia> A = SymTridiagonal([1.; 2.; 1.], [2.; 3.])
3×3 SymTridiagonal{Float64, Vector{Float64}}:
 1.0  2.0   ⋅
 2.0  2.0  3.0
  ⋅   3.0  1.0

julia> eigvals(A, -1, 2)
1-element Vector{Float64}:
 1.0000000000000009

julia> eigvals(A)
3-element Vector{Float64}:
 -2.1400549446402604
  1.0000000000000002
  5.140054944640259
```
```julia
eigvals!(A; permute::Bool=true, scale::Bool=true, sortby) -> values
```
Same as [`eigvals`](#LinearAlgebra.eigvals), but saves space by overwriting the input `A`, instead of creating a copy. The `permute`, `scale`, and `sortby` keywords are the same as for [`eigen`](#LinearAlgebra.eigen).
The input matrix `A` will not contain its eigenvalues after `eigvals!` is called on it - `A` is used as a workspace.
**Examples**
```julia-repl
julia> A = [1. 2.; 3. 4.]
2×2 Matrix{Float64}:
 1.0  2.0
 3.0  4.0

julia> eigvals!(A)
2-element Vector{Float64}:
 -0.3722813232690143
  5.372281323269014

julia> A
2×2 Matrix{Float64}:
 -0.372281  -1.0
  0.0        5.37228
```
```julia
eigvals!(A, B; sortby) -> values
```
Same as [`eigvals`](#LinearAlgebra.eigvals), but saves space by overwriting the input `A` (and `B`), instead of creating copies.
The input matrices `A` and `B` will not contain their eigenvalues after `eigvals!` is called. They are used as workspaces.
**Examples**


## [Standard functions](#Standard-functions)
```julia-repl
julia> A = [1. 0.; 0. -1.]
2×2 Matrix{Float64}:
 1.0   0.0
 0.0  -1.0

julia> B = [0. 1.; 1. 0.]
2×2 Matrix{Float64}:
 0.0  1.0
 1.0  0.0

julia> eigvals!(A, B)
2-element Vector{ComplexF64}:
 0.0 - 1.0im
 0.0 + 1.0im

julia> A
2×2 Matrix{Float64}:
 -0.0  -1.0
  1.0  -0.0

julia> B
2×2 Matrix{Float64}:
 1.0  0.0
 0.0  1.0
```
```julia
eigvals!(A::Union{SymTridiagonal, Hermitian, Symmetric}, irange::UnitRange) -> values
```
Same as [`eigvals`](#LinearAlgebra.eigvals), but saves space by overwriting the input `A`, instead of creating a copy. `irange` is a range of eigenvalue *indices* to search for - for instance, the 2nd to 8th eigenvalues.
```julia
eigvals!(A::Union{SymTridiagonal, Hermitian, Symmetric}, vl::Real, vu::Real) -> values
```
Same as [`eigvals`](#LinearAlgebra.eigvals), but saves space by overwriting the input `A`, instead of creating a copy. `vl` is the lower bound of the interval to search for eigenvalues, and `vu` is the upper bound.
```julia
eigmax(A; permute::Bool=true, scale::Bool=true)
```
Return the largest eigenvalue of `A`. The option `permute=true` permutes the matrix to become closer to upper triangular, and `scale=true` scales the matrix by its diagonal elements to make rows and columns more equal in norm. Note that if the eigenvalues of `A` are complex, this method will fail, since complex numbers cannot be sorted.
**Examples**


## [Standard functions](#Standard-functions)
```julia-repl
julia> A = [0 im; -im 0]
2×2 Matrix{Complex{Int64}}:
 0+0im  0+1im
 0-1im  0+0im

julia> eigmax(A)
1.0

julia> A = [0 im; -1 0]
2×2 Matrix{Complex{Int64}}:
  0+0im  0+1im
 -1+0im  0+0im

julia> eigmax(A)
ERROR: DomainError with Complex{Int64}[0+0im 0+1im; -1+0im 0+0im]:
`A` cannot have complex eigenvalues.
Stacktrace:
[...]
```
```julia
eigmin(A; permute::Bool=true, scale::Bool=true)
```
Return the smallest eigenvalue of `A`. The option `permute=true` permutes the matrix to become closer to upper triangular, and `scale=true` scales the matrix by its diagonal elements to make rows and columns more equal in norm. Note that if the eigenvalues of `A` are complex, this method will fail, since complex numbers cannot be sorted.
**Examples**
```julia-repl
julia> A = [0 im; -im 0]
2×2 Matrix{Complex{Int64}}:
 0+0im  0+1im
 0-1im  0+0im

julia> eigmin(A)
-1.0

julia> A = [0 im; -1 0]
2×2 Matrix{Complex{Int64}}:
  0+0im  0+1im
 -1+0im  0+0im

julia> eigmin(A)
ERROR: DomainError with Complex{Int64}[0+0im 0+1im; -1+0im 0+0im]:
`A` cannot have complex eigenvalues.
Stacktrace:
[...]
```
```julia
eigvecs(A::SymTridiagonal[, eigvals]) -> Matrix
```
Return a matrix `M` whose columns are the eigenvectors of `A`. (The `k`th eigenvector can be obtained from the slice `M[:, k]`.)
If the optional vector of eigenvalues `eigvals` is specified, `eigvecs` returns the specific corresponding eigenvectors.
**Examples**


## [Standard functions](#Standard-functions)
```julia-repl
julia> A = SymTridiagonal([1.; 2.; 1.], [2.; 3.])
3×3 SymTridiagonal{Float64, Vector{Float64}}:
 1.0  2.0   ⋅
 2.0  2.0  3.0
  ⋅   3.0  1.0

julia> eigvals(A)
3-element Vector{Float64}:
 -2.1400549446402604
  1.0000000000000002
  5.140054944640259

julia> eigvecs(A)
3×3 Matrix{Float64}:
  0.418304  -0.83205      0.364299
 -0.656749  -7.39009e-16  0.754109
  0.627457   0.5547       0.546448

julia> eigvecs(A, [1.])
3×1 Matrix{Float64}:
  0.8320502943378438
  4.263514128092366e-17
 -0.5547001962252291
```
```julia
eigvecs(A; permute::Bool=true, scale::Bool=true, `sortby`) -> Matrix
```
Return a matrix `M` whose columns are the eigenvectors of `A`. (The `k`th eigenvector can be obtained from the slice `M[:, k]`.) The `permute`, `scale`, and `sortby` keywords are the same as for [`eigen`](#LinearAlgebra.eigen).
**Examples**
```julia-repl
julia> eigvecs([1.0 0.0 0.0; 0.0 3.0 0.0; 0.0 0.0 18.0])
3×3 Matrix{Float64}:
 1.0  0.0  0.0
 0.0  1.0  0.0
 0.0  0.0  1.0
```
```julia
eigvecs(A, B) -> Matrix
```
Return a matrix `M` whose columns are the generalized eigenvectors of `A` and `B`. (The `k`th eigenvector can be obtained from the slice `M[:, k]`.)
**Examples**
```julia-repl
julia> A = [1 0; 0 -1]
2×2 Matrix{Int64}:
 1   0
 0  -1

julia> B = [0 1; 1 0]
2×2 Matrix{Int64}:
 0  1
 1  0

julia> eigvecs(A, B)
2×2 Matrix{ComplexF64}:
  0.0+1.0im   0.0-1.0im
 -1.0+0.0im  -1.0-0.0im
```
```julia
eigen(A; permute::Bool=true, scale::Bool=true, sortby) -> Eigen
```


## [Standard functions](#Standard-functions)
Compute the eigenvalue decomposition of `A`, returning an [`Eigen`](#LinearAlgebra.Eigen) factorization object `F` which contains the eigenvalues in `F.values` and the eigenvectors in the columns of the matrix `F.vectors`. This corresponds to solving an eigenvalue problem of the form `Ax =  λx`, where `A` is a matrix, `x` is an eigenvector, and `λ` is an eigenvalue. (The `k`th eigenvector can be obtained from the slice `F.vectors[:, k]`.)
Iterating the decomposition produces the components `F.values` and `F.vectors`.
The following functions are available for `Eigen` objects: [`inv`](../../base/math/#Base.inv-Tuple%7BNumber%7D), [`det`](#LinearAlgebra.det), and [`isposdef`](#LinearAlgebra.isposdef).
For general nonsymmetric matrices it is possible to specify how the matrix is balanced before the eigenvector calculation. The option `permute=true` permutes the matrix to become closer to upper triangular, and `scale=true` scales the matrix by its diagonal elements to make rows and columns more equal in norm. The default is `true` for both options.
By default, the eigenvalues and vectors are sorted lexicographically by `(real(λ),imag(λ))`. A different comparison function `by(λ)` can be passed to `sortby`, or you can pass `sortby=nothing` to leave the eigenvalues in an arbitrary order. Some special matrix types (e.g. [`Diagonal`](#LinearAlgebra.Diagonal) or [`SymTridiagonal`](#LinearAlgebra.SymTridiagonal)) may implement their own sorting convention and not accept a `sortby` keyword.
**Examples**


## [Standard functions](#Standard-functions)
```julia-repl
julia> F = eigen([1.0 0.0 0.0; 0.0 3.0 0.0; 0.0 0.0 18.0])
Eigen{Float64, Float64, Matrix{Float64}, Vector{Float64}}
values:
3-element Vector{Float64}:
  1.0
  3.0
 18.0
vectors:
3×3 Matrix{Float64}:
 1.0  0.0  0.0
 0.0  1.0  0.0
 0.0  0.0  1.0

julia> F.values
3-element Vector{Float64}:
  1.0
  3.0
 18.0

julia> F.vectors
3×3 Matrix{Float64}:
 1.0  0.0  0.0
 0.0  1.0  0.0
 0.0  0.0  1.0

julia> vals, vecs = F; # destructuring via iteration

julia> vals == F.values && vecs == F.vectors
true
```
```julia
eigen(A, B; sortby) -> GeneralizedEigen
```
Compute the generalized eigenvalue decomposition of `A` and `B`, returning a [`GeneralizedEigen`](#LinearAlgebra.GeneralizedEigen) factorization object `F` which contains the generalized eigenvalues in `F.values` and the generalized eigenvectors in the columns of the matrix `F.vectors`. This corresponds to solving a generalized eigenvalue problem of the form `Ax =  λBx`, where `A, B` are matrices, `x` is an eigenvector, and `λ` is an eigenvalue. (The `k`th generalized eigenvector can be obtained from the slice `F.vectors[:, k]`.)
Iterating the decomposition produces the components `F.values` and `F.vectors`.
By default, the eigenvalues and vectors are sorted lexicographically by `(real(λ),imag(λ))`. A different comparison function `by(λ)` can be passed to `sortby`, or you can pass `sortby=nothing` to leave the eigenvalues in an arbitrary order.
**Examples**


## [Standard functions](#Standard-functions)
```julia-repl
julia> A = [1 0; 0 -1]
2×2 Matrix{Int64}:
 1   0
 0  -1

julia> B = [0 1; 1 0]
2×2 Matrix{Int64}:
 0  1
 1  0

julia> F = eigen(A, B);

julia> F.values
2-element Vector{ComplexF64}:
 0.0 - 1.0im
 0.0 + 1.0im

julia> F.vectors
2×2 Matrix{ComplexF64}:
  0.0+1.0im   0.0-1.0im
 -1.0+0.0im  -1.0-0.0im

julia> vals, vecs = F; # destructuring via iteration

julia> vals == F.values && vecs == F.vectors
true
```
```julia
eigen(A::Union{SymTridiagonal, Hermitian, Symmetric}, irange::UnitRange) -> Eigen
```
Compute the eigenvalue decomposition of `A`, returning an [`Eigen`](#LinearAlgebra.Eigen) factorization object `F` which contains the eigenvalues in `F.values` and the eigenvectors in the columns of the matrix `F.vectors`. (The `k`th eigenvector can be obtained from the slice `F.vectors[:, k]`.)
Iterating the decomposition produces the components `F.values` and `F.vectors`.
The following functions are available for `Eigen` objects: [`inv`](../../base/math/#Base.inv-Tuple%7BNumber%7D), [`det`](#LinearAlgebra.det), and [`isposdef`](#LinearAlgebra.isposdef).
The [`UnitRange`](../../base/collections/#Base.UnitRange) `irange` specifies indices of the sorted eigenvalues to search for.
If `irange` is not `1:n`, where `n` is the dimension of `A`, then the returned factorization will be a *truncated* factorization.
```julia
eigen(A::Union{SymTridiagonal, Hermitian, Symmetric}, vl::Real, vu::Real) -> Eigen
```


## [Standard functions](#Standard-functions)
Compute the eigenvalue decomposition of `A`, returning an [`Eigen`](#LinearAlgebra.Eigen) factorization object `F` which contains the eigenvalues in `F.values` and the eigenvectors in the columns of the matrix `F.vectors`. (The `k`th eigenvector can be obtained from the slice `F.vectors[:, k]`.)
Iterating the decomposition produces the components `F.values` and `F.vectors`.
The following functions are available for `Eigen` objects: [`inv`](../../base/math/#Base.inv-Tuple%7BNumber%7D), [`det`](#LinearAlgebra.det), and [`isposdef`](#LinearAlgebra.isposdef).
`vl` is the lower bound of the window of eigenvalues to search for, and `vu` is the upper bound.
If \[`vl`, `vu`\] does not contain all eigenvalues of `A`, then the returned factorization will be a *truncated* factorization.
```julia
eigen!(A; permute, scale, sortby)
eigen!(A, B; sortby)
```
Same as [`eigen`](#LinearAlgebra.eigen), but saves space by overwriting the input `A` (and `B`), instead of creating a copy.
```julia
Hessenberg <: Factorization
```
A `Hessenberg` object represents the Hessenberg factorization `QHQ'` of a square matrix, or a shift `Q(H+μI)Q'` thereof, which is produced by the [`hessenberg`](#LinearAlgebra.hessenberg) function.
```julia
hessenberg(A) -> Hessenberg
```


## [Standard functions](#Standard-functions)
Compute the Hessenberg decomposition of `A` and return a `Hessenberg` object. If `F` is the factorization object, the unitary matrix can be accessed with `F.Q` (of type `LinearAlgebra.HessenbergQ`) and the Hessenberg matrix with `F.H` (of type [`UpperHessenberg`](#LinearAlgebra.UpperHessenberg)), either of which may be converted to a regular matrix with `Matrix(F.H)` or `Matrix(F.Q)`.
If `A` is [`Hermitian`](#LinearAlgebra.Hermitian) or real-[`Symmetric`](#LinearAlgebra.Symmetric), then the Hessenberg decomposition produces a real-symmetric tridiagonal matrix and `F.H` is of type [`SymTridiagonal`](#LinearAlgebra.SymTridiagonal).
Note that the shifted factorization `A+μI = Q (H+μI) Q'` can be constructed efficiently by `F + μ*I` using the [`UniformScaling`](#LinearAlgebra.UniformScaling) object [`I`](#LinearAlgebra.I), which creates a new `Hessenberg` object with shared storage and a modified shift. The shift of a given `F` is obtained by `F.μ`. This is useful because multiple shifted solves `(F + μ*I) \ b` (for different `μ` and/or `b`) can be performed efficiently once `F` is created.
Iterating the decomposition produces the factors `F.Q, F.H, F.μ`.
**Examples**


## [Standard functions](#Standard-functions)
```julia-repl
julia> A = [4. 9. 7.; 4. 4. 1.; 4. 3. 2.]
3×3 Matrix{Float64}:
 4.0  9.0  7.0
 4.0  4.0  1.0
 4.0  3.0  2.0

julia> F = hessenberg(A)
Hessenberg{Float64, UpperHessenberg{Float64, Matrix{Float64}}, Matrix{Float64}, Vector{Float64}, Bool}
Q factor: 3×3 LinearAlgebra.HessenbergQ{Float64, Matrix{Float64}, Vector{Float64}, false}
H factor:
3×3 UpperHessenberg{Float64, Matrix{Float64}}:
  4.0      -11.3137       -1.41421
 -5.65685    5.0           2.0
   ⋅        -8.88178e-16   1.0

julia> F.Q * F.H * F.Q'
3×3 Matrix{Float64}:
 4.0  9.0  7.0
 4.0  4.0  1.0
 4.0  3.0  2.0

julia> q, h = F; # destructuring via iteration

julia> q == F.Q && h == F.H
true
```
```julia
hessenberg!(A) -> Hessenberg
```
`hessenberg!` is the same as [`hessenberg`](#LinearAlgebra.hessenberg), but saves space by overwriting the input `A`, instead of creating a copy.
```julia
Schur <: Factorization
```
Matrix factorization type of the Schur factorization of a matrix `A`. This is the return type of [`schur(_)`](#LinearAlgebra.schur), the corresponding matrix factorization function.
If `F::Schur` is the factorization object, the (quasi) triangular Schur factor can be obtained via either `F.Schur` or `F.T` and the orthogonal/unitary Schur vectors via `F.vectors` or `F.Z` such that `A = F.vectors * F.Schur * F.vectors'`. The eigenvalues of `A` can be obtained with `F.values`.
Iterating the decomposition produces the components `F.T`, `F.Z`, and `F.values`.
**Examples**


## [Standard functions](#Standard-functions)
```julia-repl
julia> A = [5. 7.; -2. -4.]
2×2 Matrix{Float64}:
  5.0   7.0
 -2.0  -4.0

julia> F = schur(A)
Schur{Float64, Matrix{Float64}, Vector{Float64}}
T factor:
2×2 Matrix{Float64}:
 3.0   9.0
 0.0  -2.0
Z factor:
2×2 Matrix{Float64}:
  0.961524  0.274721
 -0.274721  0.961524
eigenvalues:
2-element Vector{Float64}:
  3.0
 -2.0

julia> F.vectors * F.Schur * F.vectors'
2×2 Matrix{Float64}:
  5.0   7.0
 -2.0  -4.0

julia> t, z, vals = F; # destructuring via iteration

julia> t == F.T && z == F.Z && vals == F.values
true
```
```julia
GeneralizedSchur <: Factorization
```
Matrix factorization type of the generalized Schur factorization of two matrices `A` and `B`. This is the return type of [`schur(_, _)`](#LinearAlgebra.schur), the corresponding matrix factorization function.
If `F::GeneralizedSchur` is the factorization object, the (quasi) triangular Schur factors can be obtained via `F.S` and `F.T`, the left unitary/orthogonal Schur vectors via `F.left` or `F.Q`, and the right unitary/orthogonal Schur vectors can be obtained with `F.right` or `F.Z` such that `A=F.left*F.S*F.right'` and `B=F.left*F.T*F.right'`. The generalized eigenvalues of `A` and `B` can be obtained with `F.α./F.β`.
Iterating the decomposition produces the components `F.S`, `F.T`, `F.Q`, `F.Z`, `F.α`, and `F.β`.
```julia
schur(A) -> F::Schur
```


## [Standard functions](#Standard-functions)
Computes the Schur factorization of the matrix `A`. The (quasi) triangular Schur factor can be obtained from the `Schur` object `F` with either `F.Schur` or `F.T` and the orthogonal/unitary Schur vectors can be obtained with `F.vectors` or `F.Z` such that `A = F.vectors * F.Schur * F.vectors'`. The eigenvalues of `A` can be obtained with `F.values`.
For real `A`, the Schur factorization is "quasitriangular", which means that it is upper-triangular except with 2×2 diagonal blocks for any conjugate pair of complex eigenvalues; this allows the factorization to be purely real even when there are complex eigenvalues. To obtain the (complex) purely upper-triangular Schur factorization from a real quasitriangular factorization, you can use `Schur{Complex}(schur(A))`.
Iterating the decomposition produces the components `F.T`, `F.Z`, and `F.values`.
**Examples**
```julia-repl
julia> A = [5. 7.; -2. -4.]
2×2 Matrix{Float64}:
  5.0   7.0
 -2.0  -4.0

julia> F = schur(A)
Schur{Float64, Matrix{Float64}, Vector{Float64}}
T factor:
2×2 Matrix{Float64}:
 3.0   9.0
 0.0  -2.0
Z factor:
2×2 Matrix{Float64}:
  0.961524  0.274721
 -0.274721  0.961524
eigenvalues:
2-element Vector{Float64}:
  3.0
 -2.0

julia> F.vectors * F.Schur * F.vectors'
2×2 Matrix{Float64}:
  5.0   7.0
 -2.0  -4.0

julia> t, z, vals = F; # destructuring via iteration

julia> t == F.T && z == F.Z && vals == F.values
true
```
```julia
schur(A, B) -> F::GeneralizedSchur
```


## [Standard functions](#Standard-functions)
Computes the Generalized Schur (or QZ) factorization of the matrices `A` and `B`. The (quasi) triangular Schur factors can be obtained from the `Schur` object `F` with `F.S` and `F.T`, the left unitary/orthogonal Schur vectors can be obtained with `F.left` or `F.Q` and the right unitary/orthogonal Schur vectors can be obtained with `F.right` or `F.Z` such that `A=F.left*F.S*F.right'` and `B=F.left*F.T*F.right'`. The generalized eigenvalues of `A` and `B` can be obtained with `F.α./F.β`.
Iterating the decomposition produces the components `F.S`, `F.T`, `F.Q`, `F.Z`, `F.α`, and `F.β`.
```julia
schur!(A) -> F::Schur
```
Same as [`schur`](#LinearAlgebra.schur) but uses the input argument `A` as workspace.
**Examples**
```julia-repl
julia> A = [5. 7.; -2. -4.]
2×2 Matrix{Float64}:
  5.0   7.0
 -2.0  -4.0

julia> F = schur!(A)
Schur{Float64, Matrix{Float64}, Vector{Float64}}
T factor:
2×2 Matrix{Float64}:
 3.0   9.0
 0.0  -2.0
Z factor:
2×2 Matrix{Float64}:
  0.961524  0.274721
 -0.274721  0.961524
eigenvalues:
2-element Vector{Float64}:
  3.0
 -2.0

julia> A
2×2 Matrix{Float64}:
 3.0   9.0
 0.0  -2.0
```
```julia
schur!(A::StridedMatrix, B::StridedMatrix) -> F::GeneralizedSchur
```
Same as [`schur`](#LinearAlgebra.schur) but uses the input matrices `A` and `B` as workspace.
```julia
ordschur(F::Schur, select::Union{Vector{Bool},BitVector}) -> F::Schur
```


## [Standard functions](#Standard-functions)
Reorders the Schur factorization `F` of a matrix `A = Z*T*Z'` according to the logical array `select` returning the reordered factorization `F` object. The selected eigenvalues appear in the leading diagonal of `F.Schur` and the corresponding leading columns of `F.vectors` form an orthogonal/unitary basis of the corresponding right invariant subspace. In the real case, a complex conjugate pair of eigenvalues must be either both included or both excluded via `select`.
```julia
ordschur(F::GeneralizedSchur, select::Union{Vector{Bool},BitVector}) -> F::GeneralizedSchur
```
Reorders the Generalized Schur factorization `F` of a matrix pair `(A, B) = (Q*S*Z', Q*T*Z')` according to the logical array `select` and returns a GeneralizedSchur object `F`. The selected eigenvalues appear in the leading diagonal of both `F.S` and `F.T`, and the left and right orthogonal/unitary Schur vectors are also reordered such that `(A, B) = F.Q*(F.S, F.T)*F.Z'` still holds and the generalized eigenvalues of `A` and `B` can still be obtained with `F.α./F.β`.
```julia
ordschur!(F::Schur, select::Union{Vector{Bool},BitVector}) -> F::Schur
```
Same as [`ordschur`](#LinearAlgebra.ordschur) but overwrites the factorization `F`.
```julia
ordschur!(F::GeneralizedSchur, select::Union{Vector{Bool},BitVector}) -> F::GeneralizedSchur
```
Same as `ordschur` but overwrites the factorization `F`.
```julia
SVD <: Factorization
```


## [Standard functions](#Standard-functions)
Matrix factorization type of the singular value decomposition (SVD) of a matrix `A`. This is the return type of [`svd(_)`](#LinearAlgebra.svd), the corresponding matrix factorization function.
If `F::SVD` is the factorization object, `U`, `S`, `V` and `Vt` can be obtained via `F.U`, `F.S`, `F.V` and `F.Vt`, such that `A = U * Diagonal(S) * Vt`. The singular values in `S` are sorted in descending order.
Iterating the decomposition produces the components `U`, `S`, and `V`.
**Examples**
```julia-repl
julia> A = [1. 0. 0. 0. 2.; 0. 0. 3. 0. 0.; 0. 0. 0. 0. 0.; 0. 2. 0. 0. 0.]
4×5 Matrix{Float64}:
 1.0  0.0  0.0  0.0  2.0
 0.0  0.0  3.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0
 0.0  2.0  0.0  0.0  0.0

julia> F = svd(A)
SVD{Float64, Float64, Matrix{Float64}, Vector{Float64}}
U factor:
4×4 Matrix{Float64}:
 0.0  1.0   0.0  0.0
 1.0  0.0   0.0  0.0
 0.0  0.0   0.0  1.0
 0.0  0.0  -1.0  0.0
singular values:
4-element Vector{Float64}:
 3.0
 2.23606797749979
 2.0
 0.0
Vt factor:
4×5 Matrix{Float64}:
 -0.0        0.0  1.0  -0.0  0.0
  0.447214   0.0  0.0   0.0  0.894427
  0.0       -1.0  0.0   0.0  0.0
  0.0        0.0  0.0   1.0  0.0

julia> F.U * Diagonal(F.S) * F.Vt
4×5 Matrix{Float64}:
 1.0  0.0  0.0  0.0  2.0
 0.0  0.0  3.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0
 0.0  2.0  0.0  0.0  0.0

julia> u, s, v = F; # destructuring via iteration

julia> u == F.U && s == F.S && v == F.V
true
```
```julia
GeneralizedSVD <: Factorization
```


## [Standard functions](#Standard-functions)
Matrix factorization type of the generalized singular value decomposition (SVD) of two matrices `A` and `B`, such that `A = F.U*F.D1*F.R0*F.Q'` and `B = F.V*F.D2*F.R0*F.Q'`. This is the return type of [`svd(_, _)`](#LinearAlgebra.svd), the corresponding matrix factorization function.
For an M-by-N matrix `A` and P-by-N matrix `B`,
-   `U` is a M-by-M orthogonal matrix,
-   `V` is a P-by-P orthogonal matrix,
-   `Q` is a N-by-N orthogonal matrix,
-   `D1` is a M-by-(K+L) diagonal matrix with 1s in the first K entries,
-   `D2` is a P-by-(K+L) matrix whose top right L-by-L block is diagonal,
-   `R0` is a (K+L)-by-N matrix whose rightmost (K+L)-by-(K+L) block is nonsingular upper block triangular,
`K+L` is the effective numerical rank of the matrix `[A; B]`.
Iterating the decomposition produces the components `U`, `V`, `Q`, `D1`, `D2`, and `R0`.
The entries of `F.D1` and `F.D2` are related, as explained in the LAPACK documentation for the [generalized SVD](https://www.netlib.org/lapack/lug/node36.html) and the [xGGSVD3](https://www.netlib.org/lapack/explore-html/d6/db3/dggsvd3_8f.html) routine which is called underneath (in LAPACK 3.6.0 and newer).
**Examples**


## [Standard functions](#Standard-functions)
```julia-repl
julia> A = [1. 0.; 0. -1.]
2×2 Matrix{Float64}:
 1.0   0.0
 0.0  -1.0

julia> B = [0. 1.; 1. 0.]
2×2 Matrix{Float64}:
 0.0  1.0
 1.0  0.0

julia> F = svd(A, B)
GeneralizedSVD{Float64, Matrix{Float64}, Float64, Vector{Float64}}
U factor:
2×2 Matrix{Float64}:
 1.0  0.0
 0.0  1.0
V factor:
2×2 Matrix{Float64}:
 -0.0  -1.0
  1.0   0.0
Q factor:
2×2 Matrix{Float64}:
 1.0  0.0
 0.0  1.0
D1 factor:
2×2 Matrix{Float64}:
 0.707107  0.0
 0.0       0.707107
D2 factor:
2×2 Matrix{Float64}:
 0.707107  0.0
 0.0       0.707107
R0 factor:
2×2 Matrix{Float64}:
 1.41421   0.0
 0.0      -1.41421

julia> F.U*F.D1*F.R0*F.Q'
2×2 Matrix{Float64}:
 1.0   0.0
 0.0  -1.0

julia> F.V*F.D2*F.R0*F.Q'
2×2 Matrix{Float64}:
 -0.0  1.0
  1.0  0.0
```
```julia
svd(A; full::Bool = false, alg::Algorithm = default_svd_alg(A)) -> SVD
```
Compute the singular value decomposition (SVD) of `A` and return an `SVD` object.
`U`, `S`, `V` and `Vt` can be obtained from the factorization `F` with `F.U`, `F.S`, `F.V` and `F.Vt`, such that `A = U * Diagonal(S) * Vt`. The algorithm produces `Vt` and hence `Vt` is more efficient to extract than `V`. The singular values in `S` are sorted in descending order.
Iterating the decomposition produces the components `U`, `S`, and `V`.


## [Standard functions](#Standard-functions)
If `full = false` (default), a "thin" SVD is returned. For an $M \\times N$ matrix `A`, in the full factorization `U` is $M \\times M$ and `V` is $N \\times N$, while in the thin factorization `U` is $M \\times K$ and `V` is $N \\times K$, where $K = \\min(M,N)$ is the number of singular values.
If `alg = DivideAndConquer()` a divide-and-conquer algorithm is used to calculate the SVD. Another (typically slower but more accurate) option is `alg = QRIteration()`.
The `alg` keyword argument requires Julia 1.3 or later.
**Examples**
```julia-repl
julia> A = rand(4,3);

julia> F = svd(A); # Store the Factorization Object

julia> A ≈ F.U * Diagonal(F.S) * F.Vt
true

julia> U, S, V = F; # destructuring via iteration

julia> A ≈ U * Diagonal(S) * V'
true

julia> Uonly, = svd(A); # Store U only

julia> Uonly == U
true
```
```julia
svd(A, B) -> GeneralizedSVD
```
Compute the generalized SVD of `A` and `B`, returning a `GeneralizedSVD` factorization object `F` such that `[A;B] = [F.U * F.D1; F.V * F.D2] * F.R0 * F.Q'`
-   `U` is a M-by-M orthogonal matrix,
-   `V` is a P-by-P orthogonal matrix,
-   `Q` is a N-by-N orthogonal matrix,
-   `D1` is a M-by-(K+L) diagonal matrix with 1s in the first K entries,
-   `D2` is a P-by-(K+L) matrix whose top right L-by-L block is diagonal,
-   `R0` is a (K+L)-by-N matrix whose rightmost (K+L)-by-(K+L) block is nonsingular upper block triangular,
`K+L` is the effective numerical rank of the matrix `[A; B]`.
Iterating the decomposition produces the components `U`, `V`, `Q`, `D1`, `D2`, and `R0`.