Skip to content

Commit 5c39d32

Browse files
authored
More docs (#49)
1 parent ccb13bc commit 5c39d32

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

docs/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[deps]
22
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
4+
Quaternions = "94ee1d12-ae83-5a48-8b1c-48b8ff168ae0"
35

46
[compat]
57
Documenter = "~0.21"

docs/src/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ CurrentModule = GenericLinearAlgebra
88

99
```@docs
1010
svd!
11+
svdvals!
1112
```

src/svd.jl

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,31 @@ function rmul!(A::AbstractMatrix, Q::LinearAlgebra.LQPackedQ)
425425
end
426426

427427
# Overload LinearAlgebra methods
428+
428429
LinearAlgebra.svdvals!(B::Bidiagonal{T}; tol = eps(T), debug = false) where T<:Real = _svdvals!(B, tol = tol, debug = debug)
430+
431+
"""
432+
svdvals!(A [, tol, debug])
433+
434+
Generic computation of singular values.
435+
```jldoctest
436+
julia> using LinearAlgebra, GenericLinearAlgebra, Quaternions
437+
438+
julia> n = 20;
439+
440+
julia> H = [big(1)/(i + j - 1) for i in 1:n, j in 1:n]; # The Hilbert matrix
441+
442+
julia> Float64(svdvals(H)[end]/svdvals(Float64.(H))[end] - 1) # The relative error of the LAPACK based solution in 64 bit floating point.
443+
-0.9999999999447275
444+
445+
julia> A = qr([Quaternion(randn(4)...) for i in 1:3, j in 1:3]).Q *
446+
Diagonal([3, 2, 1]) *
447+
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.
448+
449+
julia> svdvals(A) ≈ [3, 2, 1]
450+
true
451+
```
452+
"""
429453
function LinearAlgebra.svdvals!(A::StridedMatrix; tol = eps(real(eltype(A))), debug = false)
430454
B = bidiagonalize!(A).bidiagonal
431455
# It doesn't matter that we transpose the bidiagonal matrix when we are only interested in the values
@@ -436,9 +460,23 @@ end
436460
LinearAlgebra.svd!(B::Bidiagonal{T}; tol = eps(T), full = false, debug = false) where T<:Real = _svd!(B, tol = tol, debug = debug)
437461

438462
"""
439-
svd!
463+
svd!(A[, tol, full, debug])::SVD
464+
465+
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.
466+
467+
- `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).
468+
469+
- `full`: Sepcifies if all the left and right singular vectors be returned or if only the vectors us to the number of rows and columns of the input matrix `A` should be returned (the default).
470+
471+
- `debug`: A Boolean flag to activate debug information during the executions of the algorithm. The default is false.
472+
473+
# Algorithm
474+
...tomorrow
475+
476+
# Example
440477
441-
A generic SVD implementation.
478+
```jldoctest
479+
```
442480
"""
443481
function LinearAlgebra.svd!(A::StridedMatrix{T}; tol = eps(real(eltype(A))), full = false, debug = false) where T
444482

0 commit comments

Comments
 (0)