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.q6jFunction
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 k and q are omitted, returns the abstract DCR object.
  • If k is provided, projects to the root of unity (Float64 by default, Cyclotomic if exact=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 unity k).
source
QRecoupling.q3jFunction
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.

source

Other TQFT Tensors

Composite tensors and network invariants used in the construction of 3D TQFTs, spin foam models, and string-net models.

QRecoupling.qdimFunction
qdim(j; k=nothing, q=nothing, exact::Bool=false, T=Float64)

Quantum dimension [2j+1]_q.

source
QRecoupling.rmatrixFunction
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.

source
QRecoupling.fsymbolFunction
fsymbol(j1, j2, j3, j4, j5, j6; k=nothing, q=nothing, exact::Bool=false, T=Float64)

Unitary crossing matrix element: √([d3][d6]) * {6j}.

source
QRecoupling.gsymbolFunction
gsymbol(j1, j2, j3, j4, j5, j6; k=nothing, q=nothing, exact::Bool=false, T=Float64)

Tetrahedrally symmetric invariant: √(Π[di]) * {6j}.

source

$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.qintFunction
qint(n::Int, p::Int=1)

Returns the algebraic representation of ([n]_q)^p as a CyclotomicMonomial.

source
QRecoupling.qfactFunction
qfact(n::Int, p::Int=1)

Returns the algebraic representation of ([n]_q!)^p as a CyclotomicMonomial.

source
QRecoupling.qbinomialFunction
qbinomial(n::Int, k::Int)

Returns the cyclotomic monomial for the quantum binomial coefficient [n]_q! / ([k]_q! [n-k]_q!).

source

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.qseriesFunction
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))
end
source
QRecoupling.build_seriesFunction
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.

source
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 (default false): If true, searches the prefactor for perfect squares and separates them into the root and radical fields.
  • alternating_sign::Bool (default false): If true, automatically injects a (-1)^z term into the sequence (standard for recoupling invariants).
source
QRecoupling.qevalFunction
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).
source
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).
source
QRecoupling.CyclotomicMonomialType
CyclotomicMonomial

An 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.

source
QRecoupling.DCRType
DCR

The Deferred Cyclotomic Representation: A combinatorial skeleton of a q-hypergeometric series. Separates combinatorial summation from numerical/geometrical projection.

source

Low-Level Buffer Operations & Projections

For developers building advanced, memory-optimized loops or requesting specific projection regimes directly without routing through qeval.

QRecoupling.project_discreteFunction
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)

source
project_discrete(res::DCR, k::Int, ::Type{T}=Float64)

Thread-safe, Zero-Allocation evaluator for full DCR symbols (e.g., 6j, 3j).

source
QRecoupling.project_exactFunction
project_exact(m::CyclotomicMonomial, k::Int)

Evaluates a single monomial exactly. Returns a Nemo nf_elem.

source
project_exact(dcr::DCR, k::Int)

Evaluates a DCR series exactly for discrete level k. Returns a CompositeExactResult.

source
QRecoupling.project_classicalFunction
project_classical(m::CyclotomicMonomial, ::Type{T}=Float64) -> T

Evaluate monomial m at q -> 1. Returns a real value of type T.

source
project_classical(dcr::DCR, ::Type{T}=Float64) -> T

Evaluate the full DCR series at q -> 1 using a single-pass Streaming Log-Sum-Exp algorithm to prevent overflow/underflow.

source
QRecoupling.project_classical_exactFunction
project_classical_exact(m::CyclotomicMonomial) -> ClassicalResult

Evaluate monomial m exactly at q → 1. Returns a ClassicalResult encodes σ · √(val) where val is a Rational{BigInt}.

source
project_classical_exact(dcr::DCR) -> ClassicalResult

Evaluate the full DCR series exactly at q -> 1 as a Rational{BigInt}.

Algorithm (four passes, no GCD on every ratio):

  1. Find the global denominator exponents
  2. Denominator + N_0 reconstruction
  3. Sum hot loop — accumulate numerators over D_glob
  4. Fuse prefactor — multiply root and radical

Function is fully thread-safe.

source
QRecoupling.project_analyticFunction
project_analytic(m::CyclotomicMonomial, q::Number)

Evaluates a single quantum monomial

source
project_analytic(dcr::DCR, q::Number)

Fast, thread-safe for evaluating TQFT symbols at any generic q.

source

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.