tensorcircuit.zx.evaluator¶

Evaluation of compiled scalar graphs using exact arithmetic.

class tensorcircuit.zx.evaluator.ExactScalarArray(coeffs: Array, power: Array)[source]¶

Bases: NamedTuple

Exact scalar array for ZX-calculus phase arithmetic using dyadic representation.

Represents values of the form (c_0 + c_1·ω + c_2·ω² + c_3·ω³) × 2^power where ω = e^(iπ/4).

coeffs: Array¶

Alias for field number 0

count(value, /)¶

Return number of occurrences of value.

classmethod create(coeffs: Array, power: Array | None = None) ExactScalarArray[source]¶
index(value, start=0, stop=9223372036854775807, /)¶

Return first index of value.

Raises ValueError if the value is not present.

power: Array¶

Alias for field number 1

prod(axis: int = -1) ExactScalarArray[source]¶
reduce() ExactScalarArray[source]¶
sum() ExactScalarArray[source]¶
to_complex() Array[source]¶

Convert the exact scalar to a complex JAX array.

Returns:

Complex representation of the scalar.

Return type:

jax.Array

tensorcircuit.zx.evaluator.evaluate(circuit: Any, param_vals: Array) Array[source]¶

Evaluate a compiled scalar graph circuit with batched parameter values.

Parameters:
  • circuit (Any) – The compiled scalar graph program.

  • param_vals (Array) – Array of parameter bit values (f-basis and measurement records).

Returns:

Evaluation results as a complex JAX array.

Return type:

Array