Primitives
These functions are defined in the PropagationBase submodule for generic term sums, so their signatures name a term_sum::AbstractTermSum or a prop_cache::AbstractPropagationCache rather than a Pauli sum. Every PauliSum, VectorPauliSum and MultiPauliSum is an AbstractTermSum, and PropagationCache(psum) wraps one of them into the cache that propagate! works on, so each function below accepts either.
Map
Base.map! — Method
map!(transform, term_sum::AbstractTermSum; thread=true)
map!(transform, prop_cache::AbstractPropagationCache; thread=true)Replace every active (term, coefficient) pair by the pair returned from transform(term, coefficient). Array-backed storage updates its active entries in place, while any other cache writes the transformed pairs through flatmap!.
Base.map — Method
map(transform, term_sum::AbstractTermSum; thread=true)
map(transform, prop_cache::AbstractPropagationCache; thread=true)Apply transform(term, coefficient) to every active term and coefficient pair, returning a copy. transform must return a (term, coefficient) pair of values accepted by the destination.
PauliPropagation.PropagationBase.mapcoeffs! — Method
mapcoeffs!(transform, term_sum::AbstractTermSum; thread=true)
mapcoeffs!(transform, prop_cache::AbstractPropagationCache; thread=true)Replace every active coefficient by transform(coefficient), leaving terms unchanged. This operation updates coefficients in place and does not require cache scratch storage.
PauliPropagation.PropagationBase.mapcoeffs — Method
mapcoeffs(transform, term_sum::AbstractTermSum; thread=true)
mapcoeffs(transform, prop_cache::AbstractPropagationCache; thread=true)Apply transform(coefficient) to every active coefficient, returning a copy and leaving terms unchanged.
PauliPropagation.PropagationBase.mapcoeffsbypair! — Method
mapcoeffsbypair!(transform, term_sum::AbstractTermSum; thread=true)
mapcoeffsbypair!(transform, prop_cache::AbstractPropagationCache; thread=true)Replace every active coefficient by transform(term, coefficient), leaving terms unchanged. Like mapcoeffs!, this updates coefficients in place and does not require cache scratch storage.
PauliPropagation.PropagationBase.mapterms! — Method
mapterms!(transform, term_sum::AbstractTermSum; thread=true)
mapterms!(transform, prop_cache::AbstractPropagationCache; thread=true)Replace every active term by transform(term), leaving coefficients unchanged.
PauliPropagation.PropagationBase.mapterms — Method
mapterms(transform, term_sum::AbstractTermSum; thread=true)
mapterms(transform, prop_cache::AbstractPropagationCache; thread=true)Apply transform(term) to every active term, returning a copy and leaving coefficients unchanged.
PauliPropagation.PropagationBase.flatmap! — Method
flatmap!(f, prop_cache::AbstractPropagationCache; thread=true)Replace every active term and coefficient pair by the pairs f(term, coefficient) returns, a tuple of (term, coefficient) pairs or another iterable of them, such as what apply returns for a gate. flatmap! performs no separate merge pass, so duplicate handling depends on storage: dictionaries merge while inserting, whereas arrays and multi sums retain duplicates until merge!. Several tasks on an array call f once to count the pairs and once to write them, so f must return the same pairs each time. A dictionary or multi sum finds its auxiliary sum or outboxes empty, as the merge after a gate leaves them, and throws an ArgumentError otherwise, since what they hold would be lost. Only a cache is transformed in place, because the pairs need room of their own; a term sum takes flatmap.
PauliPropagation.PropagationBase.flatmap — Method
flatmap(f, term_sum::AbstractTermSum; thread=true)
flatmap(f, prop_cache::AbstractPropagationCache; thread=true)Replace every active term and coefficient pair by the pairs f(term, coefficient) returns, on a copy. See flatmap!.
Reduce
Base.mapreduce — Method
mapreduce(mapper, reducer, term_sum::AbstractTermSum; init, neutral, thread=true)
mapreduce(mapper, reducer, prop_cache::AbstractPropagationCache; init, neutral, thread=true)Reduce mapper(term, coefficient) with reducer over the (term, coefficient) pairs of term_sum, or over the active pairs of prop_cache. init defaults to the zero of the real coefficient type. neutral is the identity used to reduce independent chunks. It is inferred for the standard reductions supported by AcceleratedKernels; pass it explicitly for a custom reducer. init is applied exactly once, after those chunks have been combined.
PauliPropagation.PropagationBase.mapreducecoeffs — Method
mapreducecoeffs(mapper, reducer, term_sum::AbstractTermSum; init, neutral, thread=true)
mapreducecoeffs(mapper, reducer, prop_cache::AbstractPropagationCache; init, neutral, thread=true)Reduce mapper(coefficient) with reducer over the coefficients of term_sum, or over the active coefficients of prop_cache. init defaults to the zero of the real coefficient type. neutral follows the same rules as mapreduce: it is the identity used for independent chunks, while init is applied once to the completed reduction.
PauliPropagation.PropagationBase.maxabscoeff — Method
maxabscoeff(term_sum::AbstractTermSum; thread=true)
maxabscoeff(prop_cache::AbstractPropagationCache; thread=true)Return the largest absolute coefficient in term_sum, or in the active view of prop_cache.
Filter
Base.filter! — Method
filter!(keep, term_sum::AbstractTermSum; thread=true)
filter!(keep, prop_cache::AbstractPropagationCache; thread=true)Remove active (term, coefficient) pairs for which keep(term, coefficient) returns false. Several tasks on an array call keep once to count the pairs and once to write them, so it must return the same for the same pair each time.
Base.filter — Method
filter(keep, term_sum::AbstractTermSum; thread=true)
filter(keep, prop_cache::AbstractPropagationCache; thread=true)Keep the active (term, coefficient) pairs for which keep(term, coefficient) returns true, returning a copy.
PauliPropagation.PropagationBase.filtercoeffs! — Method
filtercoeffs!(keep, term_sum::AbstractTermSum; thread=true)
filtercoeffs!(keep, prop_cache::AbstractPropagationCache; thread=true)Remove active coefficients for which keep(coefficient) returns false.
PauliPropagation.PropagationBase.filtercoeffs — Method
filtercoeffs(keep, term_sum::AbstractTermSum; thread=true)
filtercoeffs(keep, prop_cache::AbstractPropagationCache; thread=true)Keep active coefficients for which keep(coefficient) returns true, returning a copy.
PauliPropagation.PropagationBase.filterterms! — Method
filterterms!(keep, term_sum::AbstractTermSum; thread=true)
filterterms!(keep, prop_cache::AbstractPropagationCache; thread=true)Remove active terms for which keep(term) returns false.
PauliPropagation.PropagationBase.filterterms — Method
filterterms(keep, term_sum::AbstractTermSum; thread=true)
filterterms(keep, prop_cache::AbstractPropagationCache; thread=true)Keep active terms for which keep(term) returns true, returning a copy.
Sort
PauliPropagation.PropagationBase.sortcoeffs! — Method
sortcoeffs!(term_sum::AbstractTermSum; lt=isless, by=identity, rev=false, order=Base.Forward, thread=true)
sortcoeffs!(prop_cache::AbstractPropagationCache; lt=isless, by=identity, rev=false, order=Base.Forward, thread=true)Sort active coefficients, moving their terms with them. Dictionary-backed sums retain their unordered storage and are returned unchanged.
PauliPropagation.PropagationBase.sortcoeffs — Method
sortcoeffs(term_sum::AbstractTermSum; kwargs...)
sortcoeffs(prop_cache::AbstractPropagationCache; kwargs...)Return a copy whose active coefficients have been sorted. For multi sums, coefficients are sorted within each zone, whose ownership partition is retained.
PauliPropagation.PropagationBase.sortterms! — Method
sortterms!(term_sum::AbstractTermSum; lt=isless, by=identity, rev=false, order=Base.Forward, thread=true)
sortterms!(prop_cache::AbstractPropagationCache; lt=isless, by=identity, rev=false, order=Base.Forward, thread=true)Sort active terms. Dictionary-backed sums retain their unordered storage and are returned unchanged. Sorted in the default order, array-backed sums record their leading duplicate-free run as their sorted prefix.
PauliPropagation.PropagationBase.sortterms — Method
sortterms(term_sum::AbstractTermSum; kwargs...)
sortterms(prop_cache::AbstractPropagationCache; kwargs...)Return a copy whose active terms have been sorted. For multi sums, terms are sorted within each zone, whose ownership partition is retained.