GenericLinearAlgebra.jl

Documentation for GenericLinearAlgebra.jl

LinearAlgebra.ldltFunction
ldlt(A::Hermitian, blocksize::Int)::LTLt

A Hermitian LDL factorization of A such that A = L*D*L' if A.uplo == 'L' and A = U'*D*U if A.uplo == 'U'. Hence, thet` is a bit of a misnomer, but the name was introduced for real symmetric matrices where there is no difference between the two.

Only the elements specified by uplo in the Hermitian input will be referenced.

The factorization has three properties: d, D, and L which is respectively a vector of the diagonal elements of D, the Diagonal matrix D and the L matrix when A.uplo == 'L' or the adjoint of the U matrix when A.uplo == 'U'.

The blocksize argument controls the block size in the blocked algorithm. Currently, the blocking size is set to 128 ÷ sizeof(eltype(A)) based on very rudimentary benchmarking on my laptop. Most users won't need adjust this argument.

Examples

julia> ldlt(Hermitian([1//1 1; 1 -1]))
LDLt{Rational{Int64}, Hermitian{Rational{Int64}, Matrix{Rational{Int64}}}}
L factor:
2×2 UnitLowerTriangular{Rational{Int64}, Adjoint{Rational{Int64}, Matrix{Rational{Int64}}}}:
 1  ⋅
 1  1
D factor:
2×2 Diagonal{Rational{Int64}, SubArray{Rational{Int64}, 1, Base.ReshapedArray{Rational{Int64}, 1, Hermitian{Rational{Int64}, Matrix{Rational{Int64}}}, Tuple{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64}}}, Tuple{StepRange{Int64, Int64}}, false}}:
 1   ⋅
 ⋅  -2

julia> ldlt(Hermitian([1//1 1; 1 1], :L))
LDLt{Rational{Int64}, Hermitian{Rational{Int64}, Matrix{Rational{Int64}}}}
L factor:
2×2 UnitLowerTriangular{Rational{Int64}, Matrix{Rational{Int64}}}:
 1  ⋅
 1  1
D factor:
2×2 Diagonal{Rational{Int64}, SubArray{Rational{Int64}, 1, Base.ReshapedArray{Rational{Int64}, 1, Hermitian{Rational{Int64}, Matrix{Rational{Int64}}}, Tuple{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64}}}, Tuple{StepRange{Int64, Int64}}, false}}:
 1  ⋅
 ⋅  0
source
GenericLinearAlgebra.numnegevalsFunction

Computes the number of negative eigenvalues of T - σI, a.k.a. spectrum slicing

Inputs: T: A SymTridiagonal{<:Real} matrix σ: The shift parameter

Outputs: ν: The number of negative eigenvalues

Reference: B. N. Parlett, "The symmetric eigenvalue problem", Section 3.3.1, p. 52.

source
LinearAlgebra.svd!Function
svd!(A[, tol, full])::SVD

A generic singular value decomposition (SVD). The implementation only uses Julia functions so the SVD can be computed for any element type provided that the necessary arithmetic operations are supported by the element type.

  • tol: The relative tolerance for determining convergence. The default value is eltype(T) where T is the element type of the input matrix bidiagonal (i.e. after converting the matrix to bidiagonal form).

  • full: If set to true then all the left and right singular vectors are returned. If set to false then only the vectors corresponding to the number of rows and columns of the input matrix A are returned (the default).

Algorithm

...tomorrow

Example

julia> svd(big.([1 2; 3 4]))
SVD{BigFloat, BigFloat, Matrix{BigFloat}, Vector{BigFloat}}
U factor:
2×2 Matrix{BigFloat}:
 -0.404554   0.914514
 -0.914514  -0.404554
singular values:
2-element Vector{BigFloat}:
 5.464985704219042650451188493284182533042584640492784181017488774646871847029449
 0.3659661906262578204229643842614005434788136943931877734325179702209382149672422
Vt factor:
2×2 Matrix{BigFloat}:
 -0.576048  -0.817416
 -0.817416   0.576048
source
LinearAlgebra.svdvals!Function
svdvals!(A [, tol])

Generic computation of singular values.

Examples

julia> using LinearAlgebra, GenericLinearAlgebra, Quaternions

julia> n = 20;

julia> H = [big(1)/(i + j - 1) for i in 1:n, j in 1:n]; # The Hilbert matrix

julia> round(svdvals(H)[end]/svdvals(Float64.(H))[end] - 1, sigdigits=8) # The relative error of the LAPACK based solution rounded to eight significant digits.
-1.0

julia> A = qr([Quaternion(randn(4)...) for i in 1:3, j in 1:3]).Q *
           Diagonal([3, 2, 1]) *
           qr([Quaternion(randn(4)...) for i in 1:3, j in 1:3]).Q';

julia> svdvals(A) ≈ [3, 2, 1]
true
source