Portuguese
Idiomas
English
Bengali
French
German
Japanese
Korean
Portuguese
Spanish
Tamil

# CircuitStateFn¶

class CircuitStateFn(primitive=None, coeff=1.0, is_measurement=False, from_operator=False)[código fonte]

Bases: `StateFn`

A class for state functions and measurements which are defined by the action of a QuantumCircuit starting from |0⟩, and stored using Terra’s `QuantumCircuit` class.

Parâmetros
• primitive (`Union`[`QuantumCircuit`, `Instruction`, `None`]) – The `QuantumCircuit` (or `Instruction`, which will be converted) which defines the behavior of the underlying function.

• coeff (`Union`[`complex`, `ParameterExpression`]) – A coefficient multiplying the state function.

• is_measurement (`bool`) – Whether the StateFn is a measurement operator.

• from_operator (`bool`) – if True the StateFn is derived from OperatorStateFn. (Default: False)

Levanta

TypeError – Unsupported primitive, or primitive has ClassicalRegisters.

Methods Defined Here

 `add` Return Operator addition of self and other, overloaded by `+`. `adjoint` Return a new Operator equal to the Operator's adjoint (conjugate transpose), overloaded by `~`. `assign_parameters` Binds scalar values to any Terra `Parameters` in the coefficients or primitives of the Operator, or substitutes one `Parameter` for another. `compose` Composition (Linear algebra-style: A@B(x) = A(B(x))) is not well defined for states in the binary function model, but is well defined for measurements. `eval` Evaluate the Operator's underlying function, either on a binary string or another Operator. `from_dict` Construct the CircuitStateFn from a dict mapping strings to probability densities. `from_vector` Construct the CircuitStateFn from a vector representing the statevector. `permute` Permute the qubits of the circuit. `primitive_strings` Return a set of strings describing the primitives contained in the Operator. `reduce` Try collapsing the Operator structure, usually after some type of conversion, e.g. `sample` Sample the state function as a normalized probability distribution. `tensor` Return tensor product between self and other, overloaded by `^`. `to_circuit` Return QuantumCircuit representing StateFn `to_circuit_op` Return `StateFnCircuit` corresponding to this StateFn. `to_density_matrix` Return numpy matrix of density operator, warn if more than 16 qubits to force the user to set massive=True if they want such a large matrix. `to_instruction` Return Instruction corresponding to primitive. `to_matrix` Return NumPy representation of the Operator.

Attributes

INDENTATION = '  '
coeff

A coefficient by which the state function is multiplied.

Tipo de retorno

`Union`[`complex`, `ParameterExpression`]

instance_id

Return the unique instance id.

Tipo de retorno

`int`

is_measurement

Whether the StateFn object is a measurement Operator.

Tipo de retorno

`bool`

num_qubits
Tipo de retorno

`int`

parameters
primitive: QuantumCircuit

The primitive which defines the behavior of the underlying State function.

settings

Return settings.

Tipo de retorno

`Dict`