# qnet.algebra package¶

Symbolic quantum and photonic circuit (SLH) algebra

Subpackages:

## Summary¶

__all__ Exceptions:

 AlgebraError Base class for all algebraic errors AlgebraException Base class for all algebraic exceptions BadLiouvillianError Raised when a Liouvillian is not of standard Lindblad form. BasisNotSetError Raised if the basis or a Hilbert space dimension is unavailable CannotConvertToSLH Raised when a circuit algebra object cannot be converted to SLH CannotEliminateAutomatically Raised when attempted automatic adiabatic elimination fails. CannotSimplify Raised when a rule cannot further simplify an expression CannotSymbolicallyDiagonalize Matrix cannot be diagonalized analytically. CannotVisualize Raised when a circuit cannot be visually represented. IncompatibleBlockStructures Raised for invalid block-decomposition InfiniteSumError Raised when expanding a sum into an infinite number of terms NoConjugateMatrix Raised when entries of Matrix have no defined conjugate NonSquareMatrix Raised when a Matrix fails to be square OverlappingSpaces Raised when objects fail to be in separate Hilbert spaces. SpaceTooLargeError Raised when objects fail to be have overlapping Hilbert spaces. UnequalSpaces Raised when objects fail to be in the same Hilbert space. WrongCDimError Raised for mismatched channel number in circuit series

__all__ Classes:

 Adjoint Symbolic Adjoint of an operator BasisKet Local basis state, identified by index or label Beamsplitter Infinite bandwidth beamsplitter component. Bra The associated dual/adjoint state for any ket BraKet The symbolic inner product between two states CPermutation Channel permuting circuit Circuit Base class for the circuit algebra elements CircuitSymbol Symbolic circuit element CoherentDriveCC Coherent displacement of the input field CoherentStateKet Local coherent state, labeled by a complex amplitude Commutator Commutator of two operators Component Base class for circuit components Concatenation Concatenation of circuit elements Create Bosonic creation operator Destroy Bosonic annihilation operator Displace Unitary coherent displacement operator Eq Symbolic equation Expression Base class for all QNET Expressions Feedback Feedback on a single channel of a circuit HilbertSpace Base class for Hilbert spaces IndexedSum Base class for indexed sums Jminus Lowering operator on a spin space Jplus Raising operator of a spin space Jz Spin (angular momentum) operator in z-direction KetBra Outer product of two states KetIndexedSum Indexed sum over Kets KetPlus Sum of states KetSymbol Symbolic state LocalKet A state on a LocalSpace LocalOperator Base class for “known” operators on a LocalSpace LocalProjector A projector onto a specific level of a LocalSpace LocalSigma Level flip operator between two levels of a LocalSpace LocalSpace Hilbert space for a single degree of freedom. MatchDict Result of a Pattern.match() Matrix Matrix of Expressions NullSpaceProjector Projection operator onto the nullspace of its operand Operation Base class for “operations” Operator Base class for all quantum operators. OperatorDerivative Symbolic partial derivative of an operator OperatorIndexedSum Indexed sum over operators OperatorPlus Sum of Operators OperatorPlusMinusCC An operator plus or minus its complex conjugate OperatorSymbol Symbolic operator OperatorTimes Product of operators OperatorTimesKet Product of an operator and a state. OperatorTrace (Partial) trace of an operator Pattern Pattern for matching an expression Phase Unitary “phase” operator PhaseCC Coherent phase shift cicuit component ProductSpace Tensor product of local Hilbert spaces PseudoInverse Symbolic pseudo-inverse $$X^+$$ of an operator $$X$$ QuantumAdjoint Base class for adjoints of quantum expressions QuantumDerivative Symbolic partial derivative QuantumExpression Base class for expressions associated with a Hilbert space QuantumIndexedSum Base class for indexed sums QuantumOperation Base class for operations on quantum expression QuantumPlus General implementation of addition of quantum expressions QuantumSymbol Symbolic element of an algebra QuantumTimes General implementation of product of quantum expressions SLH Element of the SLH algebra SPost Linear post-multiplication operator SPre Linear pre-multiplication operator Scalar Base class for Scalars ScalarDerivative Symbolic partial derivative of a scalar ScalarExpression Base class for scalars with non-scalar arguments ScalarIndexedSum Indexed sum over scalars ScalarPlus Sum of scalars ScalarPower A scalar raised to a power ScalarTimes Product of scalars ScalarTimesKet Product of a Scalar coefficient and a ket ScalarTimesOperator Product of a Scalar coefficient and an Operator ScalarTimesQuantumExpression Product of a Scalar and a QuantumExpression ScalarTimesSuperOperator Product of a Scalar coefficient and a SuperOperator ScalarValue Wrapper around a numeric or symbolic value SeriesInverse Symbolic series product inversion operation SeriesProduct The series product circuit operation. SingleQuantumOperation Base class for operations on a single quantum expression SpinOperator Base class for operators in a spin space SpinSpace A Hilbert space for an integer or half-integer spin system Squeeze Unitary squeezing operator State Base class for states in a Hilbert space StateDerivative Symbolic partial derivative of a state SuperAdjoint Adjoint of a super-operator SuperOperator Base class for super-operators SuperOperatorDerivative Symbolic partial derivative of a super-operator SuperOperatorPlus A sum of super-operators SuperOperatorSymbol Symbolic super-operator SuperOperatorTimes Product of super-operators SuperOperatorTimesOperator Application of a super-operator to an operator TensorKet A tensor product of kets

__all__ Functions:

 FB Wrapper for Feedback, defaulting to last channel KroneckerDelta Kronecker delta symbol PauliX Pauli-type X-operator PauliY Pauli-type Y-operator PauliZ Pauli-type Z-operator SpinBasisKet Constructor for a BasisKet for a SpinSpace Sum Instantiator for an arbitrary indexed sum. adjoint Return the adjoint of an obj. anti_commutator If B != None, return the anti-commutator $$\{A,B\}$$, otherwise return the super-operator $$\{A,\cdot\}$$. block_matrix Generate the operator matrix with quadrants circuit_identity Return the circuit identity for n channels commutator Commutator of A and B connect Connect a list of components according to a list of connections. decompose_space Simplifies OperatorTrace expressions over tensor-product spaces by turning it into iterated partial traces. diagm Generalizes the diagonal matrix creation capabilities of numpy.diag to Matrix objects. eval_adiabatic_limit Compute the limiting SLH model for the adiabatic approximation expand_commutators_leibniz Recursively expand commutators in expr according to the Leibniz rule. extract_channel Create a CPermutation that extracts channel k factor_coeff Factor out coefficients of all factors. factor_for_trace Given a LocalSpace ls to take the partial trace over and an operator op, factor the trace such that operators acting on disjoint degrees of freedom are pulled out of the trace.If the operator acts trivially on ls the trace yields only a pre-factor equal to the dimension of ls.If there are LocalSigma operators among a product, the trace’s cyclical property is used to move to sandwich the full product by LocalSigma operators:. getABCD Calculate the ABCD-linearization of an SLH model get_coeffs Create a dictionary with all Operator terms of the expression (understood as a sum) as keys and their coefficients as values. hstackm Generalizes numpy.hstack to Matrix objects. identity_matrix Generate the N-dimensional identity matrix. init_algebra Initialize the algebra system lindblad Return the super-operator Lindblad term of the Lindblad operator C liouvillian Return the Liouvillian super-operator associated with H and Ls liouvillian_normal_form Return a Hamilton operator H and a minimal list of collapse operators Ls that generate the liouvillian L. map_channels Create a CPermuation based on a dict of channel mappings match_pattern Recursively match expr with the given expr_or_pattern move_drive_to_H Move coherent drives from the Lindblad operators to the Hamiltonian no_instance_caching Temporarily disable instance caching in create() pad_with_identity Pad a circuit by adding a n-channel identity circuit at index k pattern ‘Flat’ constructor for the Pattern class pattern_head Constructor for a Pattern matching a ProtoExpr prepare_adiabatic_limit Prepare the adiabatic elimination on an SLH object rewrite_with_operator_pm_cc Try to rewrite expr using OperatorPlusMinusCC sqrt Square root of a Scalar or scalar value substitute Substitute symbols or (sub-)expressions with the given replacements and re-evalute the result symbols The symbols() function from SymPy temporary_instance_cache Use a temporary cache for instances in create() temporary_rules Allow temporary modification of rules for create() try_adiabatic_elimination Attempt to automatically do adiabatic elimination on an SLH object vstackm Generalizes numpy.vstack to Matrix objects. wc Constructor for a wildcard-Pattern zerosm Generalizes numpy.zeros to Matrix objects.

__all__ Data:

 CIdentity Single pass-through channel; neutral element of SeriesProduct CircuitZero Zero circuit, the neutral element of Concatenation FullSpace The ‘full space’, i.e. II IdentityOperator constant (singleton) object. IdentityOperator IdentityOperator constant (singleton) object. IdentitySuperOperator Neutral element for product of super-operators One The neutral element with respect to scalar multiplication TrivialKet TrivialKet constant (singleton) object. TrivialSpace The ‘nullspace’, i.e. Zero The neutral element with respect to scalar addition ZeroKet ZeroKet constant (singleton) object for the null-state. ZeroOperator ZeroOperator constant (singleton) object. ZeroSuperOperator Neutral element for sum of super-operators tr Instantiate while applying automatic simplifications

## Reference¶

qnet.algebra.init_algebra(*, default_hs_cls='LocalSpace')[source]

Initialize the algebra system

Parameters: default_hs_cls (str) – The name of the LocalSpace subclass that should be used when implicitly creating Hilbert spaces, e.g. in OperatorSymbol