sample_density_matrix: Sample density matrix

Description Usage Arguments Details Value Raises See Also

View source: R/sampling_simulations.R

Description

Samples repeatedly from measurements in the computational basis.

Usage

1
sample_density_matrix(density_matrix, indices)

Arguments

density_matrix

The density matrix to be measured. This matrix is assumed to be positive semidefinite and trace one. The matrix is assumed to be of shape '(2 ** integer, 2 ** integer)' or (2, 2, ..., 2).

indices

Which qubits are measured. The density matrix rows and columns are assumed to be supplied in big endian order. That is the xth index of v, when expressed as a bitstring, has its largest values in the 0th index.

Details

Note that this does not modify the density_matrix.

Value

Measurement results with TRUE corresponding to the “|1⟩“ state. The outer list is for repetitions, and the inner corresponds to measurements ordered by the supplied qubits. These lists are wrapped as an numpy ndarray.

Raises

ValueError: “repetitions“ is less than one or size of “matrix“ is not a power of 2. IndexError: An index from “indices“ is out of range, given the number of qubits corresponding to the density matrix.

See Also

Other Sampling, Simulations and Data collection: big_endian_bits_to_int(), big_endian_digits_to_int(), big_endian_int_to_bits(), big_endian_int_to_digits(), circuit_like(), final_density_matrix(), final_wavefunction(), flatten_to_ops_or_moments(), flatten_to_ops(), flatten_with_params(), flatten_with_sweep(), flatten(), hog_score_xeb_fidelity_from_probabilities(), measure_density_matrix(), measure_state_vector(), random_state_or_seed_like(), sample_state_vector(), sample_sweep(), sample(), to_resolvers(), to_sweep(), validate_mixture()


henry090/Cirq documentation built on June 13, 2020, 1:28 a.m.