You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using truncated decompositions such as [`svd_trunc`](@ref), [`eig_trunc`](@ref), or [`eigh_trunc`](@ref), an additional truncation error value is returned.
116
+
When using truncated decompositions such as [`svd_trunc_with_err`](@ref), [`eig_trunc`](@ref), or [`eigh_trunc`](@ref), an additional truncation error value is returned.
117
117
This error is defined as the 2-norm of the discarded singular values or eigenvalues, providing a measure of the approximation quality.
118
-
For `svd_trunc` and `eigh_trunc`, this corresponds to the 2-norm difference between the original and the truncated matrix.
118
+
For `svd_trunc_with_err` and `eigh_trunc`, this corresponds to the 2-norm difference between the original and the truncated matrix.
119
119
For the case of `eig_trunc`, this interpretation does not hold because the norm of the non-unitary matrix of eigenvectors and its inverse also influence the approximation quality.
120
120
121
121
122
122
For example:
123
123
```jldoctest truncations; output=false
124
124
using LinearAlgebra: norm
125
-
U, S, Vᴴ, ϵ = svd_trunc(A; trunc=truncrank(2))
125
+
U, S, Vᴴ, ϵ = svd_trunc_with_err(A; trunc=truncrank(2))
126
126
norm(A - U * S * Vᴴ) ≈ ϵ # ϵ is the 2-norm of the discarded singular values
abs(dy[4]) > MatrixAlgebraKit.defaulttol(dy[4]) &&@warn"Pullback for svd_trunc! does not yet support non-zero tangent for the truncation error"
322
+
abs(dy[4]) > MatrixAlgebraKit.defaulttol(dy[4]) &&@warn"Pullback for svd_trunc_with_err does not yet support non-zero tangent for the truncation error"
323
+
U, dU =arrayify(Utrunc, dUtrunc_)
324
+
S, dS =arrayify(Strunc, dStrunc_)
325
+
Vᴴ, dVᴴ =arrayify(Vᴴtrunc, dVᴴtrunc_)
326
+
svd_trunc_pullback!(dA, A, (U, S, Vᴴ), (dU, dS, dVᴴ))
0 commit comments