Skip to content

Commit cd0cb33

Browse files
committed
Update and fix the docs
Update to Documenter@1 and fix failures. Also update Quaternions to same version used for tests. The old version had larger struct sizes so revealed a bug in the new ldlt code for the blocksize determination. This bug was fixed here.
1 parent 65c4f82 commit cd0cb33

4 files changed

Lines changed: 26 additions & 19 deletions

File tree

docs/Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
44
Quaternions = "94ee1d12-ae83-5a48-8b1c-48b8ff168ae0"
55

66
[compat]
7-
Documenter = "0.26"
8-
Quaternions = "0.4"
7+
Documenter = "1"
8+
Quaternions = "0.7"

docs/src/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ CurrentModule = GenericLinearAlgebra
77
```
88

99
```@docs
10+
ldlt
11+
ldlt!
12+
numnegevals
1013
svd!
1114
svdvals!
1215
```

src/ldlt.jl

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ end
147147
148148
See [`ldlt`](@ref)
149149
"""
150-
function LinearAlgebra.ldlt!(A::Hermitian{T}, blocksize::Int = 32 ÷ sizeof(T)) where T
150+
function LinearAlgebra.ldlt!(A::Hermitian{T}, blocksize::Int = max(1, 128 ÷ sizeof(T))) where T
151151
if A.uplo === 'U'
152152
_ldlt_upper_blocked!(A.data, blocksize)
153153
else
@@ -157,7 +157,7 @@ function LinearAlgebra.ldlt!(A::Hermitian{T}, blocksize::Int = 32 ÷ sizeof(T))
157157
end
158158

159159
"""
160-
ldlt(A::Hermitian)::LTLt
160+
ldlt(A::Hermitian, blocksize::Int)::LTLt
161161
162162
A Hermitian LDL factorization of `A` such that `A = L*D*L'` if `A.uplo == 'L'`
163163
and `A = U'*D*U` if `A.uplo == 'U'. Hence, the `t` is a bit of a misnomer,
@@ -171,35 +171,37 @@ The factorization has three properties: `d`, `D`, and `L` which is respectively
171171
a vector of the diagonal elements of `D`, the `Diagonal` matrix `D` and the `L`
172172
matrix when `A.uplo == 'L'` or the `adjoint` of the `U` matrix when `A.uplo == 'U'`.
173173
174-
The factorization is blocked. Currently, the blocking size is set to `32 ÷ sizeof(eltype(A))`
175-
based on very rudimentary benchmarking on my laptop.
174+
The `blocksize` argument controls the block size in the blocked algorithm.
175+
Currently, the blocking size is set to `128 ÷ sizeof(eltype(A))`
176+
based on very rudimentary benchmarking on my laptop. Most users won't need
177+
adjust this argument.
176178
177179
# Examples
178180
```jldoctest
179-
julia> ldlt(Hermitian([1 1; 1 -1]))
180-
LDLt{Int64, Hermitian{Int64, Matrix{Int64}}}
181+
julia> ldlt(Hermitian([1//1 1; 1 -1]))
182+
LDLt{Rational{Int64}, Hermitian{Rational{Int64}, Matrix{Rational{Int64}}}}
181183
L factor:
182-
2×2 UnitLowerTriangular{Int64, Adjoint{Int64, Matrix{Int64}}}:
184+
2×2 UnitLowerTriangular{Rational{Int64}, Adjoint{Rational{Int64}, Matrix{Rational{Int64}}}}:
183185
1 ⋅
184186
1 1
185187
D factor:
186-
2×2 Diagonal{Int64, SubArray{Int64, 1, Base.ReshapedArray{Int64, 1, Hermitian{Int64, Matrix{Int64}}, Tuple{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64}}}, Tuple{StepRange{Int64, Int64}}, false}}:
188+
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}}:
187189
1 ⋅
188190
⋅ -2
189191
190-
julia> ldlt(Hermitian([1 1; 1 1], :L))
191-
LDLt{Int64, Hermitian{Int64, Matrix{Int64}}}
192+
julia> ldlt(Hermitian([1//1 1; 1 1], :L))
193+
LDLt{Rational{Int64}, Hermitian{Rational{Int64}, Matrix{Rational{Int64}}}}
192194
L factor:
193-
2×2 UnitLowerTriangular{Int64, Matrix{Int64}}:
195+
2×2 UnitLowerTriangular{Rational{Int64}, Matrix{Rational{Int64}}}:
194196
1 ⋅
195197
1 1
196198
D factor:
197-
2×2 Diagonal{Int64, SubArray{Int64, 1, Base.ReshapedArray{Int64, 1, Hermitian{Int64, Matrix{Int64}}, Tuple{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64}}}, Tuple{StepRange{Int64, Int64}}, false}}:
199+
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}}:
198200
1 ⋅
199201
⋅ 0
200202
```
201203
"""
202-
LinearAlgebra.ldlt(A::Hermitian{T}, blocksize::Int = 32 ÷ sizeof(T)) where T = ldlt!(LinearAlgebra.copy_oftype(A, typeof(oneunit(T) / one(T))))
204+
LinearAlgebra.ldlt(A::Hermitian{T}, blocksize::Int = max(1, 128 ÷ sizeof(T))) where T = ldlt!(LinearAlgebra.copy_oftype(A, typeof(oneunit(T) / one(T))))
203205

204206
function Base.getproperty(F::LDLt{<:Any, <:Hermitian}, d::Symbol)
205207
Fdata = getfield(F, :data)

src/svd.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,19 +567,21 @@ LinearAlgebra.svdvals!(B::Bidiagonal{T}; tol = eps(T)) where {T<:Real} =
567567
svdvals!(A [, tol])
568568
569569
Generic computation of singular values.
570+
571+
# Examples
570572
```jldoctest
571573
julia> using LinearAlgebra, GenericLinearAlgebra, Quaternions
572574
573575
julia> n = 20;
574576
575577
julia> H = [big(1)/(i + j - 1) for i in 1:n, j in 1:n]; # The Hilbert matrix
576578
577-
julia> Float64(svdvals(H)[end]/svdvals(Float64.(H))[end] - 1) # The relative error of the LAPACK based solution in 64 bit floating point.
578-
-0.9999999999447275
579+
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.
580+
-1.0
579581
580582
julia> A = qr([Quaternion(randn(4)...) for i in 1:3, j in 1:3]).Q *
581583
Diagonal([3, 2, 1]) *
582-
qr([Quaternion(randn(4)...) for i in 1:3, j in 1:3]).Q'; # A quaternion matrix with the singular value 1, 2, and 3.
584+
qr([Quaternion(randn(4)...) for i in 1:3, j in 1:3]).Q';
583585
584586
julia> svdvals(A) ≈ [3, 2, 1]
585587
true
@@ -617,7 +619,7 @@ A generic singular value decomposition (SVD). The implementation only uses Julia
617619
618620
```jldoctest
619621
julia> svd(big.([1 2; 3 4]))
620-
SVD{BigFloat, BigFloat, Matrix{BigFloat}}
622+
SVD{BigFloat, BigFloat, Matrix{BigFloat}, Vector{BigFloat}}
621623
U factor:
622624
2×2 Matrix{BigFloat}:
623625
-0.404554 0.914514

0 commit comments

Comments
 (0)