@@ -28,6 +28,9 @@ The keyword argument `kind` can be used to specify the specific orthogonal decom
2828that should be used to factor `A`, whereas `trunc` can be used to control the
2929precision in determining the rank of `A` via its singular values.
3030
31+ `trunc` can either be a truncation strategy object or a NamedTuple with fields
32+ `atol`, `rtol`, and `maxrank`.
33+
3134This is a high-level wrapper and will use one of the decompositions
3235`qr_compact!`, `svd_compact!`/`svd_trunc!`, and `left_polar!` to compute the orthogonal basis `V`, as controlled
3336by the keyword arguments.
@@ -75,15 +78,18 @@ function left_orth(A::AbstractMatrix; kwargs...)
7578end
7679
7780"""
78- right_orth(A; [kind::Symbol, atol::Real=0, rtol::Real=0, alg ]) -> C, Vᴴ
79- right_orth!(A, [CVᴴ]; [kind::Symbol, atol::Real=0, rtol::Real=0, alg ]) -> C, Vᴴ
81+ right_orth(A; [kind::Symbol, trunc, alg_lq, alg_polar, alg_svd ]) -> C, Vᴴ
82+ right_orth!(A, [CVᴴ]; [kind::Symbol, trunc, alg_lq, alg_polar, alg_svd ]) -> C, Vᴴ
8083
8184Compute an orthonormal basis `V = adjoint(Vᴴ)` for the coimage of the matrix `A`, i.e.
8285for the image of `adjoint(A)`, as well as a matrix `C` such that `A = C * Vᴴ`.
8386The keyword argument `kind` can be used to specify the specific orthogonal decomposition
8487that should be used to factor `A`, whereas `trunc` can be used to control the
8588precision in determining the rank of `A` via its singular values.
8689
90+ `trunc` can either be a truncation strategy object or a NamedTuple with fields
91+ `atol`, `rtol`, and `maxrank`.
92+
8793This is a high-level wrapper and will use call one of the decompositions
8894`lq_compact!`, `svd_compact!`/`svd_trunc!`, and `right_polar!` to compute the
8995orthogonal basis `V`, as controlled by the keyword arguments.
@@ -109,7 +115,7 @@ When `kind` is not provided, the default value is `:lq` when `isnothing(trunc)`
109115and `:svd` otherwise. Finally, finer control is obtained by providing an explicit algorithm
110116for backend factorizations through the `alg_lq`, `alg_polar`, and `alg_svd` keyword arguments,
111117which will only be used if the corresponding factorization is called based on the other inputs.
112- If NamedTuples are passed as `alg_lq`, `alg_polar`, or `alg_svd`, a default algorithm is chosen
118+ If `alg_lq`, `alg_polar`, or `alg_svd` are NamedTuples , a default algorithm is chosen
113119with `select_algorithm` and the NamedTuple is passed as keyword arguments to that algorithm.
114120`alg_lq` defaults to `(; positive=true)` so that by default a positive QR decomposition will
115121be used.
@@ -133,36 +139,38 @@ end
133139# Null functions
134140# --------------
135141"""
136- left_null(A; [kind::Symbol, atol::Real=0, rtol::Real=0, alg ]) -> N
137- left_null!(A, [N]; [kind::Symbol, atol::Real=0, rtol::Real=0, alg ]) -> N
142+ left_null(A; [kind::Symbol, trunc, alg_qr, alg_svd ]) -> N
143+ left_null!(A, [N]; [kind::Symbol, alg_qr, alg_svd ]) -> N
138144
139145Compute an orthonormal basis `N` for the cokernel of the matrix `A` of size `(m, n)`, i.e.
140146the nullspace of `adjoint(A)`, such that `adjoint(A)*N ≈ 0` and `N'*N ≈ I`.
141147The keyword argument `kind` can be used to specify the specific orthogonal decomposition
142- that should be used to factor `A`, whereas `atol` and `rtol` can be used to control the
143- precision in determining the rank of `A` via its singular values.
148+ that should be used to factor `A`, whereas `trunc` can be used to control the
149+ the rank of `A` via its singular values.
150+
151+ `trunc` can either be a truncation strategy object or a NamedTuple with fields
152+ `atol`, `rtol`, and `maxrank`.
144153
145154This is a high-level wrapper and will use one of the decompositions `qr!` or `svd!`
146155to compute the orthogonal basis `N`, as controlled by the keyword arguments.
147156
148157When `kind` is provided, its possible values are
149158
150- * `kind == :qrpos `: `N` is computed using the positive QR decomposition.
151- This requires `iszero(atol) && iszero(rtol) ` and `left_null!(A, [N], kind=:qrpos )` is equivalent to
159+ * `kind == :qr `: `N` is computed using the QR decomposition.
160+ This requires `isnothing(trunc) ` and `left_null!(A, [N], kind=:qr )` is equivalent to
152161 `qr_null!(A, [N], alg)` with a default value `alg = select_algorithm(qr_compact!, A; positive=true)`
153162
154- * `kind == :qr`: `N` is computed using the (nonpositive) QR decomposition.
155- This requires `iszero(atol) && iszero(rtol)` and `left_null!(A, [N], kind=:qr)` is equivalent to
156- `qr_null!(A, [N], alg)` with a default value `alg = select_algorithm(qr_compact!, A)`
157-
158163* `kind == :svd`: `N` is computed using the singular value decomposition and will contain
159- the left singular vectors corresponding to the singular values that
160- are smaller than `max(atol, rtol * σ₁)`, where `σ₁` is the largest singular value of `A `.
164+ the left singular vectors corresponding to either the zero singular values if `trunc`
165+ isn't specified or the singular values specified by `trunc `.
161166
162- When `kind` is not provided, the default value is `:qrpos ` when `iszero(atol) && iszero(rtol )`
167+ When `kind` is not provided, the default value is `:qr ` when `isnothing(trunc )`
163168and `:svd` otherwise. Finally, finer control is obtained by providing an explicit algorithm
164- using the `alg` keyword argument, which should be compatible with the chosen or default value
165- of `kind`.
169+ using the `alg_qr` and `alg_svd` keyword arguments, which will only be used by the corresponding
170+ factorization backend. If `alg_qr` or `alg_svd` are NamedTuples, a default algorithm is chosen
171+ with `select_algorithm` and the NamedTuple is passed as keyword arguments to that algorithm.
172+ `alg_qr` defaults to `(; positive=true)` so that by default a positive QR decomposition will
173+ be used.
166174
167175!!! note
168176 The bang method `left_null!` optionally accepts the output structure and possibly destroys
@@ -181,33 +189,32 @@ function left_null(A::AbstractMatrix; kwargs...)
181189end
182190
183191"""
184- right_null(A; [kind::Symbol, atol::Real=0, rtol::Real=0, alg ]) -> Nᴴ
185- right_null!(A, [Nᴴ]; [kind::Symbol, atol::Real=0, rtol::Real=0, alg ]) -> Nᴴ
192+ right_null(A; [kind::Symbol, alg_lq, alg_svd ]) -> Nᴴ
193+ right_null!(A, [Nᴴ]; [kind::Symbol, alg_lq, alg_svd ]) -> Nᴴ
186194
187195Compute an orthonormal basis `N = adjoint(Nᴴ)` for the kernel or nullspace of the matrix `A`
188196of size `(m, n)`, such that `A*adjoint(Nᴴ) ≈ 0` and `Nᴴ*adjoint(Nᴴ) ≈ I`.
189197The keyword argument `kind` can be used to specify the specific orthogonal decomposition
190- that should be used to factor `A`, whereas `atol` and `rtol` can be used to control the
191- precision in determining the rank of `A` via its singular values.
198+ that should be used to factor `A`, whereas `trunc` can be used to control the
199+ the rank of `A` via its singular values.
200+
201+ `trunc` can either be a truncation strategy object or a NamedTuple with fields
202+ `atol`, `rtol`, and `maxrank`.
192203
193204This is a high-level wrapper and will use one of the decompositions `lq!` or `svd!`
194205to compute the orthogonal basis `Nᴴ`, as controlled by the keyword arguments.
195206
196207When `kind` is provided, its possible values are
197208
198- * `kind == :lqpos`: `Nᴴ` is computed using the positive LQ decomposition.
199- This requires `iszero(atol) && iszero(rtol)` and `right_null!(A, [Nᴴ], kind=:lqpos)` is equivalent to
200- `lq_null!(A, [Nᴴ], alg)` with a default value `alg = select_algorithm(lq_compact!, A; positive=true)`
201-
202209* `kind == :lq`: `Nᴴ` is computed using the (nonpositive) LQ decomposition.
203- This requires `iszero(atol) && iszero(rtol )` and `right_null!(A, [Nᴴ], kind=:lq)` is equivalent to
204- `lq_null!(A, [Nᴴ], alg)` with a default value `alg = select_algorithm(lq_compact!, A)`
210+ This requires `isnothing(trunc )` and `right_null!(A, [Nᴴ], kind=:lq)` is equivalent to
211+ `lq_null!(A, [Nᴴ], alg)` with a default value `alg = select_algorithm(lq_compact!, A; positive=true )`
205212
206213* `kind == :svd`: `N` is computed using the singular value decomposition and will contain
207214 the left singular vectors corresponding to the singular values that
208215 are smaller than `max(atol, rtol * σ₁)`, where `σ₁` is the largest singular value of `A`.
209216
210- When `kind` is not provided, the default value is `:lqpos ` when `iszero(atol) && iszero(rtol )`
217+ When `kind` is not provided, the default value is `:lq ` when `isnothing(trunc )`
211218and `:svd` otherwise. Finally, finer control is obtained by providing an explicit algorithm
212219using the `alg` keyword argument, which should be compatible with the chosen or default value
213220of `kind`.
0 commit comments