@@ -41,26 +41,45 @@ See also [`svd_full(!)`](@ref svd_full), [`svd_vals(!)`](@ref svd_vals) and
4141"""
4242@functiondef svd_compact
4343
44- # TODO : decide if we should have `svd_trunc!!` instead
4544"""
46- svd_trunc(A; kwargs...) -> U, S, Vᴴ
45+ svd_trunc(A; trunc, kwargs...) -> U, S, Vᴴ
4746 svd_trunc(A, alg::AbstractAlgorithm) -> U, S, Vᴴ
48- svd_trunc!(A, [USVᴴ]; kwargs...) -> U, S, Vᴴ
47+ svd_trunc!(A, [USVᴴ]; trunc, kwargs...) -> U, S, Vᴴ
4948 svd_trunc!(A, [USVᴴ], alg::AbstractAlgorithm) -> U, S, Vᴴ
5049
5150Compute a partial or truncated singular value decomposition (SVD) of `A`, such that
5251`A * (Vᴴ)' = U * S`. Here, `U` is an isometric matrix (orthonormal columns) of size
5352`(m, k)`, whereas `Vᴴ` is a matrix of size `(k, n)` with orthonormal rows and `S` is a
5453square diagonal matrix of size `(k, k)`, with `k` is set by the truncation strategy.
5554
55+ ## Keyword arguments
56+ The behavior of this function is controlled by the following keyword arguments:
57+
58+ - `trunc`: Specifies the truncation strategy. This can be:
59+ - A `NamedTuple` with fields `atol`, `rtol`, and/or `maxrank`, which will be converted to
60+ a [`TruncationStrategy`](@ref). For details on available truncation strategies, see
61+ [Truncations](@ref).
62+ - A `TruncationStrategy` object directly (e.g., `truncrank(10)`, `trunctol(atol=1e-6)`, or
63+ combinations using `&`).
64+ - `nothing` (default), which keeps all singular values.
65+
66+ - Other keyword arguments are passed to the algorithm selection procedure. If no explicit
67+ `alg` is provided, these keywords are used to select and configure the algorithm through
68+ [`MatrixAlgebraKit.select_algorithm`](@ref). The remaining keywords after algorithm
69+ selection are passed to the algorithm constructor. See [`MatrixAlgebraKit.default_algorithm`](@ref)
70+ for the default algorithm selection behavior.
71+
72+ When `alg` is a [`TruncatedAlgorithm`](@ref), the `trunc` keyword cannot be specified as the
73+ truncation strategy is already embedded in the algorithm.
74+
5675!!! note
5776 The bang method `svd_trunc!` optionally accepts the output structure and
5877 possibly destroys the input matrix `A`. Always use the return value of the function
5978 as it may not always be possible to use the provided `USVᴴ` as output.
6079
61-
62- See also [`svd_full (!)`](@ref svd_full ), [`svd_compact(!)` ](@ref svd_compact) and
63- [`svd_vals(!)`](@ref svd_vals) .
80+ See also [`svd_full(!)`](@ref svd_full), [`svd_compact(!)`](@ref svd_compact),
81+ [`svd_vals (!)`](@ref svd_vals ), and [Truncations ](@ref) for more information on
82+ truncation strategies .
6483"""
6584@functiondef svd_trunc
6685
0 commit comments