netket.operator.ProductOperator#
- class netket.operator.ProductOperator[source]#
Bases:
ABCBase class for product of quantum operators.
This class represents a product of quantum operators with a coefficient, implementing the mathematical concept of \(c \prod_i \hat{H}_i\) where \(c\) is a scalar coefficient and \(\hat{H}_i\) are quantum operators.
The class uses a dispatch mechanism to automatically select the appropriate specialized subclass based on the types of operators being multiplied:
ProductDiscreteJaxOperatorfor products ofDiscreteJaxOperatorinstancesProductDiscreteOperatorfor products ofDiscreteOperatorinstancesProductGenericOperatorfor mixed operator types or fallback cases.
Products can be constructed using the
@operator (matrix multiplication) or by directly instantiating this class with a list of operators.Examples
Creating a product of Pauli operators:
>>> import netket as nk >>> hi = nk.hilbert.Spin(s=1/2, N=4) >>> sx0 = nk.operator.spin.sigmax(hi, 0) >>> sz1 = nk.operator.spin.sigmaz(hi, 1) >>> sy2 = nk.operator.spin.sigmay(hi, 2) >>> # Using ProductOperator constructor >>> product1 = nk.operator.ProductOperator(sx0, sz1, sy2) >>> print(product1) ProductDiscreteJaxOperator with terms: ∙ 1.0 ∙ PauliStringsJax(n_sites=4, hilbert=Spin(s=1/2, N=4), n_strings=1) ∙ PauliStringsJax(n_sites=4, hilbert=Spin(s=1/2, N=4), n_strings=1) ∙ PauliStringsJax(n_sites=4, hilbert=Spin(s=1/2, N=4), n_strings=1)
Creating a product with explicit coefficient:
>>> # Direct instantiation >>> product2 = nk.operator.ProductOperator(sx0, sz1, coefficient=2.0) >>> print(product2.coefficient) 2.0
Products of products are automatically flattened:
>>> prod_a = nk.operator.ProductOperator(sx0, sz1) >>> prod_b = nk.operator.ProductOperator(sy2, nk.operator.spin.sigmaz(hi, 3)) >>> combined = nk.operator.ProductOperator(prod_a, prod_b) >>> print(len(combined.operators)) # All 4 operators are flattened 4
Scaling a product:
>>> scaled = 3.0 * product1 >>> print(scaled.coefficient) (3+0j)
- Inheritance

- __init__(operators, *args, coefficient=1.0, dtype=None, **kwargs)[source]#
Constructs a Product of Operators.
- Parameters:
operators (
Iterable[AbstractHilbert]) – An iterable of quantum operators to be multiplied. All operators must act on the same Hilbert space.coefficient (
float) – Scalar coefficient for the product. Default is 1.0.dtype – Data type for the coefficient. If None, it will be inferred from the operators and coefficient.
- Attributes
- coefficient#
The scalar coefficient multiplying the product of operators.
- dtype#
- operators#
The tuple of all operators in the terms of this product. All operators are multiplied together with the scalar coefficient.
Methods