nkdsl.SymbolicOperator

class SymbolicOperator(hilbert, name, ir_terms, *, dtype_str='complex64', is_hermitian=False, metadata=None)[source]

A symbolic operator built via the SymbolicDiscreteJaxOperator DSL.

SymbolicOperator is the canonical result of SymbolicDiscreteJaxOperator(...).build(). It holds an ordered list of typed IR terms and provides a .compile() method to lower them to an executable CompiledOperator.

Instances are not directly executable: calling get_conn_padded before compilation raises SymbolicOperatorExecutionError.

Parameters:
  • hilbert (DiscreteHilbert)

  • name (str)

  • ir_terms (tuple)

  • dtype_str (str)

  • is_hermitian (bool)

  • metadata (dict[str, Any] | None)

name

User-facing operator name.

hilbert

The NetKet Hilbert space.

dtype

Matrix-element dtype.

is_hermitian

Whether this operator is declared Hermitian.

Example:

op = (
    SymbolicDiscreteJaxOperator(hi, "hopping")
    .for_each_pair("i", "j")
    .where(site("i") > 0)
    .emit(shift("i", -1).shift("j", +1), matrix_element=1.0)
    .build()
)
compiled = op.compile()
xp, mels = compiled.get_conn_padded(x_batch)
__init__(hilbert, name, ir_terms, *, dtype_str='complex64', is_hermitian=False, metadata=None)[source]
Parameters:
  • hilbert (_install_doc_stubs.<locals>.DiscreteHilbert)

  • name (str)

  • ir_terms (tuple)

  • dtype_str (str)

  • is_hermitian (bool)

  • metadata (dict[str, Any] | None)

Return type:

None

Methods

__init__(hilbert, name, ir_terms, *[, ...])

apply_scalar(scalar)

Returns a scaled copy of this operator.

compile(*[, backend, operator_lowering, ...])

Lowers this symbolic operator to an executable CompiledOperator.

estimate_max_conn_size()

Returns the aggregate static max-connection bound across all terms.

get_conn_padded(x)

Raises until this operator has been compiled.

to_ir()

Builds the symbolic operator IR for compiler consumption.

Attributes

dtype

Returns matrix-element dtype.

dtype_str

Returns matrix-element dtype as a normalized string.

free_symbols

Returns the set of free (non-iterator-bound) symbol names across all terms.

is_hermitian

Returns whether this operator is declared Hermitian.

max_conn_size

Returns a static upper bound on the number of connected states.

metadata

Returns operator metadata dictionary.

name

User-facing operator name.

operator_name

Returns user-facing operator name.

term_count

Number of IR terms in this operator.