@@ -27,7 +27,8 @@ and the diagonal matrix `D` contains the associated eigenvalues.
2727!!! note
2828$(docs_eig_note)
2929
30- See also [`eig_vals(!)`](@ref eig_vals) and [`eig_trunc(!)`](@ref eig_trunc).
30+ See also [`eig_vals(!)`](@ref eig_vals), [`eig_trunc_no_error`](@ref eig_trunc_no_error)
31+ and [`eig_trunc(!)`](@ref eig_trunc).
3132"""
3233@functiondef eig_full
3334
@@ -79,11 +80,63 @@ truncation strategy is already embedded in the algorithm.
7980!!! note
8081$docs_eig_note
8182
82- See also [`eig_full(!)`](@ref eig_full), [`eig_vals(!)`](@ref eig_vals), and
83- [Truncations](@ref) for more information on truncation strategies.
83+ See also [`eig_full(!)`](@ref eig_full), [`eig_vals(!)`](@ref eig_vals),
84+ [`eig_trunc_no_error!`](@ref eig_trunc_no_error) and [Truncations](@ref)
85+ for more information on truncation strategies.
8486"""
8587@functiondef eig_trunc
8688
89+ """
90+ eig_trunc_no_error(A; [trunc], kwargs...) -> D, V
91+ eig_trunc_no_error(A, alg::AbstractAlgorithm) -> D, V
92+ eig_trunc_no_error!(A, [DV]; [trunc], kwargs...) -> D, V
93+ eig_trunc_no_error!(A, [DV], alg::AbstractAlgorithm) -> D, V
94+
95+ Compute a partial or truncated eigenvalue decomposition of the matrix `A`,
96+ such that `A * V ≈ V * D`, where the (possibly rectangular) matrix `V` contains
97+ a subset of eigenvectors and the diagonal matrix `D` contains the associated eigenvalues,
98+ selected according to a truncation strategy. The truncation error is *not* returned.
99+
100+ ## Truncation
101+ The truncation strategy can be controlled via the `trunc` keyword argument. This can be
102+ either a `NamedTuple` or a [`TruncationStrategy`](@ref). If `trunc` is not provided or
103+ nothing, all values will be kept.
104+
105+ ### `trunc::NamedTuple`
106+ The supported truncation keyword arguments are:
107+
108+ $docs_truncation_kwargs
109+
110+ ### `trunc::TruncationStrategy`
111+ For more control, a truncation strategy can be supplied directly.
112+ By default, MatrixAlgebraKit supplies the following:
113+
114+ $docs_truncation_strategies
115+
116+ ## Keyword Arguments
117+ Other keyword arguments are passed to the algorithm selection procedure. If no explicit
118+ `alg` is provided, these keywords are used to select and configure the algorithm through
119+ [`MatrixAlgebraKit.select_algorithm`](@ref). The remaining keywords after algorithm
120+ selection are passed to the algorithm constructor. See [`MatrixAlgebraKit.default_algorithm`](@ref)
121+ for the default algorithm selection behavior.
122+
123+ When `alg` is a [`TruncatedAlgorithm`](@ref), the `trunc` keyword cannot be specified as the
124+ truncation strategy is already embedded in the algorithm.
125+
126+ !!! note
127+ The bang method `eig_trunc!` optionally accepts the output structure and
128+ possibly destroys the input matrix `A`. Always use the return value of the function
129+ as it may not always be possible to use the provided `DV` as output.
130+
131+ !!! note
132+ $docs_eig_note
133+
134+ See also [`eig_full(!)`](@ref eig_full), [`eig_vals(!)`](@ref eig_vals),
135+ [`eig_trunc(!)`](@ref eig_trunc) and [Truncations](@ref) for more
136+ information on truncation strategies.
137+ """
138+ @functiondef eig_trunc_no_error
139+
87140"""
88141 eig_vals(A; kwargs...) -> D
89142 eig_vals(A, alg::AbstractAlgorithm) -> D
@@ -121,13 +174,15 @@ for f in (:eig_full!, :eig_vals!)
121174 end
122175end
123176
124- function select_algorithm (:: typeof (eig_trunc!), A, alg; trunc = nothing , kwargs... )
125- if alg isa TruncatedAlgorithm
126- isnothing (trunc) ||
127- throw (ArgumentError (" `trunc` can't be specified when `alg` is a `TruncatedAlgorithm`" ))
128- return alg
129- else
130- alg_eig = select_algorithm (eig_full!, A, alg; kwargs... )
131- return TruncatedAlgorithm (alg_eig, select_truncation (trunc))
177+ for f in (:eig_trunc! , :eig_trunc_no_error! )
178+ @eval function select_algorithm (:: typeof ($ f), A, alg; trunc = nothing , kwargs... )
179+ if alg isa TruncatedAlgorithm
180+ isnothing (trunc) ||
181+ throw (ArgumentError (" `trunc` can't be specified when `alg` is a `TruncatedAlgorithm`" ))
182+ return alg
183+ else
184+ alg_eig = select_algorithm (eig_full!, A, alg; kwargs... )
185+ return TruncatedAlgorithm (alg_eig, select_truncation (trunc))
186+ end
132187 end
133188end
0 commit comments