## [Standard functions](#Standard-functions)
The generalized SVD is used in applications such as when one wants to compare how much belongs to `A` vs. how much belongs to `B`, as in human vs yeast genome, or signal vs noise, or between clusters vs within clusters. (See Edelman and Wang for discussion: https://arxiv.org/abs/1901.00485)
It decomposes `[A; B]` into `[UC; VS]H`, where `[UC; VS]` is a natural orthogonal basis for the column space of `[A; B]`, and `H = RQ'` is a natural non-orthogonal basis for the rowspace of `[A;B]`, where the top rows are most closely attributed to the `A` matrix, and the bottom to the `B` matrix. The multi-cosine/sine matrices `C` and `S` provide a multi-measure of how much `A` vs how much `B`, and `U` and `V` provide directions in which these are measured.
**Examples**
```julia-repl
julia> A = randn(3,2); B=randn(4,2);

julia> F = svd(A, B);

julia> U,V,Q,C,S,R = F;

julia> H = R*Q';

julia> [A; B] ≈ [U*C; V*S]*H
true

julia> [A; B] ≈ [F.U*F.D1; F.V*F.D2]*F.R0*F.Q'
true

julia> Uonly, = svd(A,B);

julia> U == Uonly
true
```
```julia
svd!(A; full::Bool = false, alg::Algorithm = default_svd_alg(A)) -> SVD
```
`svd!` is the same as [`svd`](#LinearAlgebra.svd), but saves space by overwriting the input `A`, instead of creating a copy. See documentation of [`svd`](#LinearAlgebra.svd) for details.
```julia
svd!(A, B) -> GeneralizedSVD
```
`svd!` is the same as [`svd`](#LinearAlgebra.svd), but modifies the arguments `A` and `B` in-place, instead of making copies. See documentation of [`svd`](#LinearAlgebra.svd) for details.
```julia
svdvals(A)
```


## [Standard functions](#Standard-functions)
Return the singular values of `A` in descending order.
**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> svdvals(A)
4-element Vector{Float64}:
 3.0
 2.23606797749979
 2.0
 0.0
```
```julia
svdvals(A, B)
```
Return the generalized singular values from the generalized singular value decomposition of `A` and `B`. See also [`svd`](#LinearAlgebra.svd).
**Examples**
```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> svdvals(A, B)
2-element Vector{Float64}:
 1.0
 1.0
```
```julia
svdvals!(A)
```
Return the singular values of `A`, saving space by overwriting the input. See also [`svdvals`](#LinearAlgebra.svdvals) and [`svd`](#LinearAlgebra.svd).
```julia
svdvals!(A, B)
```
Return the generalized singular values from the generalized singular value decomposition of `A` and `B`, saving space by overwriting `A` and `B`. See also [`svd`](#LinearAlgebra.svd) and [`svdvals`](#LinearAlgebra.svdvals).
```julia
LinearAlgebra.Givens(i1,i2,c,s) -> G
```


## [Standard functions](#Standard-functions)
A Givens rotation linear operator. The fields `c` and `s` represent the cosine and sine of the rotation angle, respectively. The `Givens` type supports left multiplication `G*A` and conjugated transpose right multiplication `A*G'`. The type doesn't have a `size` and can therefore be multiplied with matrices of arbitrary size as long as `i2<=size(A,2)` for `G*A` or `i2<=size(A,1)` for `A*G'`.
See also [`givens`](#LinearAlgebra.givens).
```julia
givens(f::T, g::T, i1::Integer, i2::Integer) where {T} -> (G::Givens, r::T)
```
Computes the Givens rotation `G` and scalar `r` such that for any vector `x` where
```julia
x[i1] = f
x[i2] = g
```
the result of the multiplication
```julia
y = G*x
```
has the property that
```julia
y[i1] = r
y[i2] = 0
```
See also [`LinearAlgebra.Givens`](#LinearAlgebra.Givens).
```julia
givens(A::AbstractArray, i1::Integer, i2::Integer, j::Integer) -> (G::Givens, r)
```
Computes the Givens rotation `G` and scalar `r` such that the result of the multiplication
```julia
B = G*A
```
has the property that
```julia
B[i1,j] = r
B[i2,j] = 0
```
See also [`LinearAlgebra.Givens`](#LinearAlgebra.Givens).
```julia
givens(x::AbstractVector, i1::Integer, i2::Integer) -> (G::Givens, r)
```
Computes the Givens rotation `G` and scalar `r` such that the result of the multiplication
```julia
B = G*x
```
has the property that
```julia
B[i1] = r
B[i2] = 0
```
See also [`LinearAlgebra.Givens`](#LinearAlgebra.Givens).
```julia
triu(M)
```
Upper triangle of a matrix.
**Examples**


## [Standard functions](#Standard-functions)
```julia-repl
julia> a = fill(1.0, (4,4))
4×4 Matrix{Float64}:
 1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0

julia> triu(a)
4×4 Matrix{Float64}:
 1.0  1.0  1.0  1.0
 0.0  1.0  1.0  1.0
 0.0  0.0  1.0  1.0
 0.0  0.0  0.0  1.0
```
```julia
triu(M, k::Integer)
```
Return the upper triangle of `M` starting from the `k`th superdiagonal.
**Examples**
```julia-repl
julia> a = fill(1.0, (4,4))
4×4 Matrix{Float64}:
 1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0

julia> triu(a,3)
4×4 Matrix{Float64}:
 0.0  0.0  0.0  1.0
 0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0

julia> triu(a,-3)
4×4 Matrix{Float64}:
 1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0
```
```julia
triu!(M)
```
Upper triangle of a matrix, overwriting `M` in the process. See also [`triu`](#LinearAlgebra.triu).
```julia
triu!(M, k::Integer)
```
Return the upper triangle of `M` starting from the `k`th superdiagonal, overwriting `M` in the process.
**Examples**
```julia-repl
julia> M = [1 2 3 4 5; 1 2 3 4 5; 1 2 3 4 5; 1 2 3 4 5; 1 2 3 4 5]
5×5 Matrix{Int64}:
 1  2  3  4  5
 1  2  3  4  5
 1  2  3  4  5
 1  2  3  4  5
 1  2  3  4  5

julia> triu!(M, 1)
5×5 Matrix{Int64}:
 0  2  3  4  5
 0  0  3  4  5
 0  0  0  4  5
 0  0  0  0  5
 0  0  0  0  0
```
```julia
tril(M)
```
Lower triangle of a matrix.
**Examples**


## [Standard functions](#Standard-functions)
```julia-repl
julia> a = fill(1.0, (4,4))
4×4 Matrix{Float64}:
 1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0

julia> tril(a)
4×4 Matrix{Float64}:
 1.0  0.0  0.0  0.0
 1.0  1.0  0.0  0.0
 1.0  1.0  1.0  0.0
 1.0  1.0  1.0  1.0
```
```julia
tril(M, k::Integer)
```
Return the lower triangle of `M` starting from the `k`th superdiagonal.
**Examples**
```julia-repl
julia> a = fill(1.0, (4,4))
4×4 Matrix{Float64}:
 1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0

julia> tril(a,3)
4×4 Matrix{Float64}:
 1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0

julia> tril(a,-3)
4×4 Matrix{Float64}:
 0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0
 1.0  0.0  0.0  0.0
```
```julia
tril!(M)
```
Lower triangle of a matrix, overwriting `M` in the process. See also [`tril`](#LinearAlgebra.tril).
```julia
tril!(M, k::Integer)
```
Return the lower triangle of `M` starting from the `k`th superdiagonal, overwriting `M` in the process.
**Examples**
```julia-repl
julia> M = [1 2 3 4 5; 1 2 3 4 5; 1 2 3 4 5; 1 2 3 4 5; 1 2 3 4 5]
5×5 Matrix{Int64}:
 1  2  3  4  5
 1  2  3  4  5
 1  2  3  4  5
 1  2  3  4  5
 1  2  3  4  5

julia> tril!(M, 2)
5×5 Matrix{Int64}:
 1  2  3  0  0
 1  2  3  4  0
 1  2  3  4  5
 1  2  3  4  5
 1  2  3  4  5
```
```julia
diagind(M::AbstractMatrix, k::Integer = 0, indstyle::IndexStyle = IndexLinear())
diagind(M::AbstractMatrix, indstyle::IndexStyle = IndexLinear())
```


## [Standard functions](#Standard-functions)
An `AbstractRange` giving the indices of the `k`th diagonal of the matrix `M`. Optionally, an index style may be specified which determines the type of the range returned. If `indstyle isa IndexLinear` (default), this returns an `AbstractRange{Integer}`. On the other hand, if `indstyle isa IndexCartesian`, this returns an `AbstractRange{CartesianIndex{2}}`.
If `k` is not provided, it is assumed to be `0` (corresponding to the main diagonal).
See also: [`diag`](#LinearAlgebra.diag), [`diagm`](#LinearAlgebra.diagm), [`Diagonal`](#LinearAlgebra.Diagonal).
**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> diagind(A, -1)
2:4:6

julia> diagind(A, IndexCartesian())
StepRangeLen(CartesianIndex(1, 1), CartesianIndex(1, 1), 3)
```
Specifying an `IndexStyle` requires at least Julia 1.11.
```julia
diag(M, k::Integer=0)
```
The `k`th diagonal of a matrix, as a vector.
See also [`diagm`](#LinearAlgebra.diagm), [`diagind`](#LinearAlgebra.diagind), [`Diagonal`](#LinearAlgebra.Diagonal), [`isdiag`](#LinearAlgebra.isdiag).
**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> diag(A,1)
2-element Vector{Int64}:
 2
 6
```
```julia
diagm(kv::Pair{<:Integer,<:AbstractVector}...)
diagm(m::Integer, n::Integer, kv::Pair{<:Integer,<:AbstractVector}...)
```


## [Standard functions](#Standard-functions)
Construct a matrix from `Pair`s of diagonals and vectors. Vector `kv.second` will be placed on the `kv.first` diagonal. By default the matrix is square and its size is inferred from `kv`, but a non-square size `m`×`n` (padded with zeros as needed) can be specified by passing `m,n` as the first arguments. For repeated diagonal indices `kv.first` the values in the corresponding vectors `kv.second` will be added.
`diagm` constructs a full matrix; if you want storage-efficient versions with fast arithmetic, see [`Diagonal`](#LinearAlgebra.Diagonal), [`Bidiagonal`](#LinearAlgebra.Bidiagonal) [`Tridiagonal`](#LinearAlgebra.Tridiagonal) and [`SymTridiagonal`](#LinearAlgebra.SymTridiagonal).
**Examples**
```julia-repl
julia> diagm(1 => [1,2,3])
4×4 Matrix{Int64}:
 0  1  0  0
 0  0  2  0
 0  0  0  3
 0  0  0  0

julia> diagm(1 => [1,2,3], -1 => [4,5])
4×4 Matrix{Int64}:
 0  1  0  0
 4  0  2  0
 0  5  0  3
 0  0  0  0

julia> diagm(1 => [1,2,3], 1 => [1,2,3])
4×4 Matrix{Int64}:
 0  2  0  0
 0  0  4  0
 0  0  0  6
 0  0  0  0
```
```julia
diagm(v::AbstractVector)
diagm(m::Integer, n::Integer, v::AbstractVector)
```
Construct a matrix with elements of the vector as diagonal elements. By default, the matrix is square and its size is given by `length(v)`, but a non-square size `m`×`n` can be specified by passing `m,n` as the first arguments.
**Examples**
```julia-repl
julia> diagm([1,2,3])
3×3 Matrix{Int64}:
 1  0  0
 0  2  0
 0  0  3
```
```julia
rank(::QRSparse{Tv,Ti}) -> Ti
```
Return the rank of the QR factorization


## [Standard functions](#Standard-functions)
```julia
rank(S::SparseMatrixCSC{Tv,Ti}; [tol::Real]) -> Ti
```
Calculate rank of `S` by calculating its QR factorization. Values smaller than `tol` are considered as zero. See SPQR's manual.
```julia
rank(A::AbstractMatrix; atol::Real=0, rtol::Real=atol>0 ? 0 : n*ϵ)
rank(A::AbstractMatrix, rtol::Real)
```
Compute the numerical rank of a matrix by counting how many outputs of `svdvals(A)` are greater than `max(atol, rtol*σ₁)` where `σ₁` is `A`'s largest calculated singular value. `atol` and `rtol` are the absolute and relative tolerances, respectively. The default relative tolerance is `n*ϵ`, where `n` is the size of the smallest dimension of `A`, and `ϵ` is the [`eps`](../../base/base/#Base.eps-Tuple%7BType%7B%3C:AbstractFloat%7D%7D) of the element type of `A`.
Numerical rank can be a sensitive and imprecise characterization of ill-conditioned matrices with singular values that are close to the threshold tolerance `max(atol, rtol*σ₁)`. In such cases, slight perturbations to the singular-value computation or to the matrix can change the result of `rank` by pushing one or more singular values across the threshold. These variations can even occur due to changes in floating-point errors between different Julia versions, architectures, compilers, or operating systems.
The `atol` and `rtol` keyword arguments requires at least Julia 1.1. In Julia 1.0 `rtol` is available as a positional argument, but this will be deprecated in Julia 2.0.
**Examples**


## [Standard functions](#Standard-functions)
```julia-repl
julia> rank(Matrix(I, 3, 3))
3

julia> rank(diagm(0 => [1, 0, 2]))
2

julia> rank(diagm(0 => [1, 0.001, 2]), rtol=0.1)
2

julia> rank(diagm(0 => [1, 0.001, 2]), rtol=0.00001)
3

julia> rank(diagm(0 => [1, 0.001, 2]), atol=1.5)
1
```
```julia
norm(A, p::Real=2)
```
For any iterable container `A` (including arrays of any dimension) of numbers (or any element type for which `norm` is defined), compute the `p`-norm (defaulting to `p=2`) as if `A` were a vector of the corresponding length.
The `p`-norm is defined as
\\\[\\\|A\\\|\_p = \\left( \\sum\_{i=1}^n \| a_i \| ^p \\right)^{1/p}\\\]
with $a_i$ the entries of $A$, $\| a_i \|$ the [`norm`](#LinearAlgebra.norm) of $a_i$, and $n$ the length of $A$. Since the `p`-norm is computed using the [`norm`](#LinearAlgebra.norm)s of the entries of `A`, the `p`-norm of a vector of vectors is not compatible with the interpretation of it as a block vector in general if `p != 2`.
`p` can assume any numeric value (even though not all values produce a mathematically valid vector norm). In particular, `norm(A, Inf)` returns the largest value in `abs.(A)`, whereas `norm(A, -Inf)` returns the smallest. If `A` is a matrix and `p=2`, then this is equivalent to the Frobenius norm.
The second argument `p` is not necessarily a part of the interface for `norm`, i.e. a custom type may only implement `norm(A)` without second argument.
Use [`opnorm`](#LinearAlgebra.opnorm) to compute the operator norm of a matrix.
**Examples**


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

julia> norm(v)
7.0

julia> norm(v, 1)
11.0

julia> norm(v, Inf)
6.0

julia> norm([1 2 3; 4 5 6; 7 8 9])
16.881943016134134

julia> norm([1 2 3 4 5 6 7 8 9])
16.881943016134134

julia> norm(1:9)
16.881943016134134

julia> norm(hcat(v,v), 1) == norm(vcat(v,v), 1) != norm([v,v], 1)
true

julia> norm(hcat(v,v), 2) == norm(vcat(v,v), 2) == norm([v,v], 2)
true

julia> norm(hcat(v,v), Inf) == norm(vcat(v,v), Inf) != norm([v,v], Inf)
true
```
```julia
norm(x::Number, p::Real=2)
```
For numbers, return $\\left( \|x\|^p \\right)^{1/p}$.
**Examples**
```julia-repl
julia> norm(2, 1)
2.0

julia> norm(-2, 1)
2.0

julia> norm(2, 2)
2.0

julia> norm(-2, 2)
2.0

julia> norm(2, Inf)
2.0

julia> norm(-2, Inf)
2.0
```
```julia
opnorm(A::AbstractMatrix, p::Real=2)
```
Compute the operator norm (or matrix norm) induced by the vector `p`-norm, where valid values of `p` are `1`, `2`, or `Inf`. (Note that for sparse matrices, `p=2` is currently not implemented.) Use [`norm`](#LinearAlgebra.norm) to compute the Frobenius norm.
When `p=1`, the operator norm is the maximum absolute column sum of `A`:
\\\[\\\|A\\\|\_1 = \\max\_{1 ≤ j ≤ n} \\sum\_{i=1}^m \| a\_{ij} \|\\\]
with $a\_{ij}$ the entries of $A$, and $m$ and $n$ its dimensions.
When `p=2`, the operator norm is the spectral norm, equal to the largest singular value of `A`.
When `p=Inf`, the operator norm is the maximum absolute row sum of `A`:
\\\[\\\|A\\\|\_\\infty = \\max\_{1 ≤ i ≤ m} \\sum \_{j=1}^n \| a\_{ij} \|\\\]


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

julia> opnorm(A, Inf)
6.0

julia> opnorm(A, 1)
5.0
```
```julia
opnorm(x::Number, p::Real=2)
```
For numbers, return $\\left( \|x\|^p \\right)^{1/p}$. This is equivalent to [`norm`](#LinearAlgebra.norm).
```julia
opnorm(A::Adjoint{<:Any,<:AbstractVector}, q::Real=2)
opnorm(A::Transpose{<:Any,<:AbstractVector}, q::Real=2)
```
For Adjoint/Transpose-wrapped vectors, return the operator $q$-norm of `A`, which is equivalent to the `p`-norm with value `p = q/(q-1)`. They coincide at `p = q = 2`. Use [`norm`](#LinearAlgebra.norm) to compute the `p` norm of `A` as a vector.
The difference in norm between a vector space and its dual arises to preserve the relationship between duality and the dot product, and the result is consistent with the operator `p`-norm of a `1 × n` matrix.
**Examples**
```julia-repl
julia> v = [1; im];

julia> vc = v';

julia> opnorm(vc, 1)
1.0

julia> norm(vc, 1)
2.0

julia> norm(v, 1)
2.0

julia> opnorm(vc, 2)
1.4142135623730951

julia> norm(vc, 2)
1.4142135623730951

julia> norm(v, 2)
1.4142135623730951

julia> opnorm(vc, Inf)
2.0

julia> norm(vc, Inf)
1.0

julia> norm(v, Inf)
1.0
```
```julia
normalize!(a::AbstractArray, p::Real=2)
```
Normalize the array `a` in-place so that its `p`-norm equals unity, i.e. `norm(a, p) == 1`. See also [`normalize`](#LinearAlgebra.normalize) and [`norm`](#LinearAlgebra.norm).
```julia
normalize(a, p::Real=2)
```


## [Standard functions](#Standard-functions)
Normalize `a` so that its `p`-norm equals unity, i.e. `norm(a, p) == 1`. For scalars, this is similar to sign(a), except normalize(0) = NaN. See also [`normalize!`](#LinearAlgebra.normalize!), [`norm`](#LinearAlgebra.norm), and [`sign`](../../base/math/#Base.sign).
**Examples**
```julia-repl
julia> a = [1,2,4];

julia> b = normalize(a)
3-element Vector{Float64}:
 0.2182178902359924
 0.4364357804719848
 0.8728715609439696

julia> norm(b)
1.0

julia> c = normalize(a, 1)
3-element Vector{Float64}:
 0.14285714285714285
 0.2857142857142857
 0.5714285714285714

julia> norm(c, 1)
1.0

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

julia> norm(a)
6.48074069840786

julia> normalize(a)
2×3 Matrix{Float64}:
 0.154303  0.308607  0.617213
 0.154303  0.308607  0.617213

julia> normalize(3, 1)
1.0

julia> normalize(-8, 1)
-1.0

julia> normalize(0, 1)
NaN
```
```julia
cond(M, p::Real=2)
```
Condition number of the matrix `M`, computed using the operator `p`-norm. Valid values for `p` are `1`, `2` (default), or `Inf`.
```julia
condskeel(M, [x, p::Real=Inf])
```
\\\[\\kappa_S(M, p) = \\left\\Vert \\left\\vert M \\right\\vert \\left\\vert M^{-1} \\right\\vert \\right\\Vert_p \\\\ \\kappa_S(M, x, p) = \\frac{\\left\\Vert \\left\\vert M \\right\\vert \\left\\vert M^{-1} \\right\\vert \\left\\vert x \\right\\vert \\right\\Vert_p}{\\left \\Vert x \\right \\Vert_p}\\\]


## [Standard functions](#Standard-functions)
Skeel condition number $\\kappa_S$ of the matrix `M`, optionally with respect to the vector `x`, as computed using the operator `p`-norm. $\\left\\vert M \\right\\vert$ denotes the matrix of (entry wise) absolute values of $M$; $\\left\\vert M \\right\\vert\_{ij} = \\left\\vert M\_{ij} \\right\\vert$. Valid values for `p` are `1`, `2` and `Inf` (default).
This quantity is also known in the literature as the Bauer condition number, relative condition number, or componentwise relative condition number.
```julia
tr(M)
```
Matrix trace. Sums the diagonal elements of `M`.
**Examples**
```julia-repl
julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> tr(A)
5
```
```julia
det(M)
```
Matrix determinant.
See also: [`logdet`](#LinearAlgebra.logdet) and [`logabsdet`](#LinearAlgebra.logabsdet).
**Examples**
```julia-repl
julia> M = [1 0; 2 2]
2×2 Matrix{Int64}:
 1  0
 2  2

julia> det(M)
2.0
```
```julia
logdet(M)
```
Logarithm of matrix determinant. Equivalent to `log(det(M))`, but may provide increased accuracy and avoids overflow/underflow.
**Examples**
```julia-repl
julia> M = [1 0; 2 2]
2×2 Matrix{Int64}:
 1  0
 2  2

julia> logdet(M)
0.6931471805599453

julia> logdet(Matrix(I, 3, 3))
0.0
```
```julia
logabsdet(M)
```
Log of absolute value of matrix determinant. Equivalent to `(log(abs(det(M))), sign(det(M)))`, but may provide increased accuracy and/or speed.
**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> det(A)
-1.0

julia> logabsdet(A)
(0.0, -1.0)

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

julia> det(B)
2.0

julia> logabsdet(B)
(0.6931471805599453, 1.0)
```
```julia
inv(M)
```
Matrix inverse. Computes matrix `N` such that `M * N = I`, where `I` is the identity matrix. Computed by solving the left-division `N = M \ I`.
**Examples**
```julia-repl
julia> M = [2 5; 1 3]
2×2 Matrix{Int64}:
 2  5
 1  3

julia> N = inv(M)
2×2 Matrix{Float64}:
  3.0  -5.0
 -1.0   2.0

julia> M*N == N*M == Matrix(I, 2, 2)
true
```
```julia
pinv(M; atol::Real=0, rtol::Real=atol>0 ? 0 : n*ϵ)
pinv(M, rtol::Real) = pinv(M; rtol=rtol) # to be deprecated in Julia 2.0
```
Computes the Moore-Penrose pseudoinverse.
For matrices `M` with floating point elements, it is convenient to compute the pseudoinverse by inverting only singular values greater than `max(atol, rtol*σ₁)` where `σ₁` is the largest singular value of `M`.
The optimal choice of absolute (`atol`) and relative tolerance (`rtol`) varies both with the value of `M` and the intended application of the pseudoinverse. The default relative tolerance is `n*ϵ`, where `n` is the size of the smallest dimension of `M`, and `ϵ` is the [`eps`](../../base/base/#Base.eps-Tuple%7BType%7B%3C:AbstractFloat%7D%7D) of the element type of `M`.
For inverting dense ill-conditioned matrices in a least-squares sense, `rtol = sqrt(eps(real(float(oneunit(eltype(M))))))` is recommended.


## [Standard functions](#Standard-functions)
For more information, see [[issue8859\]](#footnote-issue8859), [[B96\]](#footnote-B96), [[S84\]](#footnote-S84), [[KY88\]](#footnote-KY88).
**Examples**
```julia-repl
julia> M = [1.5 1.3; 1.2 1.9]
2×2 Matrix{Float64}:
 1.5  1.3
 1.2  1.9

julia> N = pinv(M)
2×2 Matrix{Float64}:
  1.47287   -1.00775
 -0.930233   1.16279

julia> M * N
2×2 Matrix{Float64}:
 1.0          -2.22045e-16
 4.44089e-16   1.0
```
```julia
nullspace(M; atol::Real=0, rtol::Real=atol>0 ? 0 : n*ϵ)
nullspace(M, rtol::Real) = nullspace(M; rtol=rtol) # to be deprecated in Julia 2.0
```
Computes a basis for the nullspace of `M` by including the singular vectors of `M` whose singular values have magnitudes smaller than `max(atol, rtol*σ₁)`, where `σ₁` is `M`'s largest singular value.
By default, the relative tolerance `rtol` is `n*ϵ`, where `n` is the size of the smallest dimension of `M`, and `ϵ` is the [`eps`](../../base/base/#Base.eps-Tuple%7BType%7B%3C:AbstractFloat%7D%7D) of the element type of `M`.
**Examples**
```julia-repl
julia> M = [1 0 0; 0 1 0; 0 0 0]
3×3 Matrix{Int64}:
 1  0  0
 0  1  0
 0  0  0

julia> nullspace(M)
3×1 Matrix{Float64}:
 0.0
 0.0
 1.0

julia> nullspace(M, rtol=3)
3×3 Matrix{Float64}:
 0.0  1.0  0.0
 1.0  0.0  0.0
 0.0  0.0  1.0

julia> nullspace(M, atol=0.95)
3×1 Matrix{Float64}:
 0.0
 0.0
 1.0
```
```julia
kron(A, B)
```
Computes the Kronecker product of two vectors, matrices or numbers.


## [Standard functions](#Standard-functions)
For real vectors `v` and `w`, the Kronecker product is related to the outer product by `kron(v,w) == vec(w * transpose(v))` or `w * transpose(v) == reshape(kron(v,w), (length(w), length(v)))`. Note how the ordering of `v` and `w` differs on the left and right of these expressions (due to column-major storage). For complex vectors, the outer product `w * v'` also differs by conjugation of `v`.
**Examples**
```julia-repl
julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

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

julia> kron(A, B)
4×4 Matrix{Complex{Int64}}:
 0+1im  1+0im  0+2im  2+0im
 1+0im  0-1im  2+0im  0-2im
 0+3im  3+0im  0+4im  4+0im
 3+0im  0-3im  4+0im  0-4im

julia> v = [1, 2]; w = [3, 4, 5];

julia> w*transpose(v)
3×2 Matrix{Int64}:
 3   6
 4   8
 5  10

julia> reshape(kron(v,w), (length(w), length(v)))
3×2 Matrix{Int64}:
 3   6
 4   8
 5  10
```
```julia
kron!(C, A, B)
```
Computes the Kronecker product of `A` and `B` and stores the result in `C`, overwriting the existing content of `C`. This is the in-place version of [`kron`](#Base.kron).
This function requires Julia 1.6 or later.
```julia
exp(A::AbstractMatrix)
```
Compute the matrix exponential of `A`, defined by
\\\[e^A = \\sum\_{n=0}^{\\infty} \\frac{A^n}{n!}.\\\]
For symmetric or Hermitian `A`, an eigendecomposition ([`eigen`](#LinearAlgebra.eigen)) is used, otherwise the scaling and squaring algorithm (see <sup>[[H05\]](#footnote-H05)</sup>) is chosen.
**Examples**


## [Standard functions](#Standard-functions)
```julia-repl
julia> A = Matrix(1.0I, 2, 2)
2×2 Matrix{Float64}:
 1.0  0.0
 0.0  1.0

julia> exp(A)
2×2 Matrix{Float64}:
 2.71828  0.0
 0.0      2.71828
```
```julia
cis(A::AbstractMatrix)
```
More efficient method for `exp(im*A)` of square matrix `A` (especially if `A` is `Hermitian` or real-`Symmetric`).
See also [`cispi`](../../base/math/#Base.cispi), [`sincos`](../../base/math/#Base.Math.sincos-Tuple%7BFloat64%7D), [`exp`](../../base/math/#Base.exp-Tuple%7BFloat64%7D).
Support for using `cis` with matrices was added in Julia 1.7.
**Examples**
```julia-repl
julia> cis([π 0; 0 π]) ≈ -I
true
```
```julia
^(A::AbstractMatrix, p::Number)
```
Matrix power, equivalent to $\\exp(p\\log(A))$
**Examples**
```julia-repl
julia> [1 2; 0 3]^3
2×2 Matrix{Int64}:
 1  26
 0  27
```
```julia
^(b::Number, A::AbstractMatrix)
```
Matrix exponential, equivalent to $\\exp(\\log(b)A)$.
Support for raising `Irrational` numbers (like `ℯ`) to a matrix was added in Julia 1.1.
**Examples**
```julia-repl
julia> 2^[1 2; 0 3]
2×2 Matrix{Float64}:
 2.0  6.0
 0.0  8.0

julia> ℯ^[1 2; 0 3]
2×2 Matrix{Float64}:
 2.71828  17.3673
 0.0      20.0855
```
```julia
log(A::AbstractMatrix)
```
If `A` has no negative real eigenvalue, compute the principal matrix logarithm of `A`, i.e. the unique matrix $X$ such that $e^X = A$ and $-\\pi \< Im(\\lambda) \< \\pi$ for all the eigenvalues $\\lambda$ of $X$. If `A` has nonpositive eigenvalues, a nonprincipal matrix function is returned whenever possible.


## [Standard functions](#Standard-functions)
If `A` is symmetric or Hermitian, its eigendecomposition ([`eigen`](#LinearAlgebra.eigen)) is used, if `A` is triangular an improved version of the inverse scaling and squaring method is employed (see [[AH12\]](#footnote-AH12) and [[AHR13\]](#footnote-AHR13)). If `A` is real with no negative eigenvalues, then the real Schur form is computed. Otherwise, the complex Schur form is computed. Then the upper (quasi-)triangular algorithm in [[AHR13\]](#footnote-AHR13) is used on the upper (quasi-)triangular factor.
**Examples**
```julia-repl
julia> A = Matrix(2.7182818*I, 2, 2)
2×2 Matrix{Float64}:
 2.71828  0.0
 0.0      2.71828

julia> log(A)
2×2 Matrix{Float64}:
 1.0  0.0
 0.0  1.0
```
```julia
sqrt(x)
```
Return $\\sqrt{x}$.
Throws [`DomainError`](../../base/base/#Core.DomainError) for negative [`Real`](../../base/numbers/#Core.Real) arguments. Use complex negative arguments instead. Note that `sqrt` has a branch cut along the negative real axis.
The prefix operator `√` is equivalent to `sqrt`.
See also: [`hypot`](../../base/math/#Base.Math.hypot).
**Examples**
```julia-repl
julia> sqrt(big(81))
9.0

julia> sqrt(big(-81))
ERROR: DomainError with -81.0:
NaN result for non-NaN input.
Stacktrace:
 [1] sqrt(::BigFloat) at ./mpfr.jl:501
[...]

julia> sqrt(big(complex(-81)))
0.0 + 9.0im

julia> sqrt(-81 - 0.0im)  # -0.0im is below the branch cut
0.0 - 9.0im

julia> .√(1:4)
4-element Vector{Float64}:
 1.0
 1.4142135623730951
 1.7320508075688772
 2.0
```


## [Standard functions](#Standard-functions)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/math.jl#L612-L650)
```julia
sqrt(A::AbstractMatrix)
```
If `A` has no negative real eigenvalues, compute the principal matrix square root of `A`, that is the unique matrix $X$ with eigenvalues having positive real part such that $X^2 = A$. Otherwise, a nonprincipal square root is returned.
If `A` is real-symmetric or Hermitian, its eigendecomposition ([`eigen`](#LinearAlgebra.eigen)) is used to compute the square root. For such matrices, eigenvalues λ that appear to be slightly negative due to roundoff errors are treated as if they were zero. More precisely, matrices with all eigenvalues `≥ -rtol*(max |λ|)` are treated as semidefinite (yielding a Hermitian square root), with negative eigenvalues taken to be zero. `rtol` is a keyword argument to `sqrt` (in the Hermitian/real-symmetric case only) that defaults to machine precision scaled by `size(A,1)`.
Otherwise, the square root is determined by means of the Björck-Hammarling method [[BH83\]](#footnote-BH83), which computes the complex Schur form ([`schur`](#LinearAlgebra.schur)) and then the complex square root of the triangular factor. If a real square root exists, then an extension of this method [[H87\]](#footnote-H87) that computes the real Schur form and then the real square root of the quasi-triangular factor is instead used.
**Examples**


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

julia> sqrt(A)
2×2 Matrix{Float64}:
 2.0  0.0
 0.0  2.0
```
```julia
cbrt(A::AbstractMatrix{<:Real})
```
Computes the real-valued cube root of a real-valued matrix `A`. If `T = cbrt(A)`, then we have `T*T*T ≈ A`, see example given below.
If `A` is symmetric, i.e., of type `HermOrSym{<:Real}`, then ([`eigen`](#LinearAlgebra.eigen)) is used to find the cube root. Otherwise, a specialized version of the p-th root algorithm <sup>[[S03\]](#footnote-S03)</sup> is utilized, which exploits the real-valued Schur decomposition ([`schur`](#LinearAlgebra.schur)) to compute the cube root.
**Examples**
```julia-repl
julia> A = [0.927524 -0.15857; -1.3677 -1.01172]
2×2 Matrix{Float64}:
  0.927524  -0.15857
 -1.3677    -1.01172

julia> T = cbrt(A)
2×2 Matrix{Float64}:
  0.910077  -0.151019
 -1.30257   -0.936818

julia> T*T*T ≈ A
true
```
```julia
cos(A::AbstractMatrix)
```
Compute the matrix cosine of a square matrix `A`.
If `A` is symmetric or Hermitian, its eigendecomposition ([`eigen`](#LinearAlgebra.eigen)) is used to compute the cosine. Otherwise, the cosine is determined by calling [`exp`](../../base/math/#Base.exp-Tuple%7BFloat64%7D).
**Examples**
```julia-repl
julia> cos(fill(1.0, (2,2)))
2×2 Matrix{Float64}:
  0.291927  -0.708073
 -0.708073   0.291927
```
```julia
sin(A::AbstractMatrix)
```
Compute the matrix sine of a square matrix `A`.


## [Standard functions](#Standard-functions)
If `A` is symmetric or Hermitian, its eigendecomposition ([`eigen`](#LinearAlgebra.eigen)) is used to compute the sine. Otherwise, the sine is determined by calling [`exp`](../../base/math/#Base.exp-Tuple%7BFloat64%7D).
**Examples**
```julia-repl
julia> sin(fill(1.0, (2,2)))
2×2 Matrix{Float64}:
 0.454649  0.454649
 0.454649  0.454649
```
```julia
sincos(A::AbstractMatrix)
```
Compute the matrix sine and cosine of a square matrix `A`.
**Examples**
```julia-repl
julia> S, C = sincos(fill(1.0, (2,2)));

julia> S
2×2 Matrix{Float64}:
 0.454649  0.454649
 0.454649  0.454649

julia> C
2×2 Matrix{Float64}:
  0.291927  -0.708073
 -0.708073   0.291927
```
```julia
tan(A::AbstractMatrix)
```
Compute the matrix tangent of a square matrix `A`.
If `A` is symmetric or Hermitian, its eigendecomposition ([`eigen`](#LinearAlgebra.eigen)) is used to compute the tangent. Otherwise, the tangent is determined by calling [`exp`](../../base/math/#Base.exp-Tuple%7BFloat64%7D).
**Examples**
```julia-repl
julia> tan(fill(1.0, (2,2)))
2×2 Matrix{Float64}:
 -1.09252  -1.09252
 -1.09252  -1.09252
```
```julia
sec(A::AbstractMatrix)
```
Compute the matrix secant of a square matrix `A`.
```julia
csc(A::AbstractMatrix)
```
Compute the matrix cosecant of a square matrix `A`.
```julia
cot(A::AbstractMatrix)
```
Compute the matrix cotangent of a square matrix `A`.
```julia
cosh(A::AbstractMatrix)
```
Compute the matrix hyperbolic cosine of a square matrix `A`.
```julia
sinh(A::AbstractMatrix)
```
Compute the matrix hyperbolic sine of a square matrix `A`.


## [Standard functions](#Standard-functions)
```julia
tanh(A::AbstractMatrix)
```
Compute the matrix hyperbolic tangent of a square matrix `A`.
```julia
sech(A::AbstractMatrix)
```
Compute the matrix hyperbolic secant of square matrix `A`.
```julia
csch(A::AbstractMatrix)
```
Compute the matrix hyperbolic cosecant of square matrix `A`.
```julia
coth(A::AbstractMatrix)
```
Compute the matrix hyperbolic cotangent of square matrix `A`.
```julia
acos(A::AbstractMatrix)
```
Compute the inverse matrix cosine of a square matrix `A`.
If `A` is symmetric or Hermitian, its eigendecomposition ([`eigen`](#LinearAlgebra.eigen)) is used to compute the inverse cosine. Otherwise, the inverse cosine is determined by using [`log`](../../base/math/#Base.log-Tuple%7BNumber%7D) and [`sqrt`](../../base/math/#Base.sqrt-Tuple%7BNumber%7D). For the theory and logarithmic formulas used to compute this function, see <sup>[[AH16_1\]](#footnote-AH16_1)</sup>.
**Examples**
```julia-repl
julia> acos(cos([0.5 0.1; -0.2 0.3]))
2×2 Matrix{ComplexF64}:
  0.5-8.32667e-17im  0.1+0.0im
 -0.2+2.63678e-16im  0.3-3.46945e-16im
```
```julia
asin(A::AbstractMatrix)
```
Compute the inverse matrix sine of a square matrix `A`.


## [Standard functions](#Standard-functions)
If `A` is symmetric or Hermitian, its eigendecomposition ([`eigen`](#LinearAlgebra.eigen)) is used to compute the inverse sine. Otherwise, the inverse sine is determined by using [`log`](../../base/math/#Base.log-Tuple%7BNumber%7D) and [`sqrt`](../../base/math/#Base.sqrt-Tuple%7BNumber%7D). For the theory and logarithmic formulas used to compute this function, see [[AH16_2\]](#footnote-AH16_2).
**Examples**
```julia-repl
julia> asin(sin([0.5 0.1; -0.2 0.3]))
2×2 Matrix{ComplexF64}:
  0.5-4.16334e-17im  0.1-5.55112e-17im
 -0.2+9.71445e-17im  0.3-1.249e-16im
```
```julia
atan(A::AbstractMatrix)
```
Compute the inverse matrix tangent of a square matrix `A`.
If `A` is symmetric or Hermitian, its eigendecomposition ([`eigen`](#LinearAlgebra.eigen)) is used to compute the inverse tangent. Otherwise, the inverse tangent is determined by using [`log`](../../base/math/#Base.log-Tuple%7BNumber%7D). For the theory and logarithmic formulas used to compute this function, see [[AH16_3\]](#footnote-AH16_3).
**Examples**
```julia-repl
julia> atan(tan([0.5 0.1; -0.2 0.3]))
2×2 Matrix{ComplexF64}:
  0.5+1.38778e-17im  0.1-2.77556e-17im
 -0.2+6.93889e-17im  0.3-4.16334e-17im
```
```julia
asec(A::AbstractMatrix)
```
Compute the inverse matrix secant of `A`.
```julia
acsc(A::AbstractMatrix)
```
Compute the inverse matrix cosecant of `A`.
```julia
acot(A::AbstractMatrix)
```
Compute the inverse matrix cotangent of `A`.
```julia
acosh(A::AbstractMatrix)
```


## [Standard functions](#Standard-functions)
Compute the inverse hyperbolic matrix cosine of a square matrix `A`. For the theory and logarithmic formulas used to compute this function, see [[AH16_4\]](#footnote-AH16_4).
```julia
asinh(A::AbstractMatrix)
```
Compute the inverse hyperbolic matrix sine of a square matrix `A`. For the theory and logarithmic formulas used to compute this function, see [[AH16_5\]](#footnote-AH16_5).
```julia
atanh(A::AbstractMatrix)
```
Compute the inverse hyperbolic matrix tangent of a square matrix `A`. For the theory and logarithmic formulas used to compute this function, see [[AH16_6\]](#footnote-AH16_6).
```julia
asech(A::AbstractMatrix)
```
Compute the inverse matrix hyperbolic secant of `A`.
```julia
acsch(A::AbstractMatrix)
```
Compute the inverse matrix hyperbolic cosecant of `A`.
```julia
acoth(A::AbstractMatrix)
```
Compute the inverse matrix hyperbolic cotangent of `A`.
```julia
lyap(A, C)
```
Computes the solution `X` to the continuous Lyapunov equation `AX + XA' + C = 0`, where no eigenvalue of `A` has a zero real part and no two eigenvalues are negative complex conjugates of each other.
**Examples**
```julia-repl
julia> A = [3. 4.; 5. 6]
2×2 Matrix{Float64}:
 3.0  4.0
 5.0  6.0

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

julia> X = lyap(A, B)
2×2 Matrix{Float64}:
  0.5  -0.5
 -0.5   0.25

julia> A*X + X*A' ≈ -B
true
```
```julia
sylvester(A, B, C)
```


## [Standard functions](#Standard-functions)
Computes the solution `X` to the Sylvester equation `AX + XB + C = 0`, where `A`, `B` and `C` have compatible dimensions and `A` and `-B` have no eigenvalues with equal real part.
**Examples**
```julia-repl
julia> A = [3. 4.; 5. 6]
2×2 Matrix{Float64}:
 3.0  4.0
 5.0  6.0

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

julia> C = [1. 2.; -2. 1]
2×2 Matrix{Float64}:
  1.0  2.0
 -2.0  1.0

julia> X = sylvester(A, B, C)
2×2 Matrix{Float64}:
 -4.46667   1.93333
  3.73333  -1.8

julia> A*X + X*B ≈ -C
true
```
```julia
issuccess(F::Factorization)
```
Test that a factorization of a matrix succeeded.
`issuccess(::CholeskyPivoted)` requires Julia 1.6 or later.
**Examples**
```julia-repl
julia> F = cholesky([1 0; 0 1]);

julia> issuccess(F)
true
```
```julia
issuccess(F::LU; allowsingular = false)
```
Test that the LU factorization of a matrix succeeded. By default a factorization that produces a valid but rank-deficient U factor is considered a failure. This can be changed by passing `allowsingular = true`.
The `allowsingular` keyword argument was added in Julia 1.11.
**Examples**
```julia-repl
julia> F = lu([1 2; 1 2], check = false);

julia> issuccess(F)
false

julia> issuccess(F, allowsingular = true)
true
```
```julia
issymmetric(A) -> Bool
```
Test whether a matrix is symmetric.
**Examples**
```julia-repl
julia> a = [1 2; 2 -1]
2×2 Matrix{Int64}:
 1   2
 2  -1

julia> issymmetric(a)
true

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

julia> issymmetric(b)
false
```


## [Standard functions](#Standard-functions)
```julia
isposdef(A) -> Bool
```
Test whether a matrix is positive definite (and Hermitian) by trying to perform a Cholesky factorization of `A`.
See also [`isposdef!`](#LinearAlgebra.isposdef!), [`cholesky`](#LinearAlgebra.cholesky).
**Examples**
```julia-repl
julia> A = [1 2; 2 50]
2×2 Matrix{Int64}:
 1   2
 2  50

julia> isposdef(A)
true
```
```julia
isposdef!(A) -> Bool
```
Test whether a matrix is positive definite (and Hermitian) by trying to perform a Cholesky factorization of `A`, overwriting `A` in the process. See also [`isposdef`](#LinearAlgebra.isposdef).
**Examples**
```julia-repl
julia> A = [1. 2.; 2. 50.];

julia> isposdef!(A)
true

julia> A
2×2 Matrix{Float64}:
 1.0  2.0
 2.0  6.78233
```
```julia
istril(A::AbstractMatrix, k::Integer = 0) -> Bool
```
Test whether `A` is lower triangular starting from the `k`th superdiagonal.
**Examples**
```julia-repl
julia> a = [1 2; 2 -1]
2×2 Matrix{Int64}:
 1   2
 2  -1

julia> istril(a)
false

julia> istril(a, 1)
true

julia> c = [1 1 0; 1 1 1; 1 1 1]
3×3 Matrix{Int64}:
 1  1  0
 1  1  1
 1  1  1

julia> istril(c)
false

julia> istril(c, 1)
true
```
```julia
istriu(A::AbstractMatrix, k::Integer = 0) -> Bool
```
Test whether `A` is upper triangular starting from the `k`th superdiagonal.
**Examples**
```julia-repl
julia> a = [1 2; 2 -1]
2×2 Matrix{Int64}:
 1   2
 2  -1

julia> istriu(a)
false

julia> istriu(a, -1)
true

julia> c = [1 1 1; 1 1 1; 0 1 1]
3×3 Matrix{Int64}:
 1  1  1
 1  1  1
 0  1  1

julia> istriu(c)
false

julia> istriu(c, -1)
true
```


## [Standard functions](#Standard-functions)
```julia
isdiag(A) -> Bool
```
Test whether a matrix is diagonal in the sense that `iszero(A[i,j])` is true unless `i == j`. Note that it is not necessary for `A` to be square; if you would also like to check that, you need to check that `size(A, 1) == size(A, 2)`.
**Examples**
```julia-repl
julia> a = [1 2; 2 -1]
2×2 Matrix{Int64}:
 1   2
 2  -1

julia> isdiag(a)
false

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

julia> isdiag(b)
true

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

julia> isdiag(c)
true

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

julia> isdiag(d)
false
```
```julia
ishermitian(A) -> Bool
```
Test whether a matrix is Hermitian.
**Examples**
```julia-repl
julia> a = [1 2; 2 -1]
2×2 Matrix{Int64}:
 1   2
 2  -1

julia> ishermitian(a)
true

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

julia> ishermitian(b)
true
```
```julia
transpose(A)
```
Lazy transpose. Mutating the returned object should appropriately mutate `A`. Often, but not always, yields `Transpose(A)`, where `Transpose` is a lazy transpose wrapper. Note that this operation is recursive.
This operation is intended for linear algebra usage - for general data manipulation see [`permutedims`](../../base/arrays/#Base.permutedims), which is non-recursive.
**Examples**


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

julia> B = transpose(A)
2×2 transpose(::Matrix{Int64}) with eltype Int64:
 3  0
 2  0

julia> B isa Transpose
true

julia> transpose(B) === A # the transpose of a transpose unwraps the parent
true

julia> Transpose(B) # however, the constructor always wraps its argument
2×2 transpose(transpose(::Matrix{Int64})) with eltype Int64:
 3  2
 0  0

julia> B[1,2] = 4; # modifying B will modify A automatically

julia> A
2×2 Matrix{Int64}:
 3  2
 4  0
```
For complex matrices, the `adjoint` operation is equivalent to a conjugate-transpose.
```julia-repl
julia> A = reshape([Complex(x, x) for x in 1:4], 2, 2)
2×2 Matrix{Complex{Int64}}:
 1+1im  3+3im
 2+2im  4+4im

julia> adjoint(A) == conj(transpose(A))
true
```
The `transpose` of an `AbstractVector` is a row-vector:
```julia-repl
julia> v = [1,2,3]
3-element Vector{Int64}:
 1
 2
 3

julia> transpose(v) # returns a row-vector
1×3 transpose(::Vector{Int64}) with eltype Int64:
 1  2  3

julia> transpose(v) * v # compute the dot product
14
```
For a matrix of matrices, the individual blocks are recursively operated on:
```julia-repl
julia> C = [1 3; 2 4]
2×2 Matrix{Int64}:
 1  3
 2  4

julia> D = reshape([C, 2C, 3C, 4C], 2, 2) # construct a block matrix
2×2 Matrix{Matrix{Int64}}:
 [1 3; 2 4]  [3 9; 6 12]
 [2 6; 4 8]  [4 12; 8 16]

julia> transpose(D) # blocks are recursively transposed
2×2 transpose(::Matrix{Matrix{Int64}}) with eltype Transpose{Int64, Matrix{Int64}}:
 [1 2; 3 4]   [2 4; 6 8]
 [3 6; 9 12]  [4 8; 12 16]
```


## [Standard functions](#Standard-functions)
```julia
transpose(F::Factorization)
```
Lazy transpose of the factorization `F`. By default, returns a [`TransposeFactorization`](#LinearAlgebra.TransposeFactorization), except for `Factorization`s with real `eltype`, in which case returns an [`AdjointFactorization`](#LinearAlgebra.AdjointFactorization).
```julia
transpose!(X::AbstractSparseMatrixCSC{Tv,Ti}, A::AbstractSparseMatrixCSC{Tv,Ti}) where {Tv,Ti}
```
Transpose the matrix `A` and stores it in the matrix `X`. `size(X)` must be equal to `size(transpose(A))`. No additional memory is allocated other than resizing the rowval and nzval of `X`, if needed.
See `halfperm!`
```julia
transpose!(dest,src)
```
Transpose array `src` and store the result in the preallocated array `dest`, which should have a size corresponding to `(size(src,2),size(src,1))`. No in-place transposition is supported and unexpected results will happen if `src` and `dest` have overlapping memory regions.
**Examples**
```julia-repl
julia> A = [3+2im 9+2im; 8+7im  4+6im]
2×2 Matrix{Complex{Int64}}:
 3+2im  9+2im
 8+7im  4+6im

julia> B = zeros(Complex{Int64}, 2, 2)
2×2 Matrix{Complex{Int64}}:
 0+0im  0+0im
 0+0im  0+0im

julia> transpose!(B, A);

julia> B
2×2 Matrix{Complex{Int64}}:
 3+2im  8+7im
 9+2im  4+6im

julia> A
2×2 Matrix{Complex{Int64}}:
 3+2im  9+2im
 8+7im  4+6im
```
```julia
Transpose
```


## [Standard functions](#Standard-functions)
Lazy wrapper type for a transpose view of the underlying linear algebra object, usually an `AbstractVector`/`AbstractMatrix`. Usually, the `Transpose` constructor should not be called directly, use [`transpose`](#Base.transpose) instead. To materialize the view use [`copy`](../../base/base/#Base.copy).
This type is intended for linear algebra usage - for general data manipulation see [`permutedims`](../../base/arrays/#Base.permutedims).
**Examples**
```julia-repl
julia> A = [2 3; 0 0]
2×2 Matrix{Int64}:
 2  3
 0  0

julia> Transpose(A)
2×2 transpose(::Matrix{Int64}) with eltype Int64:
 2  0
 3  0
```
```julia
TransposeFactorization
```
Lazy wrapper type for the transpose of the underlying `Factorization` object. Usually, the `TransposeFactorization` constructor should not be called directly, use [`transpose(:: Factorization)`](#Base.transpose) instead.
```julia
A'
adjoint(A)
```
Lazy adjoint (conjugate transposition). Note that `adjoint` is applied recursively to elements.
For number types, `adjoint` returns the complex conjugate, and therefore it is equivalent to the identity function for real numbers.
This operation is intended for linear algebra usage - for general data manipulation see [`permutedims`](../../base/arrays/#Base.permutedims).
**Examples**


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

julia> B = A' # equivalently adjoint(A)
2×2 adjoint(::Matrix{Complex{Int64}}) with eltype Complex{Int64}:
 3-2im  0+0im
 9-2im  0+0im

julia> B isa Adjoint
true

julia> adjoint(B) === A # the adjoint of an adjoint unwraps the parent
true

julia> Adjoint(B) # however, the constructor always wraps its argument
2×2 adjoint(adjoint(::Matrix{Complex{Int64}})) with eltype Complex{Int64}:
 3+2im  9+2im
 0+0im  0+0im

julia> B[1,2] = 4 + 5im; # modifying B will modify A automatically

julia> A
2×2 Matrix{Complex{Int64}}:
 3+2im  9+2im
 4-5im  0+0im
```
For real matrices, the `adjoint` operation is equivalent to a `transpose`.
```julia-repl
julia> A = reshape([x for x in 1:4], 2, 2)
2×2 Matrix{Int64}:
 1  3
 2  4

julia> A'
2×2 adjoint(::Matrix{Int64}) with eltype Int64:
 1  2
 3  4

julia> adjoint(A) == transpose(A)
true
```
The adjoint of an `AbstractVector` is a row-vector:
```julia-repl
julia> x = [3, 4im]
2-element Vector{Complex{Int64}}:
 3 + 0im
 0 + 4im

julia> x'
1×2 adjoint(::Vector{Complex{Int64}}) with eltype Complex{Int64}:
 3+0im  0-4im

julia> x'x # compute the dot product, equivalently x' * x
25 + 0im
```
For a matrix of matrices, the individual blocks are recursively operated on:


## [Standard functions](#Standard-functions)
```julia-repl
julia> A = reshape([x + im*x for x in 1:4], 2, 2)
2×2 Matrix{Complex{Int64}}:
 1+1im  3+3im
 2+2im  4+4im

julia> C = reshape([A, 2A, 3A, 4A], 2, 2)
2×2 Matrix{Matrix{Complex{Int64}}}:
 [1+1im 3+3im; 2+2im 4+4im]  [3+3im 9+9im; 6+6im 12+12im]
 [2+2im 6+6im; 4+4im 8+8im]  [4+4im 12+12im; 8+8im 16+16im]

julia> C'
2×2 adjoint(::Matrix{Matrix{Complex{Int64}}}) with eltype Adjoint{Complex{Int64}, Matrix{Complex{Int64}}}:
 [1-1im 2-2im; 3-3im 4-4im]    [2-2im 4-4im; 6-6im 8-8im]
 [3-3im 6-6im; 9-9im 12-12im]  [4-4im 8-8im; 12-12im 16-16im]
```
```julia
adjoint(F::Factorization)
```
Lazy adjoint of the factorization `F`. By default, returns an [`AdjointFactorization`](#LinearAlgebra.AdjointFactorization) wrapper.
```julia
adjoint!(X::AbstractSparseMatrixCSC{Tv,Ti}, A::AbstractSparseMatrixCSC{Tv,Ti}) where {Tv,Ti}
```
Transpose the matrix `A` and stores the adjoint of the elements in the matrix `X`. `size(X)` must be equal to `size(transpose(A))`. No additional memory is allocated other than resizing the rowval and nzval of `X`, if needed.
See `halfperm!`
```julia
adjoint!(dest,src)
```
Conjugate transpose array `src` and store the result in the preallocated array `dest`, which should have a size corresponding to `(size(src,2),size(src,1))`. No in-place transposition is supported and unexpected results will happen if `src` and `dest` have overlapping memory regions.
**Examples**


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

julia> B = zeros(Complex{Int64}, 2, 2)
2×2 Matrix{Complex{Int64}}:
 0+0im  0+0im
 0+0im  0+0im

julia> adjoint!(B, A);

julia> B
2×2 Matrix{Complex{Int64}}:
 3-2im  8-7im
 9-2im  4-6im

julia> A
2×2 Matrix{Complex{Int64}}:
 3+2im  9+2im
 8+7im  4+6im
```
```julia
Adjoint
```
Lazy wrapper type for an adjoint view of the underlying linear algebra object, usually an `AbstractVector`/`AbstractMatrix`. Usually, the `Adjoint` constructor should not be called directly, use [`adjoint`](#Base.adjoint) instead. To materialize the view use [`copy`](../../base/base/#Base.copy).
This type is intended for linear algebra usage - for general data manipulation see [`permutedims`](../../base/arrays/#Base.permutedims).
**Examples**
```julia-repl
julia> A = [3+2im 9+2im; 0 0]
2×2 Matrix{Complex{Int64}}:
 3+2im  9+2im
 0+0im  0+0im

julia> Adjoint(A)
2×2 adjoint(::Matrix{Complex{Int64}}) with eltype Complex{Int64}:
 3-2im  0+0im
 9-2im  0+0im
```
```julia
AdjointFactorization
```
Lazy wrapper type for the adjoint of the underlying `Factorization` object. Usually, the `AdjointFactorization` constructor should not be called directly, use [`adjoint(:: Factorization)`](#Base.adjoint) instead.
```julia
copy(A::Transpose)
copy(A::Adjoint)
```
Eagerly evaluate the lazy matrix transpose/adjoint. Note that the transposition is applied recursively to elements.


## [Standard functions](#Standard-functions)
This operation is intended for linear algebra usage - for general data manipulation see [`permutedims`](../../base/arrays/#Base.permutedims), which is non-recursive.
**Examples**
```julia-repl
julia> A = [1 2im; -3im 4]
2×2 Matrix{Complex{Int64}}:
 1+0im  0+2im
 0-3im  4+0im

julia> T = transpose(A)
2×2 transpose(::Matrix{Complex{Int64}}) with eltype Complex{Int64}:
 1+0im  0-3im
 0+2im  4+0im

julia> copy(T)
2×2 Matrix{Complex{Int64}}:
 1+0im  0-3im
 0+2im  4+0im
```
```julia
stride1(A) -> Int
```
Return the distance between successive array elements in dimension 1 in units of element size.
**Examples**
```julia-repl
julia> A = [1,2,3,4]
4-element Vector{Int64}:
 1
 2
 3
 4

julia> LinearAlgebra.stride1(A)
1

julia> B = view(A, 2:2:4)
2-element view(::Vector{Int64}, 2:2:4) with eltype Int64:
 2
 4

julia> LinearAlgebra.stride1(B)
2
```
```julia
LinearAlgebra.checksquare(A)
```
Check that a matrix is square, then return its common dimension. For multiple arguments, return a vector.
**Examples**
```julia-repl
julia> A = fill(1, (4,4)); B = fill(1, (5,5));

julia> LinearAlgebra.checksquare(A, B)
2-element Vector{Int64}:
 4
 5
```
```julia
LinearAlgebra.peakflops(n::Integer=4096; eltype::DataType=Float64, ntrials::Integer=3, parallel::Bool=false)
```


## [Standard functions](#Standard-functions)
`peakflops` computes the peak flop rate of the computer by using double precision [`gemm!`](#LinearAlgebra.BLAS.gemm!). By default, if no arguments are specified, it multiplies two `Float64` matrices of size `n x n`, where `n = 4096`. If the underlying BLAS is using multiple threads, higher flop rates are realized. The number of BLAS threads can be set with [`BLAS.set_num_threads(n)`](#LinearAlgebra.BLAS.set_num_threads).
If the keyword argument `eltype` is provided, `peakflops` will construct matrices with elements of type `eltype` for calculating the peak flop rate.
By default, `peakflops` will use the best timing from 3 trials. If the `ntrials` keyword argument is provided, `peakflops` will use those many trials for picking the best timing.
If the keyword argument `parallel` is set to `true`, `peakflops` is run in parallel on all the worker processors. The flop rate of the entire parallel computer is returned. When running in parallel, only 1 BLAS thread is used. The argument `n` still refers to the size of the problem that is solved on each processor.
This function requires at least Julia 1.1. In Julia 1.0 it is available from the standard library `InteractiveUtils`.
```julia
hermitianpart(A::AbstractMatrix, uplo::Symbol=:U) -> Hermitian
```


## [Standard functions](#Standard-functions)
Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`, as a [`Hermitian`](#LinearAlgebra.Hermitian) matrix. For real matrices `A`, this is also known as the symmetric part of `A`; it is also sometimes called the "operator real part". The optional argument `uplo` controls the corresponding argument of the [`Hermitian`](#LinearAlgebra.Hermitian) view. For real matrices, the latter is equivalent to a [`Symmetric`](#LinearAlgebra.Symmetric) view.
See also [`hermitianpart!`](#LinearAlgebra.hermitianpart!) for the corresponding in-place operation.
This function requires Julia 1.10 or later.
```julia
hermitianpart!(A::AbstractMatrix, uplo::Symbol=:U) -> Hermitian
```
Overwrite the square matrix `A` in-place with its Hermitian part `(A + A') / 2`, and return [`Hermitian(A, uplo)`](#LinearAlgebra.Hermitian). For real matrices `A`, this is also known as the symmetric part of `A`.
See also [`hermitianpart`](#LinearAlgebra.hermitianpart) for the corresponding out-of-place operation.
This function requires Julia 1.10 or later.
```julia
copy_adjoint!(B::AbstractVecOrMat, ir_dest::AbstractRange{Int}, jr_dest::AbstractRange{Int},
                A::AbstractVecOrMat, ir_src::AbstractRange{Int}, jr_src::AbstractRange{Int}) -> B
```
Efficiently copy elements of matrix `A` to `B` with adjunction as follows:
```julia
B[ir_dest, jr_dest] = adjoint(A)[jr_src, ir_src]
```


## [Standard functions](#Standard-functions)
The elements `B[ir_dest, jr_dest]` are overwritten. Furthermore, the index range parameters must satisfy `length(ir_dest) == length(jr_src)` and `length(jr_dest) == length(ir_src)`.
```julia
copy_transpose!(B::AbstractVecOrMat, ir_dest::AbstractRange{Int}, jr_dest::AbstractRange{Int},
                A::AbstractVecOrMat, ir_src::AbstractRange{Int}, jr_src::AbstractRange{Int}) -> B
```
Efficiently copy elements of matrix `A` to `B` with transposition as follows:
```julia
B[ir_dest, jr_dest] = transpose(A)[jr_src, ir_src]
```
The elements `B[ir_dest, jr_dest]` are overwritten. Furthermore, the index range parameters must satisfy `length(ir_dest) == length(jr_src)` and `length(jr_dest) == length(ir_src)`.
```julia
copy_transpose!(B::AbstractMatrix, ir_dest::AbstractUnitRange, jr_dest::AbstractUnitRange,
                tM::AbstractChar,
                M::AbstractVecOrMat, ir_src::AbstractUnitRange, jr_src::AbstractUnitRange) -> B
```
Efficiently copy elements of matrix `M` to `B` conditioned on the character parameter `tM` as follows:
|  `tM` | Destination           | Source                         |
|------:|:----------------------|:-------------------------------|
| `'N'` | `B[ir_dest, jr_dest]` | `transpose(M)[jr_src, ir_src]` |
| `'T'` | `B[ir_dest, jr_dest]` | `M[jr_src, ir_src]`            |
| `'C'` | `B[ir_dest, jr_dest]` | `conj(M)[jr_src, ir_src]`      |


## [Standard functions](#Standard-functions)
The elements `B[ir_dest, jr_dest]` are overwritten. Furthermore, the index range parameters must satisfy `length(ir_dest) == length(jr_src)` and `length(jr_dest) == length(ir_src)`.
See also [`copyto!`](../../base/c/#Base.copyto!) and [`copy_adjoint!`](#LinearAlgebra.copy_adjoint!).


## [Low-level matrix operations](#Low-level-matrix-operations)
In many cases there are in-place versions of matrix operations that allow you to supply a pre-allocated output vector or matrix. This is useful when optimizing critical code in order to avoid the overhead of repeated allocations. These in-place operations are suffixed with `!` below (e.g. `mul!`) according to the usual Julia convention.
```julia
mul!(Y, A, B) -> Y
```
Calculates the matrix-matrix or matrix-vector product $A B$ and stores the result in `Y`, overwriting the existing value of `Y`. Note that `Y` must not be aliased with either `A` or `B`.
**Examples**
```julia-repl
julia> A = [1.0 2.0; 3.0 4.0]; B = [1.0 1.0; 1.0 1.0]; Y = similar(B);

julia> mul!(Y, A, B) === Y
true

julia> Y
2×2 Matrix{Float64}:
 3.0  3.0
 7.0  7.0

julia> Y == A * B
true
```
**Implementation**
For custom matrix and vector types, it is recommended to implement 5-argument `mul!` rather than implementing 3-argument `mul!` directly if possible.
```julia
mul!(C, A, B, α, β) -> C
```
Combined inplace matrix-matrix or matrix-vector multiply-add $A B α + C β$. The result is stored in `C` by overwriting it. Note that `C` must not be aliased with either `A` or `B`.
Five-argument `mul!` requires at least Julia 1.3.
**Examples**


## [Low-level matrix operations](#Low-level-matrix-operations)
```julia-repl
julia> A = [1.0 2.0; 3.0 4.0]; B = [1.0 1.0; 1.0 1.0]; C = [1.0 2.0; 3.0 4.0];

julia> α, β = 100.0, 10.0;

julia> mul!(C, A, B, α, β) === C
true

julia> C
2×2 Matrix{Float64}:
 310.0  320.0
 730.0  740.0

julia> C_original = [1.0 2.0; 3.0 4.0]; # A copy of the original value of C

julia> C == A * B * α + C_original * β
true
```
```julia
lmul!(a::Number, B::AbstractArray)
```
Scale an array `B` by a scalar `a` overwriting `B` in-place. Use [`rmul!`](#LinearAlgebra.rmul!) to multiply scalar from right. The scaling operation respects the semantics of the multiplication [`*`](../../base/math/#Base.:*-Tuple%7BAny,%20Vararg%7BAny%7D%7D) between `a` and an element of `B`. In particular, this also applies to multiplication involving non-finite numbers such as `NaN` and `±Inf`.
Prior to Julia 1.1, `NaN` and `±Inf` entries in `B` were treated inconsistently.
**Examples**
```julia-repl
julia> B = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> lmul!(2, B)
2×2 Matrix{Int64}:
 2  4
 6  8

julia> lmul!(0.0, [Inf])
1-element Vector{Float64}:
 NaN
```
```julia
lmul!(A, B)
```
Calculate the matrix-matrix product $AB$, overwriting `B`, and return the result. Here, `A` must be of special matrix type, like, e.g., [`Diagonal`](#LinearAlgebra.Diagonal), [`UpperTriangular`](#LinearAlgebra.UpperTriangular) or [`LowerTriangular`](#LinearAlgebra.LowerTriangular), or of some orthogonal type, see [`QR`](#LinearAlgebra.QR).
**Examples**


## [Low-level matrix operations](#Low-level-matrix-operations)
```julia-repl
julia> B = [0 1; 1 0];

julia> A = UpperTriangular([1 2; 0 3]);

julia> lmul!(A, B);

julia> B
2×2 Matrix{Int64}:
 2  1
 3  0

julia> B = [1.0 2.0; 3.0 4.0];

julia> F = qr([0 1; -1 0]);

julia> lmul!(F.Q, B)
2×2 Matrix{Float64}:
 3.0  4.0
 1.0  2.0
```
```julia
rmul!(A::AbstractArray, b::Number)
```
Scale an array `A` by a scalar `b` overwriting `A` in-place. Use [`lmul!`](#LinearAlgebra.lmul!) to multiply scalar from left. The scaling operation respects the semantics of the multiplication [`*`](../../base/math/#Base.:*-Tuple%7BAny,%20Vararg%7BAny%7D%7D) between an element of `A` and `b`. In particular, this also applies to multiplication involving non-finite numbers such as `NaN` and `±Inf`.
Prior to Julia 1.1, `NaN` and `±Inf` entries in `A` were treated inconsistently.
**Examples**
```julia-repl
julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> rmul!(A, 2)
2×2 Matrix{Int64}:
 2  4
 6  8

julia> rmul!([NaN], 0.0)
1-element Vector{Float64}:
 NaN
```
```julia
rmul!(A, B)
```
Calculate the matrix-matrix product $AB$, overwriting `A`, and return the result. Here, `B` must be of special matrix type, like, e.g., [`Diagonal`](#LinearAlgebra.Diagonal), [`UpperTriangular`](#LinearAlgebra.UpperTriangular) or [`LowerTriangular`](#LinearAlgebra.LowerTriangular), or of some orthogonal type, see [`QR`](#LinearAlgebra.QR).
**Examples**


## [Low-level matrix operations](#Low-level-matrix-operations)
```julia-repl
julia> A = [0 1; 1 0];

julia> B = UpperTriangular([1 2; 0 3]);

julia> rmul!(A, B);

julia> A
2×2 Matrix{Int64}:
 0  3
 1  2

julia> A = [1.0 2.0; 3.0 4.0];

julia> F = qr([0 1; -1 0]);

julia> rmul!(A, F.Q)
2×2 Matrix{Float64}:
 2.0  1.0
 4.0  3.0
```
```julia
ldiv!(Y, A, B) -> Y
```
Compute `A \ B` in-place and store the result in `Y`, returning the result.
The argument `A` should *not* be a matrix. Rather, instead of matrices it should be a factorization object (e.g. produced by [`factorize`](#LinearAlgebra.factorize) or [`cholesky`](#LinearAlgebra.cholesky)). The reason for this is that factorization itself is both expensive and typically allocates memory (although it can also be done in-place via, e.g., [`lu!`](#LinearAlgebra.lu!)), and performance-critical situations requiring `ldiv!` usually also require fine-grained control over the factorization of `A`.
Certain structured matrix types, such as `Diagonal` and `UpperTriangular`, are permitted, as these are already in a factorized form
**Examples**
```julia-repl
julia> A = [1 2.2 4; 3.1 0.2 3; 4 1 2];

julia> X = [1; 2.5; 3];

julia> Y = zero(X);

julia> ldiv!(Y, qr(A), X);

julia> Y ≈ A\X
true
```
```julia
ldiv!(A, B)
```
Compute `A \ B` in-place and overwriting `B` to store the result.


## [Low-level matrix operations](#Low-level-matrix-operations)
The argument `A` should *not* be a matrix. Rather, instead of matrices it should be a factorization object (e.g. produced by [`factorize`](#LinearAlgebra.factorize) or [`cholesky`](#LinearAlgebra.cholesky)). The reason for this is that factorization itself is both expensive and typically allocates memory (although it can also be done in-place via, e.g., [`lu!`](#LinearAlgebra.lu!)), and performance-critical situations requiring `ldiv!` usually also require fine-grained control over the factorization of `A`.
Certain structured matrix types, such as `Diagonal` and `UpperTriangular`, are permitted, as these are already in a factorized form
**Examples**
```julia-repl
julia> A = [1 2.2 4; 3.1 0.2 3; 4 1 2];

julia> X = [1; 2.5; 3];

julia> Y = copy(X);

julia> ldiv!(qr(A), X);

julia> X ≈ A\Y
true
```
```julia
ldiv!(a::Number, B::AbstractArray)
```
Divide each entry in an array `B` by a scalar `a` overwriting `B` in-place. Use [`rdiv!`](#LinearAlgebra.rdiv!) to divide scalar from right.
**Examples**
```julia-repl
julia> B = [1.0 2.0; 3.0 4.0]
2×2 Matrix{Float64}:
 1.0  2.0
 3.0  4.0

julia> ldiv!(2.0, B)
2×2 Matrix{Float64}:
 0.5  1.0
 1.5  2.0
```
```julia
ldiv!(A::Tridiagonal, B::AbstractVecOrMat) -> B
```
Compute `A \ B` in-place by Gaussian elimination with partial pivoting and store the result in `B`, returning the result. In the process, the diagonals of `A` are overwritten as well.
`ldiv!` for `Tridiagonal` left-hand sides requires at least Julia 1.11.
```julia
rdiv!(A, B)
```


## [Low-level matrix operations](#Low-level-matrix-operations)
Compute `A / B` in-place and overwriting `A` to store the result.
The argument `B` should *not* be a matrix. Rather, instead of matrices it should be a factorization object (e.g. produced by [`factorize`](#LinearAlgebra.factorize) or [`cholesky`](#LinearAlgebra.cholesky)). The reason for this is that factorization itself is both expensive and typically allocates memory (although it can also be done in-place via, e.g., [`lu!`](#LinearAlgebra.lu!)), and performance-critical situations requiring `rdiv!` usually also require fine-grained control over the factorization of `B`.
Certain structured matrix types, such as `Diagonal` and `UpperTriangular`, are permitted, as these are already in a factorized form
```julia
rdiv!(A::AbstractArray, b::Number)
```
Divide each entry in an array `A` by a scalar `b` overwriting `A` in-place. Use [`ldiv!`](#LinearAlgebra.ldiv!) to divide scalar from left.
**Examples**
```julia-repl
julia> A = [1.0 2.0; 3.0 4.0]
2×2 Matrix{Float64}:
 1.0  2.0
 3.0  4.0

julia> rdiv!(A, 2.0)
2×2 Matrix{Float64}:
 0.5  1.0
 1.5  2.0
```


## [BLAS functions](#BLAS-functions)
In Julia (as in much of scientific computation), dense linear-algebra operations are based on the [LAPACK library](https://www.netlib.org/lapack/), which in turn is built on top of basic linear-algebra building-blocks known as the [BLAS](https://www.netlib.org/blas/). There are highly optimized implementations of BLAS available for every computer architecture, and sometimes in high-performance linear algebra routines it is useful to call the BLAS functions directly.
`LinearAlgebra.BLAS` provides wrappers for some of the BLAS functions. Those BLAS functions that overwrite one of the input arrays have names ending in `'!'`. Usually, a BLAS function has four methods defined, for [`Float32`](../../base/numbers/#Core.Float32), [`Float64`](../../base/numbers/#Core.Float64), [`ComplexF32`](../../base/numbers/#Base.Complex), and [`ComplexF64`](../../base/numbers/#Base.Complex) arrays.


### [BLAS character arguments](#stdlib-blas-chars)
Many BLAS functions accept arguments that determine whether to transpose an argument (`trans`), which triangle of a matrix to reference (`uplo` or `ul`), whether the diagonal of a triangular matrix can be assumed to be all ones (`dA`) or which side of a matrix multiplication the input argument belongs on (`side`). The possibilities are:


#### [Multiplication order](#stdlib-blas-side)
| `side` | Meaning                                                             |
|:-------|:--------------------------------------------------------------------|
| `'L'`  | The argument goes on the *left* side of a matrix-matrix operation.  |
| `'R'`  | The argument goes on the *right* side of a matrix-matrix operation. |


#### [Triangle referencing](#stdlib-blas-uplo)
| `uplo`/`ul` | Meaning                                               |
|:------------|:------------------------------------------------------|
| `'U'`       | Only the *upper* triangle of the matrix will be used. |
| `'L'`       | Only the *lower* triangle of the matrix will be used. |


#### [Transposition operation](#stdlib-blas-trans)
| `trans`/`tX` | Meaning                                                 |
|:-------------|:--------------------------------------------------------|
| `'N'`        | The input matrix `X` is not transposed or conjugated.   |
| `'T'`        | The input matrix `X` will be transposed.                |
| `'C'`        | The input matrix `X` will be conjugated and transposed. |


#### [Unit diagonal](#stdlib-blas-diag)
| `diag`/`dX` | Meaning                                                   |
|:------------|:----------------------------------------------------------|
| `'N'`       | The diagonal values of the matrix `X` will be read.       |
| `'U'`       | The diagonal of the matrix `X` is assumed to be all ones. |
Interface to BLAS subroutines.
```julia
set_num_threads(n::Integer)
set_num_threads(::Nothing)
```
Set the number of threads the BLAS library should use equal to `n::Integer`.
Also accepts `nothing`, in which case julia tries to guess the default number of threads. Passing `nothing` is discouraged and mainly exists for historical reasons.
```julia
get_num_threads()
```
Get the number of threads the BLAS library is using.
`get_num_threads` requires at least Julia 1.6.
BLAS functions can be divided into three groups, also called three levels, depending on when they were first proposed, the type of input parameters, and the complexity of the operation.


### [Level 1 BLAS functions](#Level-1-BLAS-functions)
The level 1 BLAS functions were first proposed in \[(Lawson, 1979)\]\[Lawson-1979\] and define operations between scalars and vectors.
\[Lawson-1979\]: https://dl.acm.org/doi/10.1145/355841.355847
```julia
rot!(n, X, incx, Y, incy, c, s)
```
Overwrite `X` with `c*X + s*Y` and `Y` with `-conj(s)*X + c*Y` for the first `n` elements of array `X` with stride `incx` and first `n` elements of array `Y` with stride `incy`. Returns `X` and `Y`.
`rot!` requires at least Julia 1.5.
```julia
scal!(n, a, X, incx)
scal!(a, X)
```
Overwrite `X` with `a*X` for the first `n` elements of array `X` with stride `incx`. Returns `X`.
If `n` and `incx` are not provided, `length(X)` and `stride(X,1)` are used.
```julia
scal(n, a, X, incx)
scal(a, X)
```
Return `X` scaled by `a` for the first `n` elements of array `X` with stride `incx`.
If `n` and `incx` are not provided, `length(X)` and `stride(X,1)` are used.
```julia
blascopy!(n, X, incx, Y, incy)
```
Copy `n` elements of array `X` with stride `incx` to array `Y` with stride `incy`. Returns `Y`.
```julia
dot(n, X, incx, Y, incy)
```
Dot product of two vectors consisting of `n` elements of array `X` with stride `incx` and `n` elements of array `Y` with stride `incy`.
**Examples**
```julia-repl
julia> BLAS.dot(10, fill(1.0, 10), 1, fill(1.0, 20), 2)
10.0
```
```julia
dotu(n, X, incx, Y, incy)
```
Dot function for two complex vectors consisting of `n` elements of array `X` with stride `incx` and `n` elements of array `Y` with stride `incy`.
**Examples**


### [Level 1 BLAS functions](#Level-1-BLAS-functions)
```julia-repl
julia> BLAS.dotu(10, fill(1.0im, 10), 1, fill(1.0+im, 20), 2)
-10.0 + 10.0im
```
```julia
dotc(n, X, incx, U, incy)
```
Dot function for two complex vectors, consisting of `n` elements of array `X` with stride `incx` and `n` elements of array `U` with stride `incy`, conjugating the first vector.
**Examples**
```julia-repl
julia> BLAS.dotc(10, fill(1.0im, 10), 1, fill(1.0+im, 20), 2)
10.0 - 10.0im
```
```julia
nrm2(n, X, incx)
```
2-norm of a vector consisting of `n` elements of array `X` with stride `incx`.
**Examples**
```julia-repl
julia> BLAS.nrm2(4, fill(1.0, 8), 2)
2.0

julia> BLAS.nrm2(1, fill(1.0, 8), 2)
1.0
```
```julia
asum(n, X, incx)
```
Sum of the magnitudes of the first `n` elements of array `X` with stride `incx`.
For a real array, the magnitude is the absolute value. For a complex array, the magnitude is the sum of the absolute value of the real part and the absolute value of the imaginary part.
**Examples**
```julia-repl
julia> BLAS.asum(5, fill(1.0im, 10), 2)
5.0

julia> BLAS.asum(2, fill(1.0im, 10), 5)
2.0
```
```julia
iamax(n, dx, incx)
iamax(dx)
```
Find the index of the element of `dx` with the maximum absolute value. `n` is the length of `dx`, and `incx` is the stride. If `n` and `incx` are not provided, they assume default values of `n=length(dx)` and `incx=stride1(dx)`.


### [Level 2 BLAS functions](#Level-2-BLAS-functions)
The level 2 BLAS functions were published in \[(Dongarra, 1988)\]\[Dongarra-1988\], and define matrix-vector operations.
\[Dongarra-1988\]: https://dl.acm.org/doi/10.1145/42288.42291
**return a vector**
```julia
gemv!(tA, alpha, A, x, beta, y)
```
Update the vector `y` as `alpha*A*x + beta*y` or `alpha*A'x + beta*y` according to [`tA`](#stdlib-blas-trans). `alpha` and `beta` are scalars. Return the updated `y`.
```julia
gemv(tA, alpha, A, x)
```
Return `alpha*A*x` or `alpha*A'x` according to [`tA`](#stdlib-blas-trans). `alpha` is a scalar.
```julia
gemv(tA, A, x)
```
Return `A*x` or `A'x` according to [`tA`](#stdlib-blas-trans).
```julia
gbmv!(trans, m, kl, ku, alpha, A, x, beta, y)
```
Update vector `y` as `alpha*A*x + beta*y` or `alpha*A'*x + beta*y` according to [`trans`](#stdlib-blas-trans). The matrix `A` is a general band matrix of dimension `m` by `size(A,2)` with `kl` sub-diagonals and `ku` super-diagonals. `alpha` and `beta` are scalars. Return the updated `y`.
```julia
gbmv(trans, m, kl, ku, alpha, A, x)
```
Return `alpha*A*x` or `alpha*A'*x` according to [`trans`](#stdlib-blas-trans). The matrix `A` is a general band matrix of dimension `m` by `size(A,2)` with `kl` sub-diagonals and `ku` super-diagonals, and `alpha` is a scalar.
```julia
hemv!(ul, alpha, A, x, beta, y)
```
Update the vector `y` as `alpha*A*x + beta*y`. `A` is assumed to be Hermitian. Only the [`ul`](#stdlib-blas-uplo) triangle of `A` is used. `alpha` and `beta` are scalars. Return the updated `y`.
```julia
hemv(ul, alpha, A, x)
```


### [Level 2 BLAS functions](#Level-2-BLAS-functions)
Return `alpha*A*x`. `A` is assumed to be Hermitian. Only the [`ul`](#stdlib-blas-uplo) triangle of `A` is used. `alpha` is a scalar.
```julia
hemv(ul, A, x)
```
Return `A*x`. `A` is assumed to be Hermitian. Only the [`ul`](#stdlib-blas-uplo) triangle of `A` is used.
```julia
hpmv!(uplo, α, AP, x, β, y)
```
Update vector `y` as `α*A*x + β*y`, where `A` is a Hermitian matrix provided in packed format `AP`.
With `uplo = 'U'`, the array AP must contain the upper triangular part of the Hermitian matrix packed sequentially, column by column, so that `AP[1]` contains `A[1, 1]`, `AP[2]` and `AP[3]` contain `A[1, 2]` and `A[2, 2]` respectively, and so on.
With `uplo = 'L'`, the array AP must contain the lower triangular part of the Hermitian matrix packed sequentially, column by column, so that `AP[1]` contains `A[1, 1]`, `AP[2]` and `AP[3]` contain `A[2, 1]` and `A[3, 1]` respectively, and so on.
The scalar inputs `α` and `β` must be complex or real numbers.
The array inputs `x`, `y` and `AP` must all be of `ComplexF32` or `ComplexF64` type.
Return the updated `y`.
`hpmv!` requires at least Julia 1.5.
```julia
symv!(ul, alpha, A, x, beta, y)
```
Update the vector `y` as `alpha*A*x + beta*y`. `A` is assumed to be symmetric. Only the [`ul`](#stdlib-blas-uplo) triangle of `A` is used. `alpha` and `beta` are scalars. Return the updated `y`.
```julia
symv(ul, alpha, A, x)
```
Return `alpha*A*x`. `A` is assumed to be symmetric. Only the [`ul`](#stdlib-blas-uplo) triangle of `A` is used. `alpha` is a scalar.


### [Level 2 BLAS functions](#Level-2-BLAS-functions)
```julia
symv(ul, A, x)
```
Return `A*x`. `A` is assumed to be symmetric. Only the [`ul`](#stdlib-blas-uplo) triangle of `A` is used.
```julia
sbmv!(uplo, k, alpha, A, x, beta, y)
```
Update vector `y` as `alpha*A*x + beta*y` where `A` is a symmetric band matrix of order `size(A,2)` with `k` super-diagonals stored in the argument `A`. The storage layout for `A` is described the reference BLAS module, level-2 BLAS at <https://www.netlib.org/lapack/explore-html/>. Only the [`uplo`](#stdlib-blas-uplo) triangle of `A` is used.
Return the updated `y`.
```julia
sbmv(uplo, k, alpha, A, x)
```
Return `alpha*A*x` where `A` is a symmetric band matrix of order `size(A,2)` with `k` super-diagonals stored in the argument `A`. Only the [`uplo`](#stdlib-blas-uplo) triangle of `A` is used.
```julia
sbmv(uplo, k, A, x)
```
Return `A*x` where `A` is a symmetric band matrix of order `size(A,2)` with `k` super-diagonals stored in the argument `A`. Only the [`uplo`](#stdlib-blas-uplo) triangle of `A` is used.
```julia
spmv!(uplo, α, AP, x, β, y)
```
Update vector `y` as `α*A*x + β*y`, where `A` is a symmetric matrix provided in packed format `AP`.
With `uplo = 'U'`, the array AP must contain the upper triangular part of the symmetric matrix packed sequentially, column by column, so that `AP[1]` contains `A[1, 1]`, `AP[2]` and `AP[3]` contain `A[1, 2]` and `A[2, 2]` respectively, and so on.


### [Level 2 BLAS functions](#Level-2-BLAS-functions)
With `uplo = 'L'`, the array AP must contain the lower triangular part of the symmetric matrix packed sequentially, column by column, so that `AP[1]` contains `A[1, 1]`, `AP[2]` and `AP[3]` contain `A[2, 1]` and `A[3, 1]` respectively, and so on.
The scalar inputs `α` and `β` must be real.
The array inputs `x`, `y` and `AP` must all be of `Float32` or `Float64` type.
Return the updated `y`.
`spmv!` requires at least Julia 1.5.
```julia
trmv!(ul, tA, dA, A, b)
```
Return `op(A)*b`, where `op` is determined by [`tA`](#stdlib-blas-trans). Only the [`ul`](#stdlib-blas-uplo) triangle of `A` is used. [`dA`](#stdlib-blas-diag) determines if the diagonal values are read or are assumed to be all ones. The multiplication occurs in-place on `b`.
```julia
trmv(ul, tA, dA, A, b)
```
Return `op(A)*b`, where `op` is determined by [`tA`](#stdlib-blas-trans). Only the [`ul`](#stdlib-blas-uplo) triangle of `A` is used. [`dA`](#stdlib-blas-diag) determines if the diagonal values are read or are assumed to be all ones.
```julia
trsv!(ul, tA, dA, A, b)
```
Overwrite `b` with the solution to `A*x = b` or one of the other two variants determined by [`tA`](#stdlib-blas-trans) and [`ul`](#stdlib-blas-uplo). [`dA`](#stdlib-blas-diag) determines if the diagonal values are read or are assumed to be all ones. Return the updated `b`.
```julia
trsv(ul, tA, dA, A, b)
```


### [Level 2 BLAS functions](#Level-2-BLAS-functions)
Return the solution to `A*x = b` or one of the other two variants determined by [`tA`](#stdlib-blas-trans) and [`ul`](#stdlib-blas-uplo). [`dA`](#stdlib-blas-diag) determines if the diagonal values are read or are assumed to be all ones.
**return a matrix**
```julia
ger!(alpha, x, y, A)
```
Rank-1 update of the matrix `A` with vectors `x` and `y` as `alpha*x*y' + A`.
```julia
her!(uplo, alpha, x, A)
```
Methods for complex arrays only. Rank-1 update of the Hermitian matrix `A` with vector `x` as `alpha*x*x' + A`. [`uplo`](#stdlib-blas-uplo) controls which triangle of `A` is updated. Returns `A`.
```julia
syr!(uplo, alpha, x, A)
```
Rank-1 update of the symmetric matrix `A` with vector `x` as `alpha*x*transpose(x) + A`. [`uplo`](#stdlib-blas-uplo) controls which triangle of `A` is updated. Returns `A`.
```julia
spr!(uplo, α, x, AP)
```
Update matrix `A` as `A+α*x*x'`, where `A` is a symmetric matrix provided in packed format `AP` and `x` is a vector.
With `uplo = 'U'`, the array AP must contain the upper triangular part of the symmetric matrix packed sequentially, column by column, so that `AP[1]` contains `A[1, 1]`, `AP[2]` and `AP[3]` contain `A[1, 2]` and `A[2, 2]` respectively, and so on.
With `uplo = 'L'`, the array AP must contain the lower triangular part of the symmetric matrix packed sequentially, column by column, so that `AP[1]` contains `A[1, 1]`, `AP[2]` and `AP[3]` contain `A[2, 1]` and `A[3, 1]` respectively, and so on.
The scalar input `α` must be real.


### [Level 2 BLAS functions](#Level-2-BLAS-functions)
The array inputs `x` and `AP` must all be of `Float32` or `Float64` type. Return the updated `AP`.
`spr!` requires at least Julia 1.8.


### [Level 3 BLAS functions](#Level-3-BLAS-functions)
The level 3 BLAS functions were published in \[(Dongarra, 1990)\]\[Dongarra-1990\], and define matrix-matrix operations.
\[Dongarra-1990\]: https://dl.acm.org/doi/10.1145/77626.79170
```julia
gemmt!(uplo, tA, tB, alpha, A, B, beta, C)
```
Update the lower or upper triangular part specified by [`uplo`](#stdlib-blas-uplo) of `C` as `alpha*A*B + beta*C` or the other variants according to [`tA`](#stdlib-blas-trans) and `tB`. Return the updated `C`.
`gemmt!` requires at least Julia 1.11.
```julia
gemmt(uplo, tA, tB, alpha, A, B)
```
Return the lower or upper triangular part specified by [`uplo`](#stdlib-blas-uplo) of `A*B` or the other three variants according to [`tA`](#stdlib-blas-trans) and `tB`.
`gemmt` requires at least Julia 1.11.
```julia
gemmt(uplo, tA, tB, A, B)
```
Return the lower or upper triangular part specified by [`uplo`](#stdlib-blas-uplo) of `A*B` or the other three variants according to [`tA`](#stdlib-blas-trans) and `tB`.
`gemmt` requires at least Julia 1.11.
```julia
gemm!(tA, tB, alpha, A, B, beta, C)
```
Update `C` as `alpha*A*B + beta*C` or the other three variants according to [`tA`](#stdlib-blas-trans) and `tB`. Return the updated `C`.
```julia
gemm(tA, tB, alpha, A, B)
```
Return `alpha*A*B` or the other three variants according to [`tA`](#stdlib-blas-trans) and `tB`.
```julia
gemm(tA, tB, A, B)
```
Return `A*B` or the other three variants according to [`tA`](#stdlib-blas-trans) and `tB`.
```julia
symm!(side, ul, alpha, A, B, beta, C)
```


### [Level 3 BLAS functions](#Level-3-BLAS-functions)
Update `C` as `alpha*A*B + beta*C` or `alpha*B*A + beta*C` according to [`side`](#stdlib-blas-side). `A` is assumed to be symmetric. Only the [`ul`](#stdlib-blas-uplo) triangle of `A` is used. Return the updated `C`.
```julia
symm(side, ul, alpha, A, B)
```
Return `alpha*A*B` or `alpha*B*A` according to [`side`](#stdlib-blas-side). `A` is assumed to be symmetric. Only the [`ul`](#stdlib-blas-uplo) triangle of `A` is used.
```julia
symm(side, ul, A, B)
```
Return `A*B` or `B*A` according to [`side`](#stdlib-blas-side). `A` is assumed to be symmetric. Only the [`ul`](#stdlib-blas-uplo) triangle of `A` is used.
```julia
hemm!(side, ul, alpha, A, B, beta, C)
```
Update `C` as `alpha*A*B + beta*C` or `alpha*B*A + beta*C` according to [`side`](#stdlib-blas-side). `A` is assumed to be Hermitian. Only the [`ul`](#stdlib-blas-uplo) triangle of `A` is used. Return the updated `C`.
```julia
hemm(side, ul, alpha, A, B)
```
Return `alpha*A*B` or `alpha*B*A` according to [`side`](#stdlib-blas-side). `A` is assumed to be Hermitian. Only the [`ul`](#stdlib-blas-uplo) triangle of `A` is used.
```julia
hemm(side, ul, A, B)
```
Return `A*B` or `B*A` according to [`side`](#stdlib-blas-side). `A` is assumed to be Hermitian. Only the [`ul`](#stdlib-blas-uplo) triangle of `A` is used.
```julia
syrk!(uplo, trans, alpha, A, beta, C)
```


### [Level 3 BLAS functions](#Level-3-BLAS-functions)
Rank-k update of the symmetric matrix `C` as `alpha*A*transpose(A) + beta*C` or `alpha*transpose(A)*A + beta*C` according to [`trans`](#stdlib-blas-trans). Only the [`uplo`](#stdlib-blas-uplo) triangle of `C` is used. Return `C`.
```julia
syrk(uplo, trans, alpha, A)
```
Return either the upper triangle or the lower triangle of `A`, according to [`uplo`](#stdlib-blas-uplo), of `alpha*A*transpose(A)` or `alpha*transpose(A)*A`, according to [`trans`](#stdlib-blas-trans).
```julia
herk!(uplo, trans, alpha, A, beta, C)
```
Methods for complex arrays only. Rank-k update of the Hermitian matrix `C` as `alpha*A*A' + beta*C` or `alpha*A'*A + beta*C` according to [`trans`](#stdlib-blas-trans). Only the [`uplo`](#stdlib-blas-uplo) triangle of `C` is updated. Returns `C`.
```julia
herk(uplo, trans, alpha, A)
```
Methods for complex arrays only. Returns the [`uplo`](#stdlib-blas-uplo) triangle of `alpha*A*A'` or `alpha*A'*A`, according to [`trans`](#stdlib-blas-trans).
```julia
syr2k!(uplo, trans, alpha, A, B, beta, C)
```
Rank-2k update of the symmetric matrix `C` as `alpha*A*transpose(B) + alpha*B*transpose(A) + beta*C` or `alpha*transpose(A)*B + alpha*transpose(B)*A + beta*C` according to [`trans`](#stdlib-blas-trans). Only the [`uplo`](#stdlib-blas-uplo) triangle of `C` is used. Returns `C`.
```julia
syr2k(uplo, trans, alpha, A, B)
```
Returns the [`uplo`](#stdlib-blas-uplo) triangle of `alpha*A*transpose(B) + alpha*B*transpose(A)` or `alpha*transpose(A)*B + alpha*transpose(B)*A`, according to [`trans`](#stdlib-blas-trans).


### [Level 3 BLAS functions](#Level-3-BLAS-functions)
```julia
syr2k(uplo, trans, A, B)
```
Return the [`uplo`](#stdlib-blas-uplo) triangle of `A*transpose(B) + B*transpose(A)` or `transpose(A)*B + transpose(B)*A`, according to [`trans`](#stdlib-blas-trans).
```julia
her2k!(uplo, trans, alpha, A, B, beta, C)
```
Rank-2k update of the Hermitian matrix `C` as `alpha*A*B' + alpha*B*A' + beta*C` or `alpha*A'*B + alpha*B'*A + beta*C` according to [`trans`](#stdlib-blas-trans). The scalar `beta` has to be real. Only the [`uplo`](#stdlib-blas-uplo) triangle of `C` is used. Return `C`.
```julia
her2k(uplo, trans, alpha, A, B)
```
Return the [`uplo`](#stdlib-blas-uplo) triangle of `alpha*A*B' + alpha*B*A'` or `alpha*A'*B + alpha*B'*A`, according to [`trans`](#stdlib-blas-trans).
```julia
her2k(uplo, trans, A, B)
```
Return the [`uplo`](#stdlib-blas-uplo) triangle of `A*B' + B*A'` or `A'*B + B'*A`, according to [`trans`](#stdlib-blas-trans).
```julia
trmm!(side, ul, tA, dA, alpha, A, B)
```
Update `B` as `alpha*A*B` or one of the other three variants determined by [`side`](#stdlib-blas-side) and [`tA`](#stdlib-blas-trans). Only the [`ul`](#stdlib-blas-uplo) triangle of `A` is used. [`dA`](#stdlib-blas-diag) determines if the diagonal values are read or are assumed to be all ones. Return the updated `B`.
```julia
trmm(side, ul, tA, dA, alpha, A, B)
```


### [Level 3 BLAS functions](#Level-3-BLAS-functions)
Return `alpha*A*B` or one of the other three variants determined by [`side`](#stdlib-blas-side) and [`tA`](#stdlib-blas-trans). Only the [`ul`](#stdlib-blas-uplo) triangle of `A` is used. [`dA`](#stdlib-blas-diag) determines if the diagonal values are read or are assumed to be all ones.
```julia
trsm!(side, ul, tA, dA, alpha, A, B)
```
Overwrite `B` with the solution to `A*X = alpha*B` or one of the other three variants determined by [`side`](#stdlib-blas-side) and [`tA`](#stdlib-blas-trans). Only the [`ul`](#stdlib-blas-uplo) triangle of `A` is used. [`dA`](#stdlib-blas-diag) determines if the diagonal values are read or are assumed to be all ones. Returns the updated `B`.
```julia
trsm(side, ul, tA, dA, alpha, A, B)
```
Return the solution to `A*X = alpha*B` or one of the other three variants determined by determined by [`side`](#stdlib-blas-side) and [`tA`](#stdlib-blas-trans). Only the [`ul`](#stdlib-blas-uplo) triangle of `A` is used. [`dA`](#stdlib-blas-diag) determines if the diagonal values are read or are assumed to be all ones.


## [LAPACK functions](#man-linalg-lapack-functions)
`LinearAlgebra.LAPACK` provides wrappers for some of the LAPACK functions for linear algebra. Those functions that overwrite one of the input arrays have names ending in `'!'`.
Usually a function has 4 methods defined, one each for [`Float64`](../../base/numbers/#Core.Float64), [`Float32`](../../base/numbers/#Core.Float32), `ComplexF64` and `ComplexF32` arrays.
Note that the LAPACK API provided by Julia can and will change in the future. Since this API is not user-facing, there is no commitment to support/deprecate this specific set of functions in future releases.
Interfaces to LAPACK subroutines.
```julia
gbtrf!(kl, ku, m, AB) -> (AB, ipiv)
```
Compute the LU factorization of a banded matrix `AB`. `kl` is the first subdiagonal containing a nonzero band, `ku` is the last superdiagonal containing one, and `m` is the first dimension of the matrix `AB`. Returns the LU factorization in-place and `ipiv`, the vector of pivots used.
```julia
gbtrs!(trans, kl, ku, m, AB, ipiv, B)
```
Solve the equation `AB * X = B`. `trans` determines the orientation of `AB`. It may be `N` (no transpose), `T` (transpose), or `C` (conjugate transpose). `kl` is the first subdiagonal containing a nonzero band, `ku` is the last superdiagonal containing one, and `m` is the first dimension of the matrix `AB`. `ipiv` is the vector of pivots returned from `gbtrf!`. Returns the vector or matrix `X`, overwriting `B` in-place.
```julia
gebal!(job, A) -> (ilo, ihi, scale)
```


## [LAPACK functions](#man-linalg-lapack-functions)
Balance the matrix `A` before computing its eigensystem or Schur factorization. `job` can be one of `N` (`A` will not be permuted or scaled), `P` (`A` will only be permuted), `S` (`A` will only be scaled), or `B` (`A` will be both permuted and scaled). Modifies `A` in-place and returns `ilo`, `ihi`, and `scale`. If permuting was turned on, `A[i,j] = 0` if `j > i` and `1 < j < ilo` or `j > ihi`. `scale` contains information about the scaling/permutations performed.
```julia
gebak!(job, side, ilo, ihi, scale, V)
```
Transform the eigenvectors `V` of a matrix balanced using `gebal!` to the unscaled/unpermuted eigenvectors of the original matrix. Modifies `V` in-place. `side` can be `L` (left eigenvectors are transformed) or `R` (right eigenvectors are transformed).
```julia
gebrd!(A) -> (A, d, e, tauq, taup)
```
Reduce `A` in-place to bidiagonal form `A = QBP'`. Returns `A`, containing the bidiagonal matrix `B`; `d`, containing the diagonal elements of `B`; `e`, containing the off-diagonal elements of `B`; `tauq`, containing the elementary reflectors representing `Q`; and `taup`, containing the elementary reflectors representing `P`.
```julia
gelqf!(A, tau)
```
Compute the `LQ` factorization of `A`, `A = LQ`. `tau` contains scalars which parameterize the elementary reflectors of the factorization. `tau` must have length greater than or equal to the smallest dimension of `A`.
Returns `A` and `tau` modified in-place.
```julia
gelqf!(A) -> (A, tau)
```
Compute the `LQ` factorization of `A`, `A = LQ`.


## [LAPACK functions](#man-linalg-lapack-functions)
Returns `A`, modified in-place, and `tau`, which contains scalars which parameterize the elementary reflectors of the factorization.
```julia
geqlf!(A, tau)
```
Compute the `QL` factorization of `A`, `A = QL`. `tau` contains scalars which parameterize the elementary reflectors of the factorization. `tau` must have length greater than or equal to the smallest dimension of `A`.
Returns `A` and `tau` modified in-place.
```julia
geqlf!(A) -> (A, tau)
```
Compute the `QL` factorization of `A`, `A = QL`.
Returns `A`, modified in-place, and `tau`, which contains scalars which parameterize the elementary reflectors of the factorization.
```julia
geqrf!(A, tau)
```
Compute the `QR` factorization of `A`, `A = QR`. `tau` contains scalars which parameterize the elementary reflectors of the factorization. `tau` must have length greater than or equal to the smallest dimension of `A`.
Returns `A` and `tau` modified in-place.
```julia
geqrf!(A) -> (A, tau)
```
Compute the `QR` factorization of `A`, `A = QR`.
Returns `A`, modified in-place, and `tau`, which contains scalars which parameterize the elementary reflectors of the factorization.
```julia
geqp3!(A, [jpvt, tau]) -> (A, tau, jpvt)
```


## [LAPACK functions](#man-linalg-lapack-functions)
Compute the pivoted `QR` factorization of `A`, `AP = QR` using BLAS level 3. `P` is a pivoting matrix, represented by `jpvt`. `tau` stores the elementary reflectors. The arguments `jpvt` and `tau` are optional and allow for passing preallocated arrays. When passed, `jpvt` must have length greater than or equal to `n` if `A` is an `(m x n)` matrix and `tau` must have length greater than or equal to the smallest dimension of `A`. On entry, if `jpvt[j]` does not equal zero then the `j`th column of `A` is permuted to the front of `AP`.
`A`, `jpvt`, and `tau` are modified in-place.
```julia
gerqf!(A, tau)
```
Compute the `RQ` factorization of `A`, `A = RQ`. `tau` contains scalars which parameterize the elementary reflectors of the factorization. `tau` must have length greater than or equal to the smallest dimension of `A`.
Returns `A` and `tau` modified in-place.
```julia
gerqf!(A) -> (A, tau)
```
Compute the `RQ` factorization of `A`, `A = RQ`.
Returns `A`, modified in-place, and `tau`, which contains scalars which parameterize the elementary reflectors of the factorization.
```julia
geqrt!(A, T)
```
Compute the blocked `QR` factorization of `A`, `A = QR`. `T` contains upper triangular block reflectors which parameterize the elementary reflectors of the factorization. The first dimension of `T` sets the block size and it must be between 1 and `n`. The second dimension of `T` must equal the smallest dimension of `A`.
Returns `A` and `T` modified in-place.
```julia
geqrt!(A, nb) -> (A, T)
```


## [LAPACK functions](#man-linalg-lapack-functions)
Compute the blocked `QR` factorization of `A`, `A = QR`. `nb` sets the block size and it must be between 1 and `n`, the second dimension of `A`.
Returns `A`, modified in-place, and `T`, which contains upper triangular block reflectors which parameterize the elementary reflectors of the factorization.
```julia
geqrt3!(A, T)
```
Recursively computes the blocked `QR` factorization of `A`, `A = QR`. `T` contains upper triangular block reflectors which parameterize the elementary reflectors of the factorization. The first dimension of `T` sets the block size and it must be between 1 and `n`. The second dimension of `T` must equal the smallest dimension of `A`.
Returns `A` and `T` modified in-place.
```julia
geqrt3!(A) -> (A, T)
```
Recursively computes the blocked `QR` factorization of `A`, `A = QR`.
Returns `A`, modified in-place, and `T`, which contains upper triangular block reflectors which parameterize the elementary reflectors of the factorization.
```julia
getrf!(A, ipiv) -> (A, ipiv, info)
```
Compute the pivoted `LU` factorization of `A`, `A = LU`. `ipiv` contains the pivoting information and `info` a code which indicates success (`info = 0`), a singular value in `U` (`info = i`, in which case `U[i,i]` is singular), or an error code (`info < 0`).
```julia
getrf!(A) -> (A, ipiv, info)
```
Compute the pivoted `LU` factorization of `A`, `A = LU`.


## [LAPACK functions](#man-linalg-lapack-functions)
Returns `A`, modified in-place, `ipiv`, the pivoting information, and an `info` code which indicates success (`info = 0`), a singular value in `U` (`info = i`, in which case `U[i,i]` is singular), or an error code (`info < 0`).
```julia
tzrzf!(A) -> (A, tau)
```
Transforms the upper trapezoidal matrix `A` to upper triangular form in-place. Returns `A` and `tau`, the scalar parameters for the elementary reflectors of the transformation.
```julia
ormrz!(side, trans, A, tau, C)
```
Multiplies the matrix `C` by `Q` from the transformation supplied by `tzrzf!`. Depending on `side` or `trans` the multiplication can be left-sided (`side = L, Q*C`) or right-sided (`side = R, C*Q`) and `Q` can be unmodified (`trans = N`), transposed (`trans = T`), or conjugate transposed (`trans = C`). Returns matrix `C` which is modified in-place with the result of the multiplication.
```julia
gels!(trans, A, B) -> (F, B, ssr)
```
Solves the linear equation `A * X = B`, `transpose(A) * X = B`, or `adjoint(A) * X = B` using a QR or LQ factorization. Modifies the matrix/vector `B` in place with the solution. `A` is overwritten with its `QR` or `LQ` factorization. `trans` may be one of `N` (no modification), `T` (transpose), or `C` (conjugate transpose). `gels!` searches for the minimum norm/least squares solution. `A` may be under or over determined. The solution is returned in `B`.
```julia
gesv!(A, B) -> (B, A, ipiv)
```


## [LAPACK functions](#man-linalg-lapack-functions)
Solves the linear equation `A * X = B` where `A` is a square matrix using the `LU` factorization of `A`. `A` is overwritten with its `LU` factorization and `B` is overwritten with the solution `X`. `ipiv` contains the pivoting information for the `LU` factorization of `A`.
```julia
getrs!(trans, A, ipiv, B)
```
Solves the linear equation `A * X = B`, `transpose(A) * X = B`, or `adjoint(A) * X = B` for square `A`. Modifies the matrix/vector `B` in place with the solution. `A` is the `LU` factorization from `getrf!`, with `ipiv` the pivoting information. `trans` may be one of `N` (no modification), `T` (transpose), or `C` (conjugate transpose).
```julia
getri!(A, ipiv)
```
Computes the inverse of `A`, using its `LU` factorization found by `getrf!`. `ipiv` is the pivot information output and `A` contains the `LU` factorization of `getrf!`. `A` is overwritten with its inverse.
```julia
gesvx!(fact, trans, A, AF, ipiv, equed, R, C, B) -> (X, equed, R, C, B, rcond, ferr, berr, work)
```


## [LAPACK functions](#man-linalg-lapack-functions)
Solves the linear equation `A * X = B` (`trans = N`), `transpose(A) * X = B` (`trans = T`), or `adjoint(A) * X = B` (`trans = C`) using the `LU` factorization of `A`. `fact` may be `E`, in which case `A` will be equilibrated and copied to `AF`; `F`, in which case `AF` and `ipiv` from a previous `LU` factorization are inputs; or `N`, in which case `A` will be copied to `AF` and then factored. If `fact = F`, `equed` may be `N`, meaning `A` has not been equilibrated; `R`, meaning `A` was multiplied by `Diagonal(R)` from the left; `C`, meaning `A` was multiplied by `Diagonal(C)` from the right; or `B`, meaning `A` was multiplied by `Diagonal(R)` from the left and `Diagonal(C)` from the right. If `fact = F` and `equed = R` or `B` the elements of `R` must all be positive. If `fact = F` and `equed = C` or `B` the elements of `C` must all be positive.
Returns the solution `X`; `equed`, which is an output if `fact` is not `N`, and describes the equilibration that was performed; `R`, the row equilibration diagonal; `C`, the column equilibration diagonal; `B`, which may be overwritten with its equilibrated form `Diagonal(R)*B` (if `trans = N` and `equed = R,B`) or `Diagonal(C)*B` (if `trans = T,C` and `equed = C,B`); `rcond`, the reciprocal condition number of `A` after equilbrating; `ferr`, the forward error bound for each solution vector in `X`; `berr`, the forward error bound for each solution vector in `X`; and `work`, the reciprocal pivot growth factor.
```julia
gesvx!(A, B)
```


## [LAPACK functions](#man-linalg-lapack-functions)
The no-equilibration, no-transpose simplification of `gesvx!`.
```julia
gelsd!(A, B, rcond) -> (B, rnk)
```
Computes the least norm solution of `A * X = B` by finding the `SVD` factorization of `A`, then dividing-and-conquering the problem. `B` is overwritten with the solution `X`. Singular values below `rcond` will be treated as zero. Returns the solution in `B` and the effective rank of `A` in `rnk`.
```julia
gelsy!(A, B, rcond) -> (B, rnk)
```
Computes the least norm solution of `A * X = B` by finding the full `QR` factorization of `A`, then dividing-and-conquering the problem. `B` is overwritten with the solution `X`. Singular values below `rcond` will be treated as zero. Returns the solution in `B` and the effective rank of `A` in `rnk`.
```julia
gglse!(A, c, B, d) -> (X,res)
```
Solves the equation `A * x = c` where `x` is subject to the equality constraint `B * x = d`. Uses the formula `||c - A*x||^2 = 0` to solve. Returns `X` and the residual sum-of-squares.
```julia
geev!(jobvl, jobvr, A) -> (W, VL, VR)
```
Finds the eigensystem of `A`. If `jobvl = N`, the left eigenvectors of `A` aren't computed. If `jobvr = N`, the right eigenvectors of `A` aren't computed. If `jobvl = V` or `jobvr = V`, the corresponding eigenvectors are computed. Returns the eigenvalues in `W`, the right eigenvectors in `VR`, and the left eigenvectors in `VL`.
```julia
gesdd!(job, A) -> (U, S, VT)
```


## [LAPACK functions](#man-linalg-lapack-functions)
Finds the singular value decomposition of `A`, `A = U * S * V'`, using a divide and conquer approach. If `job = A`, all the columns of `U` and the rows of `V'` are computed. If `job = N`, no columns of `U` or rows of `V'` are computed. If `job = O`, `A` is overwritten with the columns of (thin) `U` and the rows of (thin) `V'`. If `job = S`, the columns of (thin) `U` and the rows of (thin) `V'` are computed and returned separately.
```julia
gesvd!(jobu, jobvt, A) -> (U, S, VT)
```
Finds the singular value decomposition of `A`, `A = U * S * V'`. If `jobu = A`, all the columns of `U` are computed. If `jobvt = A` all the rows of `V'` are computed. If `jobu = N`, no columns of `U` are computed. If `jobvt = N` no rows of `V'` are computed. If `jobu = O`, `A` is overwritten with the columns of (thin) `U`. If `jobvt = O`, `A` is overwritten with the rows of (thin) `V'`. If `jobu = S`, the columns of (thin) `U` are computed and returned separately. If `jobvt = S` the rows of (thin) `V'` are computed and returned separately. `jobu` and `jobvt` can't both be `O`.
Returns `U`, `S`, and `Vt`, where `S` are the singular values of `A`.
```julia
ggsvd!(jobu, jobv, jobq, A, B) -> (U, V, Q, alpha, beta, k, l, R)
```


## [LAPACK functions](#man-linalg-lapack-functions)
Finds the generalized singular value decomposition of `A` and `B`, `U'*A*Q = D1*R` and `V'*B*Q = D2*R`. `D1` has `alpha` on its diagonal and `D2` has `beta` on its diagonal. If `jobu = U`, the orthogonal/unitary matrix `U` is computed. If `jobv = V` the orthogonal/unitary matrix `V` is computed. If `jobq = Q`, the orthogonal/unitary matrix `Q` is computed. If `jobu`, `jobv` or `jobq` is `N`, that matrix is not computed. This function is only available in LAPACK versions prior to 3.6.0.
```julia
ggsvd3!(jobu, jobv, jobq, A, B) -> (U, V, Q, alpha, beta, k, l, R)
```
Finds the generalized singular value decomposition of `A` and `B`, `U'*A*Q = D1*R` and `V'*B*Q = D2*R`. `D1` has `alpha` on its diagonal and `D2` has `beta` on its diagonal. If `jobu = U`, the orthogonal/unitary matrix `U` is computed. If `jobv = V` the orthogonal/unitary matrix `V` is computed. If `jobq = Q`, the orthogonal/unitary matrix `Q` is computed. If `jobu`, `jobv`, or `jobq` is `N`, that matrix is not computed. This function requires LAPACK 3.6.0.
```julia
geevx!(balanc, jobvl, jobvr, sense, A) -> (A, w, VL, VR, ilo, ihi, scale, abnrm, rconde, rcondv)
```