OpIDSum

For some systems, constructing the OpSum can be the bottleneck of MPO construction. OpIDSum plays the same role as OpSum, but in a much more efficient manner. To specify an operator in a term of an OpSum, you provide a string (the operator's name) and a site index. To specify an operator in a term of an OpIDSum, you provide an OpID, which contains an operator index and a site. The operator index is the position of the operator in the provided basis for the site. The remaining metadata about the operator is kept in an OpCacheVec.

ITensorMPOConstruction.OpIDType
OpID{Ti}

Compact identifier for an operator stored in an OpCacheVec.

Type Parameters

  • Ti: The integer type used to store both the operator ID and site.

Fields:

  • id: index of the operator within the cache for site n.
  • n: site number on which the operator acts.

The zero value OpID(0, 0) is used internally as padding for unused slots in fixed-width storage.

source
ITensorMPOConstruction.OpIDSumType
OpIDSum{N,C,Ti}

Compact, fixed-width storage for sum of products of local operators.

Each stored term has a scalar coefficient and up to N non-identity local operators encoded as OpID{Ti} values. Unused slots are padded with zero(OpID{Ti}). The operator ids are interpreted through op_cache_vec, and terms are stored in increasing site order after insertion.

Type Parameters:

  • N: maximum number of non-identity onsite operators stored per term.
  • C: scalar coefficient type.
  • Ti: integer type used for operator ids and site numbers.

Fields:

  • _data: tuple storage backing the reinterpreted terms matrix.
  • terms: N x capacity matrix view of fixed-width OpID term storage.
  • scalars: coefficient storage parallel to columns of terms.
  • num_terms: atomic count of currently populated terms.
  • op_cache_vec: operator cache defining the meaning of each OpID.
  • abs_tol: coefficients with abs(scalar) <= abs_tol are dropped by add!.
  • modify!: callback applied to the nonzero part of a term before storing its scalar.
source
ITensorMPS.add!Function
add!(os::OpIDSum, scalar::Number, ops) -> Nothing

Append a term (defined by ops) to os. This function is thread-safe.

Identity operators (id == 1) are removed before storage, remaining operators are sorted by site with the appropriate fermionic permutation sign, and the term-modification callback associated with os is applied. Terms below os.abs_tol are skipped. Importantly, the sorting is stable. This does not merge duplicate terms or check capacity; callers must construct os with enough room for all accepted terms.

source
add!(os::OpIDSum, scalar::Number, ops::OpID...) -> Nothing

Vararg convenience method for add!.

source
ITensorMPOConstruction.OpInfoType
OpInfo

Cached metadata for a single local operator on a given site.

Fields:

  • name: operator name used to build the local ITensor operator.
  • matrix: dense matrix representation of the local operator.
  • is_fermionic: whether the operator has odd fermion parity.
  • qn_flux: quantum-number flux carried by the operator, or QN() when the ITensor operator reports no flux.
source
ITensorMPOConstruction.OpCacheVecType
OpCacheVec

A per-site operator cache.

OpCacheVec is indexed as op_cache_vec[n][op_id], where n is a site number and op_id is the operator id stored in an OpID. By convention, operator id 1 is the identity on every site.

source
ITensorMPOConstruction.to_OpCacheVecFunction
to_OpCacheVec(sites::Vector{<:Index}, ops::OpCacheVec) -> OpCacheVec

Validate and return a precomputed operator cache.

The number of site caches must match sites, and the first cached operator for every site must be the identity. The input cache is returned unchanged.

source
to_OpCacheVec(sites::Vector{<:Index}, ops::Vector{Vector{String}}) -> OpCacheVec

Build an OpCacheVec from operator names for each site.

ops[n] is the ordered list of operator names available on site n, and the first entry for every site must be "I", which is reserved for the identity. The returned cache preserves this ordering, so ids in OpID values refer to positions in the corresponding site list.

source
to_OpCacheVec(sites::Vector{<:Index}, ::Nothing) -> Nothing

Pass through nothing for call sites where an optional operator cache is allowed.

source
Base.lengthFunction
length(os::OpIDSum) -> Int

Return the number of terms currently stored in os.

source
Base.eachindexFunction
eachindex(os::OpIDSum) -> UnitRange{Int}

Return the valid term indices of os.

source
Base.getindexFunction
getindex(os::OpIDSum, i::Integer)

Return the pair (scalar, ops) for the ith term of os, where ops is a view into the fixed-width OpID storage for that term.

source
Base.zeroFunction
zero(::OpID{Ti}) where {Ti}

Return the padding sentinel OpID{Ti}(0, 0).

source
Base.islessFunction
isless(op1::OpID, op2::OpID) -> Bool

Order OpID values lexicographically by (site, operator id).

source
ITensors.fluxFunction
ITensors.flux(ops::NTuple{N,OpID}, n::Int, op_cache_vec::OpCacheVec) where {N} -> QN

Return the total quantum-number flux contributed by operators in ops on sites >= n, using the cached operator metadata in op_cache_vec.

source