Expand description
Phase — i^k factors arising from Pauli algebra, with k ∈ {0, 1, 2, 3}.
Multiplication of two Pauli bitstrings produces an i^k factor wherever
X- and Z-bits coincide (see PauliString::mul_assign); callers fold
this into the relevant Complex64 coefficient at the boundary
(PauliSum, BuildAccumulator, channel apply). Phase
centralizes that arithmetic so every site uses the same combine/apply
rules instead of open-coded u8 & 3 masks and four-arm match statements.
§Examples
Combine phases with + (mod 4) and fold one into a Complex64
coefficient with Phase::apply:
use paulistrings::Phase;
use num_complex::Complex64;
let p = Phase::I + Phase::I; // i · i = -1
assert_eq!(p, Phase::MINUS_ONE);
let folded = Phase::I.apply(Complex64::new(2.0, 3.0)); // i · (2 + 3i) = -3 + 2i
assert_eq!(folded, Complex64::new(-3.0, 2.0));Structs§
- Phase
- A phase factor
i^kwherek ∈ {0, 1, 2, 3}.