Miscs API
Index
SymBasis.Miscs.all_permutationsSymBasis.Miscs.combos_boson_sumSymBasis.Miscs.combos_dof_sumSymBasis.Miscs.combos_spin_sumSymBasis.Miscs.invpermSymBasis.Miscs.perm_kSymBasis.Miscs.perm_wrapperSymBasis.Miscs.rtoldefaultSymBasis.Miscs.rtoldefaultSymBasis.Miscs.rtoldefault
SymBasis.Miscs.all_permutations — Method
all_permutations(t::NTuple{N,T}) where {N,T}Generate all permutations of the elements in the input tuple t.
Arguments
t::NTuple{N,T}: An N-tuple containing elements of typeT.
Returns
Vector{NTuple{N,T}}: A vector containing all permutations of the input tuplet.
SymBasis.Miscs.combos_boson_sum — Method
combos_boson_sum(
max_occupancy::Integer,
target::Integer,
n::T_n
) where {T_n<:Int}Generate all combinations of boson occupation numbers for n sites with a maximum occupancy of max_occupancy that sum to the specified target total particle number.
Arguments
max_occupancy::Integer: The maximum number of bosons allowed on a single site (e.g.,3for occupation numbers0, 1, 2, 3).target::Integer: The target total particle number (sum of all site occupancies).n::T_n: The number of sites.
Returns
Vector: A vector of named tuples, each representing a valid combination of site occupation counts that sum to the target. Each named tuple contains a countNjfor each occupation levelj = 0, 1, …, max_occupancyand the total number of sitesN.
SymBasis.Miscs.combos_dof_sum — Method
combos_dof_sum(
ldof::AbstractVector,
target,
n::T_n
) where {T_n<:Int}Generate all combinations of local degree-of-freedom (DoF) values for n sites that sum to the specified target value. This is the generic form that works for any discrete DoF, including both spin systems (rational-valued local DoF) and bosonic systems (integer-valued occupation numbers).
Arguments
ldof::AbstractVector: A vector of the possible local DoF values (e.g.,[-1//2, 1//2]for spin-1/2, or[0, 1, 2, 3]for bosons with max occupancy 3).target: The target sum of the local DoF values across allnsites. Must be comparable to elements ofldofunder arithmetic (e.g.,IntorRational).n::T_n: The number of sites.
Returns
Vector: A vector of named tuples, each representing a valid combination of DoF occupation counts that sum to the target. Each named tuple contains a countNjfor each local DoF value (indexedj = 0, 1, …) and the total number of sitesN.
SymBasis.Miscs.combos_spin_sum — Method
combos_spin_sum(
s::T_s,
target::Union{T_s,Int},
n::T_n
) where {T_s<:Rational,T_n<:Int}Generate all combinations of spin projections for n spins of size s that sum to the specified target value.
Arguments
s::T_s: The spin size (e.g.,1//2,1//1,3//2, etc.).target::Union{T_s,Int}: The target sum of spin projections.n::T_n: The number of spins.
Returns
Vector: A vector of named tuples, each representing a valid combination of spin projections that sum to the target. Each named tuple contains counts of each spin projection and the total number of spinsN.
SymBasis.Miscs.invperm — Method
invperm(perm::BitPermutation{T,<:PermutationBackend{T}}) where {T}Compute the inverse of a bit permutation.
Arguments
perm::BitPermutation{T,<:PermutationBackend{T}}: The bit permutation for which to compute the inverse.
Returns
Vector{T}: The inverse of the input bit permutation, returned as a standard vector.
SymBasis.Miscs.perm_k — Method
perm_k(perm::AbstractVector{T_lsi}, k) where {T_lsi<:Integer}Apply the permutation perm repeatedly k times.
Arguments
perm::AbstractVector{T_lsi}: The permutation to be applied.k::Integer: The number of times to apply the permutation.
Returns
Vector{T_lsi}: The resulting permutation after applyingpermktimes.
SymBasis.Miscs.perm_wrapper — Method
perm_wrapper(perm::AbstractVector{T_lsi}, base::Integer) where {T_lsi<:Integer}Wrap the permutation perm in a BitPermutations.BitPermutation if the specified base is 2, otherwise return perm as is.
Arguments
perm::AbstractVector{T_lsi}: The permutation to be wrapped.base::Integer: The base to determine whether to wrap the permutation in aBitPermutations.BitPermutation.
Returns
Union{BitPermutations.BitPermutation{unsigned(T_lsi)}, AbstractVector{T_lsi}}: The wrapped permutation ifbaseis 2, or the original permutation otherwise.
SymBasis.Miscs.rtoldefault — Method
rtoldefault(::Type{<:Real})Compute the default relative tolerance for a non-floating-point real type.
Returns
Int: Returns zero, as non-floating-point real types have exact arithmetic.
SymBasis.Miscs.rtoldefault — Method
rtoldefault(x::Union{T,Type{T}}, y::Union{S,Type{S}}, atol::Real) where {T<:Number,S<:Number}Compute a default relative tolerance based on the types of x and y and the provided absolute tolerance.
Arguments
x::Union{T,Type{T}}: A value or type of the first operand.y::Union{S,Type{S}}: A value or type of the second operand.atol::Real: The absolute tolerance threshold.
Returns
Real: The default relative tolerance. Ifatol > 0, returns zero (absolute tolerance takes precedence). Otherwise, returns the maximum of the default relative tolerances for the real parts of typesTandS.
SymBasis.Miscs.rtoldefault — Method
rtoldefault(::Type{T}) where {T<:AbstractFloat}Compute the default relative tolerance for a floating-point type as the square root of machine epsilon.
Arguments
T::Type{<:AbstractFloat}: A floating-point type.
Returns
AbstractFloat: The square root of the machine epsilon for typeT.