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:
@@ -136,7 +120,22 @@ For the case of `eig_trunc`, this interpretation does not hold because the norm
136
120
137
121
138
122
For example:
139
-
```julia
140
-
U, S, Vᴴ, ϵ =svd_trunc(A; trunc=truncrank(10))
141
-
# ϵ is the 2-norm of the discarded singular values
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
142
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