Reference
Core Functions
- paulistrings.Operator(N)View on GitHub
- paulistrings.Operator.__mul__(self, other)
Multiply this operator by another object. Other can be a scalar or another Operator.
- paulistrings.Operator.__add__(self, other)
Add another object to this operator. other can be a string, a tuple (string, coeff), another Operator, or a number (will add identity times other).
- paulistrings.Operator.__sub__(self, other)
Subtract another object from this operator.
- paulistrings.Operator.__truediv__(self, other)
Divide this operator by a scalar.
- paulistrings.Operator.__str__(self)
Return str(self).
- paulistrings.Operator.__pow__(self, exponent)
- paulistrings.Operator.__array__(self)
Convert the operator to a dense numpy array: numpy.array(o)
- paulistrings.commutator(o1: Operator, o2: Operator)View on GitHub
- paulistrings.anticommutator(o1: Operator, o2: Operator)View on GitHub
- paulistrings.trace(o: Operator)View on GitHub
Trace of an operator
- paulistrings.opnorm(o: Operator)View on GitHub
Frobenius norm of an operator
Truncation
- paulistrings.cutoff(o: Operator, epsilon: float)View on GitHub
Remove all terms with weight < epsilon.
- paulistrings.truncate(o: Operator, max_length: int) Operator View on GitHub
Remove all terms with Pauli lenght > max_length.
- paulistrings.trim(o: Operator, nterms: int, keep: Operator = None) Operator View on GitHub
Keep the nterms Pauli terms with largest absolute coefficients. If keep is provided, ensure that all terms in keep are included in the output operator.
- paulistrings.add_noise(o: Operator, g: float) Operator View on GitHub
Add depolarizing noise that make the long string decays. g is the noise amplitude. Each string is multiplied by exp(-g * w), where w is the number of non-identity Paulis in the string.
- paulistrings.k_local_part(o: Operator, k: int, atmost: bool = False) Operator View on GitHub
Return the k-local part of an operator (terms with exactly k or at-most k non-unit Paulis).
Random Operators
- paulistrings.rand_local2(N: int)View on GitHub
Random 2-local operator of N qubits.
- paulistrings.rand_local1(N: int)View on GitHub
Random 1-local operator of N qubits.
Moments and Powers
- paulistrings.trace_product(o1: Operator, o2: Operator)View on GitHub
equivalent to trace(o1*o2) but faster
- paulistrings.trace_product_power(A: Operator, k: int, B: Operator, l: int)View on GitHub
equivalent to trace(A**k * B**l) but faster
Algorithms
- paulistrings.rk4(H, O, dt, hbar=1.0, heisenberg=True, M=1048576, keep=None)View on GitHub
Single step of Runge–Kutta-4 with time-independent Hamiltonian. Returns O(t+dt).
Parameters
- HOperator
Hamiltonian
- OOperator
Observable or density matrix
- dtfloat
Time step
- hbarfloat, optional
Planck constant (default 1)
- heisenbergbool, optional
If True, evolve in Heisenberg picture (default True)
- Mint, optional
Number of strings to keep (default 2**20)
- keepOperator, optional
Strings to always keep (default: identity operator)
Returns
- Operator
The evolved operator O(t+dt)