Skip to content

Commit 4d2fd63

Browse files
committed
update docs
1 parent e4da1ca commit 4d2fd63

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

docs/src/user_interface/decompositions.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ eigh_trunc
7272
eigh_vals
7373
```
7474

75+
!!! note "Gauge Degrees of Freedom"
76+
The eigenvectors returned by these functions have residual phase degrees of freedom.
77+
By default, MatrixAlgebraKit applies a gauge fixing convention to ensure reproducible results.
78+
See [Gauge choices](@ref sec_gaugefix) for more details.
79+
7580
Alongside these functions, we provide a LAPACK-based implementation for dense arrays, as provided by the following algorithms:
7681

7782
```@autodocs; canonical=false
@@ -89,6 +94,11 @@ eig_trunc
8994
eig_vals
9095
```
9196

97+
!!! note "Gauge Degrees of Freedom"
98+
The eigenvectors returned by these functions have residual phase degrees of freedom.
99+
By default, MatrixAlgebraKit applies a gauge fixing convention to ensure reproducible results.
100+
See [Gauge choices](@ref sec_gaugefix) for more details.
101+
92102
Alongside these functions, we provide a LAPACK-based implementation for dense arrays, as provided by the following algorithms:
93103

94104
```@autodocs; canonical=false
@@ -137,6 +147,11 @@ svd_vals
137147
svd_trunc
138148
```
139149

150+
!!! note "Gauge Degrees of Freedom"
151+
The singular vectors returned by these functions have residual phase degrees of freedom.
152+
By default, MatrixAlgebraKit applies a gauge fixing convention to ensure reproducible results.
153+
See [Gauge choices](@ref sec_gaugefix) for more details.
154+
140155
MatrixAlgebraKit again ships with LAPACK-based implementations for dense arrays:
141156

142157
```@autodocs; canonical=false
@@ -371,3 +386,47 @@ norm(A * N1') < 1e-14 && norm(A * N2') < 1e-14 &&
371386
# output
372387
true
373388
```
389+
390+
## [Gauge choices](@id sec_gaugefix)
391+
392+
Both eigenvalue and singular value decompositions have residual gauge degrees of freedom even when the eigenvalues or singular values are unique.
393+
These arise from the fact that even after normalization, the eigenvectors and singular vectors are only determined up to a phase factor.
394+
395+
### Phase Ambiguity in Decompositions
396+
397+
For the eigenvalue decomposition `A * V = V * D`, if `v` is an eigenvector with eigenvalue `λ` and `|v| = 1`, then so is `e^(iθ) * v` for any real phase `θ`.
398+
When `λ` is non-degenerate (i.e., has multiplicity 1), the eigenvector is unique up to this phase.
399+
400+
Similarly, for the singular value decomposition `A = U * Σ * Vᴴ`, the singular vectors `u` and `v` corresponding to a non-degenerate singular value `σ` are unique only up to a common phase.
401+
We can replace `u → e^(iθ) * u` and `vᴴ → e^(-iθ) * vᴴ` simultaneously.
402+
403+
### Gauge Fixing Convention
404+
405+
To remove this phase ambiguity and ensure reproducible results, MatrixAlgebraKit implements a gauge fixing convention by default.
406+
The convention ensures that **the entry with the largest magnitude in each eigenvector or left singular vector is real and positive**.
407+
408+
For eigenvectors, this means that for each column `v` of `V`, we multiply by `conj(sign(v[i]))` where `i` is the index of the entry with largest absolute value.
409+
410+
For singular vectors, we apply the phase factor to both `u` and `v` based on the entry with largest magnitude in `u`.
411+
This preserves the decomposition `A = U * Σ * Vᴴ` while fixing the gauge.
412+
413+
### Disabling Gauge Fixing
414+
415+
Gauge fixing is enabled by default for all eigenvalue and singular value decompositions.
416+
If you prefer to obtain the raw results from the underlying LAPACK routines without gauge fixing, you can disable it using the `gaugefix` keyword argument:
417+
418+
```julia
419+
# With gauge fixing (default)
420+
D, V = eigh_full(A)
421+
422+
# Without gauge fixing
423+
D, V = eigh_full(A; gaugefix = false)
424+
```
425+
426+
The same keyword is available for `eig_full`, `eig_trunc`, `svd_full`, `svd_compact`, and `svd_trunc` functions.
427+
428+
```@docs; canonical=false
429+
MatrixAlgebraKit.gaugefix!
430+
```
431+
432+

0 commit comments

Comments
 (0)