netket.operator.LocalOperator

class netket.operator.LocalOperator

A custom local operator. This is a sum of an arbitrary number of operators acting locally on a limited set of k quantum numbers (i.e. k-local, in the quantum information sense).

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: netket._C_netket.operator.LocalOperator, hilbert: netket._C_netket.hilbert.Hilbert, constant: float = 0.0) -> None

    Constructs a new LocalOperator given a hilbert space and (if specified) a constant level shift.

    Args:

    hilbert: Hilbert space the operator acts on. constant: Level shift for operator. Default is 0.0.

    Examples:

    Constructs a LocalOperator without any operators.

    >>> from netket.graph import CustomGraph
    >>> from netket.hilbert import CustomHilbert
    >>> from netket.operator import LocalOperator
    >>> g = CustomGraph(edges=[[i, i + 1] for i in range(20)])
    >>> hi = CustomHilbert(local_states=[1, -1], graph=g)
    >>> empty_hat = LocalOperator(hi)
    >>> print(len(empty_hat.acting_on))
    0
    
  2. __init__(self: netket._C_netket.operator.LocalOperator, hilbert: netket._C_netket.hilbert.Hilbert, operators: List[List[List[complex]]], acting_on: List[List[int]], constant: float = 0.0) -> None

    Constructs a new LocalOperator given a hilbert space, a vector of operators, a vector of sites, and (if specified) a constant level shift.

    Args:

    hilbert: Hilbert space the operator acts on. operators: A list of operators, in matrix form. acting_on: A list of sites, which the corresponding operators act

    on.

    constant: Level shift for operator. Default is 0.0.

    Examples:

    Constructs a LocalOperator from a list of operators acting on a corresponding list of sites.

    >>> from netket.graph import CustomGraph
    >>> from netket.hilbert import CustomHilbert
    >>> from netket.operator import LocalOperator
    >>> sx = [[0, 1], [1, 0]]
    >>> g = CustomGraph(edges=[[i, i + 1] for i in range(20)])
    >>> hi = CustomHilbert(local_states=[1, -1], graph=g)
    >>> sx_hat = LocalOperator(hi, [sx] * 3, [[0], [1], [5]])
    >>> print(len(sx_hat.acting_on))
    3
    
  3. __init__(self: netket._C_netket.operator.LocalOperator, hilbert: netket._C_netket.hilbert.Hilbert, operator: List[List[complex]], acting_on: List[int], constant: float = 0.0) -> None

    Constructs a new LocalOperator given a hilbert space, an operator, a site, and (if specified) a constant level shift.

    Args:

    hilbert: Hilbert space the operator acts on. operator: An operator, in matrix form. acting_on: A list of sites, which the corresponding operators act

    on.

    constant: Level shift for operator. Default is 0.0.

    Examples:

    Constructs a LocalOperator from a single operator acting on a single site.

    >>> from netket.graph import CustomGraph
    >>> from netket.hilbert import CustomHilbert
    >>> from netket.operator import LocalOperator
    >>> sx = [[0, 1], [1, 0]]
    >>> g = CustomGraph(edges=[[i, i + 1] for i in range(20)])
    >>> hi = CustomHilbert(local_states=[1, -1], graph=g)
    >>> sx_hat = LocalOperator(hi, sx, [0])
    >>> print(len(sx_hat.acting_on))
    1
    

Methods

__init__(*args, **kwargs)

Overloaded function.

conjugate(self)

Returns the complex conjugation of this operator

get_conn(self, v, 1]])

Member function finding the connected elements of the Operator.

to_dense(self)

Returns the dense matrix representation of the operator.

to_linear_operator(self)

Converts Operator to scipy.sparse.linalg.LinearOperator.

to_sparse(self)

Returns the sparse matrix representation of the operator.

transpose(self)

Returns the transpose of this operator

Attributes

acting_on

A list of the sites that each local matrix acts on.

hilbert

Hilbert space of operator.

local_matrices

A list of the local matrices.

property acting_on

A list of the sites that each local matrix acts on.

Type

list[list]

conjugate(self: netket._C_netket.operator.LocalOperator) → netket._C_netket.operator.LocalOperator

Returns the complex conjugation of this operator

get_conn(self: netket._C_netket.Operator, v: numpy.ndarray[float64[m, 1]]) → Tuple[scipy.sparse.csc_matrix[float64], numpy.ndarray[complex128[m, 1]]]

Member function finding the connected elements of the Operator. Starting from a given visible state v, it finds all other visible states v’ such that the matrix element \(O(v,v')\) is different from zero. In general there will be several different connected visible units satisfying this condition, and they are denoted here \(v'(k)\), for \(k=0,1...N_{\mathrm{connected}}\).

Parameters

v – A constant reference to the visible configuration.

property hilbert

Hilbert space of operator.

Type

netket.hilbert.Hilbert

property local_matrices

A list of the local matrices.

Type

list[list]

to_dense(self: netket._C_netket.Operator) → numpy.ndarray[complex128[m, n]]

Returns the dense matrix representation of the operator. Note that, in general, the size of the matrix is exponential in the number of quantum numbers, and this operation should thus only be performed for low-dimensional Hilbert spaces.

This method requires an indexable Hilbert space.

to_linear_operator(self: object) → object

Converts Operator to scipy.sparse.linalg.LinearOperator.

This method requires an indexable Hilbert space.

to_sparse(self: netket._C_netket.Operator) → scipy.sparse.csr_matrix[complex128]

Returns the sparse matrix representation of the operator. Note that, in general, the size of the matrix is exponential in the number of quantum numbers, and this operation should thus only be performed for low-dimensional Hilbert spaces or sufficiently sparse operators.

This method requires an indexable Hilbert space.

transpose(self: netket._C_netket.operator.LocalOperator) → netket._C_netket.operator.LocalOperator

Returns the transpose of this operator