# qsimcirq.QSimSimulatorTrialResult

A mixin that provide methods for objects that have a state vector.

qubit_map A map from the Qubits in the Circuit to the the index of this qubit for a canonical ordering. This canonical ordering is used to define the state (see the state_vector() method).

final_state_vector

qubit_map

## Methods

### bloch_vector_of

Returns the bloch vector of a qubit in the state.

Calculates the bloch vector of the given qubit in the state given by self.state_vector(), given that self.state_vector() follows the standard Kronecker convention of numpy.kron.

Args
qubit qubit who's bloch vector we want to find.

Returns
A length 3 numpy array representing the qubit's bloch vector.

Raises
ValueError if the size of the state represents more than 25 qubits.
IndexError if index is out of range for the number of qubits corresponding to the state.

### density_matrix_of

Returns the density matrix of the state.

Calculate the density matrix for the system on the list, qubits. Any qubits not in the list that are present in self.state_vector() will be traced out. If qubits is None the full density matrix for self.state_vector() is returned, given self.state_vector() follows standard Kronecker convention of numpy.kron.

#### For example:

self.state_vector() = np.array([1/np.sqrt(2), 1/np.sqrt(2)], dtype=np.complex64) qubits = None gives us

$$\rho = \begin{bmatrix} 0.5 & 0.5 \\ 0.5 & 0.5 \end{bmatrix}$$

Args
qubits list containing qubit IDs that you would like to include in the density matrix (i.e.) qubits that WON'T be traced out.

Returns
A numpy array representing the density matrix.

Raises
ValueError if the size of the state represents more than 25 qubits.
IndexError if the indices are out of range for the number of qubits corresponding to the state.

### dirac_notation

Returns the state vector as a string in Dirac notation.

Args
decimals How many decimals to include in the pretty print.

Returns
A pretty string consisting of a sum of computational basis kets and non-zero floats of the specified accuracy.

### state_vector

View source

Return the state vector at the end of the computation.

### __ne__

[{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"Missing the information I need" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"Too complicated / too many steps" },{ "type": "thumb-down", "id": "outOfDate", "label":"Out of date" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"Samples / code issue" },{ "type": "thumb-down", "id": "otherDown", "label":"Other" }]
[{ "type": "thumb-up", "id": "easyToUnderstand", "label":"Easy to understand" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"Solved my problem" },{ "type": "thumb-up", "id": "otherUp", "label":"Other" }]