-
Notifications
You must be signed in to change notification settings - Fork 5
Documentation overhaul #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lkdvos
wants to merge
19
commits into
main
Choose a base branch
from
ld-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
7607f73
docs: set up documentation skeleton
lkdvos cf59c97
docs: document required sector interface methods
lkdvos 3a5e123
docs: document optional sector interface methods
lkdvos 44fdfa6
docs: document trait-based dispatch
lkdvos bec932b
docs: add implementation guidelines for new sectors
lkdvos fba44f9
docs: document SU2Irrep sector
lkdvos 7e56317
ci: add PR_comment workflow
lkdvos da40bfe
a4
borisdevos 1d94788
minor su2 changes
borisdevos eec4428
small a4 change
borisdevos 6e7a417
u1
borisdevos 4d6a31f
trivial and planartrivial
borisdevos 522de26
ising and fibonacci
borisdevos 4776631
zn
borisdevos f5d8892
fermions
borisdevos 7d15f9e
dn
borisdevos cef7492
cu1
borisdevos deb2cc0
product and timereversed
borisdevos cacb039
jldoctest block fix
borisdevos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| name: Docs preview comment | ||
| on: | ||
| pull_request: | ||
| types: [labeled] | ||
|
|
||
| permissions: | ||
| pull-requests: write | ||
| jobs: | ||
| pr_comment: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Create PR comment | ||
| if: github.event_name == 'pull_request' && github.repository == github.event.pull_request.head.repo.full_name && github.event.label.name == 'documentation' | ||
| uses: thollander/actions-comment-pull-request@v3 | ||
| with: | ||
| message: 'After the build completes, the updated documentation will be available [here](https://quantumkithub.github.io/TensorKitSectors.jl/previews/PR${{ github.event.number }}/)' | ||
| comment-tag: 'preview-doc' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| [deps] | ||
| Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" | ||
| TensorKitSectors = "13a9c161-d5da-41f0-bcbd-e1a08ae0647f" | ||
| TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2" | ||
|
|
||
| [compat] | ||
| Documenter = "1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| ```@meta | ||
| CollapsedDocStrings = true | ||
| ``` | ||
|
|
||
| # Implementation Guidelines | ||
|
|
||
| This section provides practical advice for implementing new sector types efficiently and correctly. | ||
|
|
||
| ## Helper Type: SectorProductIterator | ||
|
|
||
| Instead of materializing all fusion outputs in a tuple or array, one can use `SectorProductIterator` for type-stable, lazy iteration. | ||
|
|
||
| ```@docs; canonical = false | ||
| TensorKitSectors.SectorProductIterator | ||
| ``` | ||
|
|
||
| This is enabled by default, and new sectors should provide implementations for the following functions: | ||
|
|
||
| ```julia | ||
| Base.iterate(ab::SectorProductIterator{I}, [state]) = ... | ||
| # optional optimizations: | ||
| Base.IteratorSize(::Type{SectorProductIterator{I}}) = HasLength() | ||
| Base.length(ab::SectorProductIterator{I}) = ... | ||
| ``` | ||
|
|
||
| This has the benefit of helping with type stability, and has a pretty-printing overload: | ||
|
|
||
| ```@example | ||
| using TensorKitSectors # hide | ||
| SU2Irrep(1) ⊗ SU2Irrep(1) | ||
| ``` | ||
|
|
||
| ## Shape of Topological Data | ||
|
|
||
| The size of [`Fsymbol`](@ref) and [`Rsymbol`](@ref) data depends on the fusion multiplicities ([`Nsymbol`](@ref)). | ||
| For multiplicity‑free sectors scalars are sufficient; for generic fusion we need arrays. | ||
| Therefore, we distinguish the behavior through the [`FusionStyle`](@ref). | ||
|
|
||
|
|
||
| ### [`MultiplicityFreeFusion`](@ref) | ||
|
|
||
| - `Nsymbol(a, b, c)`: Returns a `Bool`. | ||
| - `Fsymbol(a, b, c, d, e, f)`: Returns a scalar of type `sectorscalartype(I)`. | ||
| - `Rsymbol(a, b, c)`: Returns a scalar of type `sectorscalartype(I)`. | ||
|
|
||
| Additionally, if the [`Fsymbol`](@ref) and [`Rsymbol`](@ref) do not correspond to valid fusion channels, the result is ``0``. | ||
| Therefore, computing the number of valid fusion channels for both diagrams as the product of the relevant [`Nsymbol`](@ref)s, we have: | ||
|
|
||
| ```math | ||
| \left(N^{ab}_e N^{ec}_d = 0 \lor N^{af}_d N^{bc}_f = 0\right) \implies (F_{abc}^d)^e_f = 0 | ||
| ``` | ||
|
|
||
| ```math | ||
| N^{ab}_c = 0 \implies R^{ab}_c = 0 | ||
| ``` | ||
|
|
||
| ### [`GenericFusion`](@ref) | ||
|
|
||
| - `Nsymbol(a, b, c)`: Returns a positive `Integer`. | ||
| - `Fsymbol(a, b, c, d, e, f)`: Returns a ``N^{ab}_e \times N^{ec}_d \times N^{af}_d \times N^{bc}_f`` array of `sectorscalartype(I)` elements. | ||
| - `Rsymbol(a, b, c)`: Returns a ``N^{ab}_c \times N^{ba}_c`` array of `sectorscalartype(I)` elements. | ||
|
|
||
| Here invalid fusion channels will necessarily lead to empty arrays. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| ```@meta | ||
| CollapsedDocStrings = true | ||
| ``` | ||
|
|
||
| # Optional Methods | ||
|
|
||
| The following methods have default implementations but can be overridden for performance or to provide additional functionality. | ||
|
|
||
| ## Quantum Dimensions | ||
|
|
||
| The quantum dimension of a sector is a fundamental invariant that determines the behavior of fusions and braiding. | ||
| The default implementation extracts the dimension from [`Fsymbol`](@ref) via the quantum dimension formula. | ||
|
|
||
| ```math | ||
|
lkdvos marked this conversation as resolved.
|
||
| d_a = \left| \frac{1}{(F_{a \bar{a} a}^a)^{1_a}_{_a1} } \right| | ||
| ``` | ||
|
|
||
| For many common sectors, however, the dimension is known directly from representation theory. | ||
| In these cases, it can be beneficial to overload [`dim`](@ref) to bypass computing F-symbols, either for performance reasons or to enforce tighter output types. | ||
| For example, dimensions of irreducible representations of groups are always integers. | ||
|
|
||
| ```@docs; canonical = false | ||
| dim | ||
| sqrtdim | ||
| invsqrtdim | ||
| ``` | ||
|
|
||
| ## Frobenius-Schur Indicators | ||
|
|
||
| The Frobenius-Schur indicator and phase characterize the self-duality properties of sectors. | ||
|
|
||
| ```math | ||
| \kappa_a = \text{sign}\left( (F_{a \bar{a} a}^a)^{1_a}_{_a1} \right) | ||
|
lkdvos marked this conversation as resolved.
|
||
| ``` | ||
|
|
||
| The indicator distinguishes real, complex, and quaternionic representations. | ||
| The phase is the category-theoretic version that appears in line bending operations. | ||
|
|
||
| ```@docs; canonical = false | ||
| frobenius_schur_indicator | ||
| frobenius_schur_phase | ||
| ``` | ||
|
|
||
| ## Scalar Type | ||
|
|
||
| Various utility functions exist for determining what number type is used in various parts of the topological data. | ||
|
|
||
| ```@docs; canonical = false | ||
| fusionscalartype | ||
| braidingscalartype | ||
| dimscalartype | ||
| sectorscalartype | ||
| ``` | ||
|
|
||
| !!! note | ||
| While there is a fallback definition that tries to determine the result from computing the functions on the unit sector, | ||
| it is often a good idea to define this method explicitly to avoid depending on compiler heuristics to constant-fold these calls. | ||
|
|
||
| ## Topological Data Symbols | ||
|
|
||
| The [`Asymbol`](@ref), [`Bsymbol`](@ref) and [`twist`](@ref) are derived from F- and R-symbols but are often occurring combinations. | ||
| The A-symbol and B-symbol relate different ways of bending strands, while the twist is the topological spin (quantum dimension phase) of a sector. | ||
|
|
||
| The A-symbol ``A^{ab}_c`` relates splitting and fusion vertices: | ||
| ```math | ||
| A^{ab}_c = \sqrt{\frac{d_a d_b}{d_c}} \overline{\kappa_a} (F_{\bar{a} a b}^b)^1_c | ||
| ``` | ||
|
|
||
| The B-symbol ``B^{ab}_c`` relates splitting and fusion vertices: | ||
| ```math | ||
| B^{ab}_c = \sqrt{\frac{d_a d_b}{d_c}} (F_{a b \bar{b}}^a)^c_1 | ||
| ``` | ||
|
|
||
| The twist ``\theta_a`` of a sector is the topological spin phase, computed as the trace of the R-matrix for braiding a sector with itself: | ||
| ```math | ||
| \theta_a = \frac{1}{d_a} \sum_{b \in a \otimes a} d_b \text{tr}(R^{aa}_b) | ||
| ``` | ||
|
|
||
| ```@docs; canonical = false | ||
| Asymbol | ||
| Bsymbol | ||
| twist | ||
| ``` | ||
|
|
||
| ## Fusion Basis | ||
|
|
||
| The fusion tensor provides explicit matrix elements for the tensor product of representations. | ||
| It is a rank-4 array whose components are the Clebsch-Gordan coefficients for fusing sector `a` and `b` into `c`. | ||
| The fusion tensor is not uniquely determined by topological data alone, instead the topological data can be extracted from it when it is available. | ||
| However, there is not always a concrete representation of these tensors in terms of simple `Array` objects, and the exact representation is not important for TensorKit.jl. | ||
| For this reason, it is optional: TensorKit can work with the topological data alone. | ||
| Note however that they are still required whenever we want to convert symmetric tensors to and from dense arrays. | ||
|
|
||
| ```@docs; canonical = false | ||
| fusiontensor | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # Sector Interface | ||
|
|
||
| ## Introduction | ||
|
|
||
| A `Sector` is a label for the different *symmetry charges* or *quantum numbers* that organize graded vector spaces. | ||
| In particular, these are the labels use to decompose vector spaces as: | ||
|
|
||
| ```math | ||
| V = \bigoplus_{a \in \text{Sectors}} \mathbb{C}^{n_a} \otimes V_a | ||
| ``` | ||
|
|
||
| where ``n_a`` is the multiplicity of sector ``a`` and ``V_a`` is the associated vector space. | ||
|
|
||
| Sectors encode the structural rules TensorKit needs: | ||
| - **Objects**: the labels themselves (irreps, anyons, …) | ||
| - **Fusion rules**: which labels appear in ``a \otimes b \rightarrow \bigoplus_c N^{ab}_c c`` | ||
| - **Associativity**: how different parenthesizations are related | ||
| - **Braiding**: how labels behave under exchange (if supported) | ||
|
|
||
| More rigorously, a `Sector` represents the isomorphism classes of simple objects in unitary and pivotal fusion categories. | ||
| This package defines an interface for accessing the topological data that is associated to these categories. | ||
| This section explains the required and optional methods needed to create a new sector type. | ||
| Once this interface is fulfilled, TensorKit.jl will create symmetric tensors that correspond to the implemented sector. | ||
|
|
||
| ## Organization | ||
|
|
||
| The interface documentation is divided into several pages: | ||
|
|
||
| - **[Required Methods](required.md)**: The minimum interface needed for a valid sector type | ||
| - **[Optional Methods](optional.md)**: Additional methods with default implementations that can be specialized | ||
| - **[Traits and Styles](traits.md)**: Compile-time properties that control behavior and optimizations | ||
| - **[Implementation Guidelines](guidelines.md)**: Practical advice and helper types for implementing sectors |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.