API Reference
This page details the public API for QRecoupling.jl. Internal evaluations are abstracted away to provide a clean, unified interface.
Core Recoupling Symbols
The master dispatchers for evaluating $3j$ and $6j$ symbols. The computational regime is dynamically routed based on the provided target: integer level $k$ (Turaev-Viro), parameter $q$ (complex analytic), or $q=1$ (classical Ponzano-Regge limit). Precision is controlled via the exact boolean flag.
QRecoupling.q6j — Function
q6j(j1, j2, j3, j4, j5, j6; k=nothing, q=nothing, exact::Bool=false, eager::Bool=false, T=Float64)Returns the Quantum 6j-symbol.
- If
kandqare omitted, returns the abstractDCRobject. - If
kis provided, projects to the root of unity (Float64 by default, Cyclotomic ifexact=true). - If
q=1, computes the exact classical Ponzano-Regge limit. - If
eager=true, bypasses DCR construction for raw speed (only valid for root of unityk).
QRecoupling.q3j — Function
q3j(j1, j2, j3, m1, m2, m3; k=nothing, q=nothing, exact::Bool=false, eager::Bool=false, T=Float64)Returns the quantum Wigner 3j-symbol.
Other TQFT Tensors
Composite tensors and network invariants used in the construction of 3D TQFTs, spin foam models, and string-net models.
QRecoupling.qdim — Function
qdim(j; k=nothing, q=nothing, exact::Bool=false, T=Float64)Quantum dimension [2j+1]_q.
QRecoupling.rmatrix — Function
rmatrix(j1, j2, j3; k=nothing, q=nothing, exact::Bool=false, T=ComplexF64)Returns the R-matrix phase (braiding eigenvalue) for j1, j2 crossing into j3.
QRecoupling.fsymbol — Function
fsymbol(j1, j2, j3, j4, j5, j6; k=nothing, q=nothing, exact::Bool=false, T=Float64)Unitary crossing matrix element: √([d3][d6]) * {6j}.
QRecoupling.gsymbol — Function
gsymbol(j1, j2, j3, j4, j5, j6; k=nothing, q=nothing, exact::Bool=false, T=Float64)Tetrahedrally symmetric invariant: √(Π[di]) * {6j}.
$q$-Hypergeometric Primitives
Public primitives to easily build algebraic representations of $q$-deformed integers, factorials, and binomial coefficients. These functions return CyclotomicMonomial objects and are designed to be used inside the qseries sequence builder.
QRecoupling.qint — Function
qint(n::Int, p::Int=1)Returns the algebraic representation of ([n]_q)^p as a CyclotomicMonomial.
QRecoupling.qfact — Function
qfact(n::Int, p::Int=1)Returns the algebraic representation of ([n]_q!)^p as a CyclotomicMonomial.
QRecoupling.qbinomial — Function
qbinomial(n::Int, k::Int)Returns the cyclotomic monomial for the quantum binomial coefficient [n]_q! / ([k]_q! [n-k]_q!).
Generic Series & Universal Evaluation
QRecoupling.jl separates algebraic construction from field evaluation. These functions allow you to construct custom $q$-hypergeometric series and project abstract Deferred Cyclotomic Representation (DCR) objects into concrete target fields.
QRecoupling.qseries — Function
qseries(summand::Function, z_range::UnitRange{Int};
prefactor::CyclotomicMonomial = ONE_MONOMIAL,
extract_radical::Bool = false)A lightweight, user-friendly API for compiling a finite q-hypergeometric series into a Deferred Cyclotomic Representation (DCR).
Example
my_series = qseries(3:10) do z
return (-1)^z * (qfact(z) / qfact(z - 3))
endQRecoupling.build_series — Function
build_series(summand::Function, z_range::UnitRange; prefactor::CyclotomicMonomial=ONE_MONOMIAL, extract_radical::Bool=false)Constructs a DCR from a user-provided summand function. summand(z) must return a CyclotomicMonomial representing the z-th term in the series.
QRecoupling.build_dcr! — Function
build_dcr!(pref_func, base_func, ratio_func, z_min, z_max; kwargs...)The master DCR compiler. Generates the full combinatorial skeleton of an arbitrary sequence by orchestrating closures over a highly optimized CycloBuffer.
Keyword Arguments:
extract_radical::Bool(defaultfalse): If true, searches the prefactor for perfect squares and separates them into therootandradicalfields.alternating_sign::Bool(defaultfalse): If true, automatically injects a (-1)^z term into the sequence (standard for recoupling invariants).
QRecoupling.qeval — Function
qeval(m::CyclotomicMonomial; k=nothing, q=nothing, exact::Bool=false, T::Type=Float64)Universal evaluation API for a single CyclotomicMonomial.
- Classical Limit: Pass
q = 1. - Root of Unity (TQFT): Pass
k(integer level). - Complex Analytic: Pass
q(complex or real parameter). - Precision is controlled by
exact(Float64 vs Rational/Cyclotomic).
qeval(dcr::DCR; k=nothing, q=nothing, exact::Bool=false, T::Type=Float64)Universal evaluation API for a DCR.
- Classical Limit: Pass
q = 1. - Root of Unity (TQFT): Pass
k(integer level). - Complex Analytic: Pass
q(complex or real parameter). - Precision is controlled by
exact(Float64 vs Rational/Cyclotomic).
QRecoupling.CyclotomicMonomial — Type
CyclotomicMonomialAn unspecialized algebraic term: M(q) = σ * qᴾ * Π Φd(q)ᵉᵈ. Stored as a sparse, sorted vector of (d => exponent) pairs for efficiency. Φd(q) are cyclotomic polynomials.
QRecoupling.DCR — Type
DCRThe Deferred Cyclotomic Representation: A combinatorial skeleton of a q-hypergeometric series. Separates combinatorial summation from numerical/geometrical projection.
Low-Level Buffer Operations & Projections
For developers building advanced, memory-optimized loops or requesting specific projection regimes directly without routing through qeval.
QRecoupling.add_qint! — Function
add_qint!(buf::CycloBuffer, n::Int, p::Int=1)Algebraically multiplies the buffer by ([n]_q)^p.
QRecoupling.add_qfact! — Function
add_qfact!(buf::CycloBuffer, n::Int, p::Int=1)Algebraically multiplies the buffer by ([n]_q!)^p.
QRecoupling.project_discrete — Function
project_discrete(m::CyclotomicMonomial, k::Int, ::Type{T}=Float64)Evaluates [n]q or dimensions at SU(2)k. Returns the real value (signs are tracked, complex phases are ignored)
project_discrete(res::DCR, k::Int, ::Type{T}=Float64)Thread-safe, Zero-Allocation evaluator for full DCR symbols (e.g., 6j, 3j).
QRecoupling.project_exact — Function
project_exact(m::CyclotomicMonomial, k::Int)Evaluates a single monomial exactly. Returns a Nemo nf_elem.
project_exact(dcr::DCR, k::Int)Evaluates a DCR series exactly for discrete level k. Returns a CompositeExactResult.
QRecoupling.project_classical — Function
project_classical(m::CyclotomicMonomial, ::Type{T}=Float64) -> TEvaluate monomial m at q -> 1. Returns a real value of type T.
project_classical(dcr::DCR, ::Type{T}=Float64) -> TEvaluate the full DCR series at q -> 1 using a single-pass Streaming Log-Sum-Exp algorithm to prevent overflow/underflow.
QRecoupling.project_classical_exact — Function
project_classical_exact(m::CyclotomicMonomial) -> ClassicalResultEvaluate monomial m exactly at q → 1. Returns a ClassicalResult encodes σ · √(val) where val is a Rational{BigInt}.
project_classical_exact(dcr::DCR) -> ClassicalResultEvaluate the full DCR series exactly at q -> 1 as a Rational{BigInt}.
Algorithm (four passes, no GCD on every ratio):
- Find the global denominator exponents
- Denominator + N_0 reconstruction
- Sum hot loop — accumulate numerators over
D_glob - Fuse prefactor — multiply root and radical
Function is fully thread-safe.
QRecoupling.project_analytic — Function
project_analytic(m::CyclotomicMonomial, q::Number)Evaluates a single quantum monomial
project_analytic(dcr::DCR, q::Number)Fast, thread-safe for evaluating TQFT symbols at any generic q.
Memory & Cache Management
When changing the topological level $k$ drastically, performing exact computations in cyclotomic fields, or benchmarking tight loops, it is recommended to clear these caches to free RAM.
QRecoupling.empty_caches! — Function
empty_caches!()Useful for freeing RAM during long interactive sessions or resetting state for benchmarking.