Skip to content

Commit 22495c3

Browse files
committed
docstring fixes
1 parent f1147f5 commit 22495c3

File tree

5 files changed

+53
-13
lines changed

5 files changed

+53
-13
lines changed

src/implementations/truncation.jl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,6 @@ _ind_intersect(A, B) = intersect(A, B)
119119

120120
# Truncation error
121121
# ----------------
122-
@doc """
123-
truncation_error(values, ind)
124-
truncation_error!(values, ind)
125-
126-
Determine the truncation error of selecting `ind` out of the `values`.
127-
This is defined as the 2-norm of the discarded values.
128-
""" truncation_error, truncation_error!
129-
130122
truncation_error(values::AbstractVector, ind) = truncation_error!(copy(values), ind)
131123
# destroys input in order to maximize accuracy:
132124
# sqrt(norm(values)^2 - norm(values[ind])^2) might suffer from floating point error

src/interface/eig.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,26 @@ selected according to a truncation strategy.
4545
The function also returns `ϵ`, the truncation error defined as the 2-norm of the
4646
discarded eigenvalues.
4747
48+
## Keyword arguments
49+
The behavior of this function is controlled by the following keyword arguments:
50+
51+
- `trunc`: Specifies the truncation strategy. This can be:
52+
- A `NamedTuple` with fields `atol`, `rtol`, and/or `maxrank`, which will be converted to
53+
a [`TruncationStrategy`](@ref). For details on available truncation strategies, see
54+
[Truncations](@ref).
55+
- A `TruncationStrategy` object directly (e.g., `truncrank(10)`, `trunctol(atol=1e-6)`, or
56+
combinations using `&`).
57+
- `nothing` (default), which keeps all eigenvalues.
58+
59+
- Other keyword arguments are passed to the algorithm selection procedure. If no explicit
60+
`alg` is provided, these keywords are used to select and configure the algorithm through
61+
[`MatrixAlgebraKit.select_algorithm`](@ref). The remaining keywords after algorithm
62+
selection are passed to the algorithm constructor. See [`MatrixAlgebraKit.default_algorithm`](@ref)
63+
for the default algorithm selection behavior.
64+
65+
When `alg` is a [`TruncatedAlgorithm`](@ref), the `trunc` keyword cannot be specified as the
66+
truncation strategy is already embedded in the algorithm.
67+
4868
!!! note
4969
The bang method `eig_trunc!` optionally accepts the output structure and
5070
possibly destroys the input matrix `A`. Always use the return value of the function

src/interface/eigh.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,19 @@ See also [`eigh_vals(!)`](@ref eigh_vals) and [`eigh_trunc(!)`](@ref eigh_trunc)
3737
@functiondef eigh_full
3838

3939
"""
40-
eigh_trunc(A; [trunc], kwargs...) -> D, V
41-
eigh_trunc(A, alg::AbstractAlgorithm) -> D, V
42-
eigh_trunc!(A, [DV]; [trunc], kwargs...) -> D, V
43-
eigh_trunc!(A, [DV], alg::AbstractAlgorithm) -> D, V
40+
eigh_trunc(A; [trunc], kwargs...) -> D, V, ϵ
41+
eigh_trunc(A, alg::AbstractAlgorithm) -> D, V, ϵ
42+
eigh_trunc!(A, [DV]; [trunc], kwargs...) -> D, V, ϵ
43+
eigh_trunc!(A, [DV], alg::AbstractAlgorithm) -> D, V, ϵ
4444
4545
Compute a partial or truncated eigenvalue decomposition of the symmetric or hermitian matrix
4646
`A`, such that `A * V ≈ V * D`, where the isometric matrix `V` contains a subset of the
4747
orthogonal eigenvectors and the real diagonal matrix `D` contains the associated eigenvalues,
4848
selected according to a truncation strategy.
4949
50+
The function also returns `ϵ`, the truncation error defined as the 2-norm of the discarded
51+
eigenvalues.
52+
5053
## Keyword arguments
5154
The behavior of this function is controlled by the following keyword arguments:
5255

src/interface/svd.jl

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,27 @@ square diagonal matrix of size `(k, k)`, with `k` is set by the truncation strat
5454
5555
The function also returns `ϵ`, the truncation error defined as the 2-norm of the
5656
discarded singular values.
57-
57+
58+
## Keyword arguments
59+
The behavior of this function is controlled by the following keyword arguments:
60+
61+
- `trunc`: Specifies the truncation strategy. This can be:
62+
- A `NamedTuple` with fields `atol`, `rtol`, and/or `maxrank`, which will be converted to
63+
a [`TruncationStrategy`](@ref). For details on available truncation strategies, see
64+
[Truncations](@ref).
65+
- A `TruncationStrategy` object directly (e.g., `truncrank(10)`, `trunctol(atol=1e-6)`, or
66+
combinations using `&`).
67+
- `nothing` (default), which keeps all singular values.
68+
69+
- Other keyword arguments are passed to the algorithm selection procedure. If no explicit
70+
`alg` is provided, these keywords are used to select and configure the algorithm through
71+
[`MatrixAlgebraKit.select_algorithm`](@ref). The remaining keywords after algorithm
72+
selection are passed to the algorithm constructor. See [`MatrixAlgebraKit.default_algorithm`](@ref)
73+
for the default algorithm selection behavior.
74+
75+
When `alg` is a [`TruncatedAlgorithm`](@ref), the `trunc` keyword cannot be specified as the
76+
truncation strategy is already embedded in the algorithm.
77+
5878
!!! note
5979
The bang method `svd_trunc!` optionally accepts the output structure and
6080
possibly destroys the input matrix `A`. Always use the return value of the function

src/interface/truncation.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,8 @@ Base.:&(::NoTruncation, ::NoTruncation) = notrunc()
181181
# disambiguate
182182
Base.:&(::NoTruncation, trunc::TruncationIntersection) = trunc
183183
Base.:&(trunc::TruncationIntersection, ::NoTruncation) = trunc
184+
185+
@doc """
186+
truncation_error(values, ind)
187+
Compute the truncation error as the 2-norm of the values that are not kept by `ind`.
188+
""" truncation_error, truncation_error!

0 commit comments

Comments
 (0)