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
## Truncation with SVD vs Eigenvalue Decompositions
102
-
103
-
When using truncations with different decomposition types, keep in mind:
104
-
105
-
-**`svd_trunc`**: Singular values are always real and non-negative, sorted in descending order. Truncation by value typically keeps the largest singular values.
106
-
107
-
-**`eigh_trunc`**: Eigenvalues are real but can be negative for symmetric matrices. By default, `truncrank` sorts by absolute value, so `truncrank(k)` keeps the `k` eigenvalues with largest magnitude (positive or negative).
108
-
109
-
-**`eig_trunc`**: For general (non-symmetric) matrices, eigenvalues can be complex. Truncation by absolute value considers the complex magnitude.
110
-
111
95
## Truncation Strategies
112
96
113
97
MatrixAlgebraKit provides several built-in truncation strategies:
@@ -127,3 +111,31 @@ When strategies are combined, only the values that satisfy all conditions are ke
When using truncated decompositions such as [`svd_trunc`](@ref), [`eig_trunc`](@ref), or [`eigh_trunc`](@ref), an additional truncation error value is returned.
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.
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
+
121
+
122
+
For example:
123
+
```jldoctest truncations; output=false
124
+
using LinearAlgebra: norm
125
+
U, S, Vᴴ, ϵ = svd_trunc(A; trunc=truncrank(2))
126
+
norm(A - U * S * Vᴴ) ≈ ϵ # ϵ is the 2-norm of the discarded singular values
127
+
128
+
# output
129
+
true
130
+
```
131
+
132
+
### Truncation with SVD vs Eigenvalue Decompositions
133
+
134
+
When using truncations with different decomposition types, keep in mind:
135
+
136
+
-**[`svd_trunc`](@ref)**: Singular values are always real and non-negative, sorted in descending order. Truncation by value typically keeps the largest singular values. The truncation error gives the 2-norm difference between the original and the truncated matrix.
137
+
138
+
-**[`eigh_trunc`](@ref)**: Eigenvalues are real but can be negative for symmetric matrices. By default, eigenvalues are treated by absolute value, e.g. `truncrank(k)` keeps the `k` eigenvalues with largest magnitude (positive or negative). The truncation error gives the 2-norm difference between the original and the truncated matrix.
139
+
140
+
-**[`eig_trunc`](@ref)**: For general (non-symmetric) matrices, eigenvalues can be complex. By default, eigenvalues are treated by absolute value. The truncation error gives an indication of the magnitude of discarded values, but is not directly related to the 2-norm difference between the original and the truncated matrix.
0 commit comments