nkdsl.ExpressionContext

class ExpressionContext[source]

Utility context passed to DSL callables at build time.

This context only builds IR expression nodes and never captures Python-runtime callbacks.

Example

>>> def my_amplitude(ctx):
...     i = ctx.site("i")
...     return ctx.sqrt(i.value + 1)
__init__()

Methods

__init__()

abs_(operand)

Returns an absolute-value expression |operand|.

all_of(*operands)

Builds logical conjunction over provided predicate values.

any_of(*operands)

Builds logical disjunction over provided predicate values.

coerce_amplitude(value)

Coerces one value into an amplitude expression.

coerce_predicate(value)

Coerces one value into a predicate expression.

conj(operand)

Returns a complex-conjugate amplitude expression.

const(value)

Returns a constant amplitude expression.

edge_components(edge_idx, n_edges_per_copy)

Returns all gauge_dim charge components for one edge.

edge_norm(edge_idx, n_edges_per_copy[, ...])

Returns the L2 norm of the charge vector at edge_idx.

edge_sq_norm(edge_idx, n_edges_per_copy[, ...])

Returns the squared L2 norm of the charge vector at edge_idx.

edge_value(edge_idx, gauge_copy, ...)

Returns the charge at x[gauge_copy * n_edges_per_copy + edge_idx].

emitted(label)

Returns an emitted-state selector by label.

emitted_edge_value(edge_idx, gauge_copy, ...)

Returns the emitted/connected charge at x'[g*E + e].

eq(left, right)

Builds equality predicate expression.

ge(left, right)

Builds greater-than-or-equal predicate expression.

gt(left, right)

Builds strict-greater-than predicate expression.

le(left, right)

Builds less-than-or-equal predicate expression.

lt(left, right)

Builds strict-less-than predicate expression.

ne(left, right)

Builds inequality predicate expression.

neg(operand)

Returns a negated amplitude expression.

norm2(*components)

Returns the L2 norm of components: sqrt(c0² + c1² + ...).

not_(operand)

Builds logical negation over one predicate value.

pow(base, exponent)

Returns a power expression base ** exponent.

site(label)

Returns a site selector by label.

source_index(flat_index)

Returns a static source-configuration read x[flat_index].

sq_norm(*components)

Returns the squared L2 norm of components: c0² + c1² + ....

sqrt(operand)

Returns a square-root amplitude expression.

symbol(name, *[, default, doc, dtype])

Returns a free symbolic amplitude expression.

target_index(flat_index)

Returns a static emitted/target-configuration read x'[flat_index].

wrap_mod(operand)

Returns a Hilbert-aware modulo-wrapped amplitude expression.