Qx.ResultBuilder (Qx - Quantum Computing Simulator v0.6.0)

View Source

Builds Qx.SimulationResult structs from counts data.

Used by Qx.Remote to reconstruct results from the qx_server JSON response, and by provider adapters when converting hardware results.

Statevector placeholder

Hardware backends do not return statevectors. The state field in the resulting Qx.SimulationResult is set to a zero-vector placeholder. Functions that depend on the statevector (e.g. state visualization) will not produce meaningful output for hardware results. Use counts and probabilities instead.

Summary

Functions

Builds a Qx.SimulationResult from a counts map, shot count, and number of classical bits.

Functions

from_counts(counts, shots, num_bits)

@spec from_counts(map(), pos_integer(), pos_integer()) :: Qx.SimulationResult.t()

Builds a Qx.SimulationResult from a counts map, shot count, and number of classical bits.

Parameters

  • counts - Map of binary string outcomes to frequencies, e.g. %{"00" => 520, "11" => 480}
  • shots - Total number of shots executed
  • num_bits - Number of classical bits in the circuit

The state field will be a zero-vector placeholder since hardware backends do not return statevectors.

Examples

result = Qx.ResultBuilder.from_counts(%{"00" => 500, "11" => 500}, 1000, 2)
result.shots
#=> 1000
result.counts
#=> %{"00" => 500, "11" => 500}