Miscs API

Index

SymBasis.Miscs.all_permutationsMethod
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 type T.

Returns

  • Vector{NTuple{N,T}}: A vector containing all permutations of the input tuple t.
source
SymBasis.Miscs.combos_boson_sumMethod
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., 3 for occupation numbers 0, 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 count Nj for each occupation level j = 0, 1, …, max_occupancy and the total number of sites N.
source
SymBasis.Miscs.combos_dof_sumMethod
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 all n sites. Must be comparable to elements of ldof under arithmetic (e.g., Int or Rational).
  • 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 count Nj for each local DoF value (indexed j = 0, 1, …) and the total number of sites N.
source
SymBasis.Miscs.combos_spin_sumMethod
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 spins N.
source
SymBasis.Miscs.invpermMethod
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.
source
SymBasis.Miscs.perm_kMethod
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 applying perm k times.
source
SymBasis.Miscs.perm_wrapperMethod
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 a BitPermutations.BitPermutation.

Returns

  • Union{BitPermutations.BitPermutation{unsigned(T_lsi)}, AbstractVector{T_lsi}}: The wrapped permutation if base is 2, or the original permutation otherwise.
source
SymBasis.Miscs.rtoldefaultMethod
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.
source
SymBasis.Miscs.rtoldefaultMethod
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. If atol > 0, returns zero (absolute tolerance takes precedence). Otherwise, returns the maximum of the default relative tolerances for the real parts of types T and S.
source
SymBasis.Miscs.rtoldefaultMethod
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 type T.
source